Hi All,
I basically want to use the custom:button-card card to create button entities that show the current state of my lights as well as the time elapsed since the last state change. I’m able to accomplish this by creating a template sensor for each light and pull that value into the label of the custom:button-card.
Button-card
type: 'custom:button-card'
entity: light.bedroom_1
tap_action:
action: toggle
hold_action:
action: more-info
label: '[[[ return ` ${states[''sensor.bedroom_1_time_since_state_change''].state}` ]]]'
name: Bedroom 1
show_label: true
styles:
label:
- color: grey
Template Sensor
bedroom_1_time_since_state_change:
entity_id: light.bedroom_1
friendly_name: bedroom 1 time since state change
icon_template: mdi:clock-outline
value_template: "{{ relative_time(states.light.bedroom_1.last_changed) }}"
My question is, is there a better way to do this other than manually creating a template sensor for each light in my setup? Either by using templates for creating the template sensor for all devices in the light domain OR being able to use the relative_time option in the button-card? Thanks