I setup an automation to turn my hall light when I opened the front door and the sun is set and leave the light on for 3 mins. The light comes on when I open the door but sometimes it will turn off as soon as the door closes. It should stay on for 3 mins. Here is my automation:
## Turn Hall light on when I get Home
- alias: Turn Hall light on when I get Home
trigger:
platform: state
entity_id: binary_sensor.front_door
to: 'on'
condition:
condition: and
conditions:
- condition: sun
after: sunset
after_offset: "-00:30:00"
action:
- service: homeassistant.turn_on
entity_id: switch.front_hall_light_switch
- delay: '00:03:00'
- service: homeassistant.turn_off
entity_id: switch.front_hall_light_switch
You can delete delay part also and create another automation for turning light off. This way it doesn’t matter how many times you opened and closed door as long as they stay closed for 3 minutes. Also add condition for front_hall_light_switch is on.
trigger:
platform: state
entity_id: binary_sensor.front_door
from: 'on'
to: 'off'
for:
minutes: 3