I would like to have it be that if its anytime before 30 minutes prior to sunset, the lights turn on and off when I trigger an action. If its within 30 minuts of sunset or after, then only turn the stairway light off,as the hallway light will already be on from another action. Currently not working, as both lights turn off even after sunset.
- id: '1653420314161'
alias: Hallway Motion Triggered Lights
description: ''
trigger:
- type: motion
platform: device
device_id: 77d39428abe145aebee509b8f7a9cc03
entity_id: binary_sensor.third_reality_inc_3rms16bz_iaszone
domain: binary_sensor
- type: opened
platform: device
device_id: 67c71e4256c239940d1ce93d2dea9cba
entity_id: binary_sensor.front_door
domain: binary_sensor
- type: opened
platform: device
device_id: 180b3575c189246a006588db1642c9b4
entity_id: binary_sensor.house_garage_door
domain: binary_sensor
condition: []
action:
- if:
- condition: sun
before: sunset
before_offset: -00:30
then:
- service: homeassistant.turn_on
data: {}
target:
entity_id:
- light.hallway
- switch.stairway_lights
- delay:
hours: 0
minutes: 2
seconds: 0
milliseconds: 0
- service: homeassistant.turn_off
data: {}
target:
entity_id:
- switch.stairway_lights
else:
- service: homeassistant.turn_on
data: {}
target:
entity_id:
- light.hallway
- switch.stairway_lights
- delay:
hours: 0
minutes: 2
seconds: 0
milliseconds: 0
- service: homeassistant.turn_off
data: {}
target:
entity_id:
- light.hallway
- switch.stairway_lights
mode: single