Hi,
Trying my first automation.
I need to turn the light on in a walking closet. All lights (for the moment) are connected to an electric on/of switch remotelely controlled by a Broadlink RMPRO with RF commands on and off (no state).
The trigger would be a xiaomi door/window sensor. It is fine that lights are ON going in and kept on with the door open (it’s ok) and then turned OFF when I leave the room (closing the door).
What would be the automation code?? Is this ok or there are better ways?
- alias: "Walking closet light on"
trigger:
- platform: state
from: 'off'
to: 'on'
entity_id: binary_sensor.door_window_sensor_158d00010e25c5
action:
service: switch.turn_on
entity_id: switch.closet
- alias: "Walking closet light off"
trigger:
- platform: state
from: 'on'
to: 'off'
entity_id: binary_sensor.door_window_sensor_158d00010e25c5
action:
service: switch.turn_off
entity_id: switch.closet