i’ve got several Automation for Switch in deconz events but:
Is it possible to create an Automation for two light with Else if Like? Why? I want to use a single Switch (only single click) to Control 2 Lights. 1 in, 1 Off 2 on, both on and both Off.
If light.1 = Off and light.2=Off Then Turn on light.1
Else If light.1 = on and light.2=Off Then Turn off light.1 and Turn on light.2
Else If light.1 = off and light.2=On Then Turn on light.1
Else If light.1 = on and light.2=on Then Turn off light.1 and Turn off light.2
the logic for light 1 always toggles (first bullet light 1 is off, turn it on - second bullet on, turn it off - third its off turn it on, fourth its on, turn it off)
the logic for light 2 is always turning on if both bulbs are in different states, and off if they’re the same.
So I’d do it like this…
trigger:
platform: state
entity_id: YOUR BUTTON
to: 'on'
action:
- service: >
{% if states('light.1') != states('light.2') %} light.turn_on
{% else %} light.turn_off {% endif %}
entity_id: light.2
- service: light.toggle
entity_id: light.1
Edited this like 3 times now because I keep confusing myself - I’m pretty certain it’s right though, give it a go