button-card icon indicating copy to clipboard operation
button-card copied to clipboard

State-dependent actions

Open hilburn opened this issue 9 months ago • 1 comments

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

hilburn avatar May 24 '24 09:05 hilburn