using a lot of buttons, Id like to use a template to not have to create hardcoded names for all of these buttons…
all of my counter sensors have the an entity_id like this:
sensor.count_input_selects, sensor.count_groups, sensor.count_input_booleans etc etc.
I want to do the name template like this:
- type: custom:button-card
template: button_body_no_action
entity: sensor.count_input_selects
name: >
[[[ return entity.entity_id.split('_')[1] ]]]
but completely forgot how to split but not leave the second section after a second _ out…
of course id need to capitalize the first capital, but thats easy
[[[
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
}
var id = entity.entity_id.split('.')[1].slice(6);
return capitalizeFirstLetter(id);
]]]
above could also be a valid method, but this is for another type of sensors.
Please help me with my brain-flush…
thanks