button-card
button-card copied to clipboard
State-dependent actions
I have a button which I would like to call different services on tap_action
depending on state.
Ideally the current action format could be implemented in the state list, along with color, icon, styles etc
Current;y I have implemented the following with templates for which service/targets to use:
tap_action:
action: call-service
service: >-
[[[ if (variables.boost_on) return "schedule_state.clear_overrides"; else
return "input_button.press" ]]]
data: {}
target:
entity_id: >-
[[[ if (variables.boost_on) return "sensor.heating_schedule"; else return
"input_button.heating_boost" ]]]
Which works ok for the moment, but could see getting rather unwieldy with more than 2 states, or more difficult if e.g. wanting to target a label rather than an entity in one of the states