Hi people, i would like some help to make an automation for my backyard light.
what i want is if i open the door and its left open for longer than 30 seconds to leave the light on till the door is shut or if its longer than 5 minutes turn the light off.
If the door was open and closed within 30 seconds to leave the light on till the door is open and closed again or if its longer than 10 minutes turn the light off.
The reason is when we go outside we tend to shut the door behind us so it will be nice to have that automation to turn the light off after we come back in.
ATM my automation is below
Turn on automation:
alias: Turn on Backyard light
trigger:
- platform: state
entity_id: binary_sensor.Backyard_motion
to: 'on'
- type: opened
platform: device
device_id: ac5a9011c62910ca87bdd83d05ec54a4
entity_id: binary_sensor.backdoor_left_contact
domain: binary_sensor
condition:
- condition: state
entity_id: switch.sonoff_backyard
state: 'off'
- condition: or
conditions:
- condition: sun
after: sunset
- condition: sun
before: sunrise
action:
- service: switch.turn_on
entity_id: switch.sonoff_backyard
- service: automation.turn_on
entity_id: automation.turn_off_backyard_light
mode: single
Turn off automation:
alias: Turn off Backyard light
trigger:
- platform: state
entity_id: binary_sensor.Backyard_motion
to: 'off'
for:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
- type: not_opened
platform: device
device_id: ac5a9011c62910ca87bdd83d05ec54a4
entity_id: binary_sensor.backdoor_left_contact
domain: binary_sensor
condition:
- condition: or
conditions:
- condition: sun
after: sunset
- condition: sun
before: sunrise
action:
- service: switch.turn_off
entity_id: switch.sonoff_backyard
- service: automation.turn_off
entity_id: automation.turn_off_backyard_light
mode: single