Good morning,
it’s my first automation.
As you can see from the code I have two lights that I control with modbus.
Now I’ve done two distinct automations but I think we can do better.
That is, unite them.
I can’t do it with the groups because I could have one of the two lamps lit and in that case it would turn me on and I would turn off the one on.
How could I implement these various states?
Thanks, Alberto
I don’t see how these automations would work. Both are missing the action section. You’re template triggers won’t work either because you have spelling errors in your entity_id’s. ‘bynary_sensor’ isn’t a valid domain, ‘binary_sensor’ is. And lastly, assuming that the services should be in the action section, you are using the toggle service. That means your light will switch on and off. So at sunset, if your light is on, it will turn off.
petro is true !!
I made a mess.
I modified the code, this does not give error.
How can I implement everything in a single automation, taking into account the fact that one or both lights could be turned on?
# ACCENDE
- alias: 'Accende luce corridoio esterno al tramonto'
initial_state: true
trigger:
- platform: sun
event: sunset
offset: +00:20:00
condition:
- condition: state
entity_id: 'binary_sensor.stato_corridoio_ext'
state: 'off'
action:
service: switch.toggle
entity_id: switch.rele_corridoio_ext
- alias: 'Accende luce androne al tramonto'
initial_state: true
trigger:
- platform: sun
event: sunset
offset: +00:20:00
condition:
- condition: state
entity_id: 'binary_sensor.stato_androne'
state: 'off'
action:
service: switch.toggle
entity_id: switch.rele_androme
# SPEGNE
- alias: 'Spegne luce corridoio esterno al tramonto'
initial_state: true
trigger:
- platform: time
at: '22:30:00'
condition:
- condition: state
entity_id: 'binary_sensor.stato_corridoio_ext'
state: 'on'
action:
service: switch.toggle
entity_id: switch.rele_corridoio_ext
- alias: 'Spegne luce androne al tramonto'
initial_state: true
trigger:
- platform: time
at: '22:30:00'
condition:
- condition: state
entity_id: 'binary_sensor.stato_androne'
state: 'on'
action:
service: switch.toggle
entity_id: switch.rele_androme