if my garage door is opened between the Sunset and Sunrise I wanted to turn on the Garage light Switch.
I also wanted to turn of the lights 5 minutes after the door is closed, ( I haven’t added this part yet, as I am not sure how do do that)
Here is my Automation YAML
alias: Tun on the Garage Lights if Garage Entrance Door is open
description: ''
trigger:
- platform: state
entity_id: binary_sensor.garage_door
from: 'off'
to: 'on'
condition:
- condition: sun
after: sunset
before: sunrise
action:
- service: switch.turn_on
target:
entity_id: switch.garage_light_mss550x_main_channel
mode: single
My automation is not triggering or running, can someone tell me what am I doing wrong here? Also can you please guide me on what configuration I have to add to turn of the lights 5 mins after I close the door
I got this automation to work by changing the script to the following
alias: 'Garage Light when door is opened '
description: ''
trigger:
- platform: state
entity_id: binary_sensor.garage_door
from: 'off'
to: 'on'
condition:
- condition: or
conditions:
- condition: sun
after: sunset
- condition: sun
before: sunrise
action:
- service: switch.turn_on
target:
entity_id: switch.garage_light_mss550x_main_channel
mode: single
However still not sure how do I configure it to turn off 5 mins after closing the door, should I create another automation for it or can I get achieve it from single automation ?
you could add to the actions after turning light on and add a wait for state, door closed, delay 5 mins, turn off light.
This would mean the automation is always running all the time the door has been opened subject to the conditions set of course and I know some people don’t like leaving automations running for any great length of time in case of HA restarts or editing automations etc
So you could also if required make a separate automation that simply turns off light if state of door has been closed for 5 mins.
alias: 'Garage Light when door is opened '
description: ''
trigger:
- platform: state
entity_id: binary_sensor.garage_door
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: sun.sun
state: above_horizon
action:
- service: switch.turn_on
target:
entity_id: switch.garage_light_mss550x_main_channel
mode: single