I’m struggling to come up with a way to have one button toggle between different states of the light. I’m trying to get it to work in the following way:
- The light is off.
- First button press toggles the light on, sets the brightness to 50/256 and temperature to 2200 K
- Second button press increases the brightness to 150 and changes temperature to 2800 K
- Third button press increased the brightness all the way up to 255 and temperature to 3200 K
- Fourth button press turns the lift off, so moving back to step 1.
I don’t want to write 4 different automations for this, each with each own condition. I’d like to have one automation. I’m trying this approach (for now only two states):
alias: ...
trigger:
- ... truncated for brevity ...
condition: []
action:
{% if is_state('light.lamp', 'off') %}
- action: light.turn_on
data:
entity_id: light.lamp
brightness: 50
{% else %}
- action: light.turn_off
data:
entity_id: light.lamp
{% endif %}
mode: single
The syntax isn’t valid though. I’m struggling to come up with a way to have a conditional item in the actions
array that would depend on the state. Tried to find a way to do that in Jinja docs, but to no avail. I’d appreciate any pointers. Thanks!
6 posts - 3 participants