Hello, I am trying to write following automation. However I am not quite sure where I am getting it wrong. I was hoping second look from someone here might help find the problem.
As description mentions, I am looking to turn on the light based of motion between 30 prior to sunset and 10:00 pm and 5:00 am to 30 min past sunrise.
alias: Office Motion Activated Lights - Turn On
description: >-
This automation triggers light on based on motion detected in room / area.
This will automation will work from Sunset (-30 min) until bed time and wake
up time until past an hour after sunrise.
trigger:
- type: motion
platform: device
device_id: b93c7f2f4457139b70823800acb3581e
entity_id: binary_sensor.motion_sensor_office
domain: binary_sensor
condition:
- condition: sun
after: sunset
after_offset: '-00:30:00'
before: sunrise
before_offset: '00:30:00'
- condition: and
conditions:
- condition: time
after: '5:00'
before: '22:00:00'
action:
- type: turn_on
device_id: 7d498ebe74e3caa2cbc359d6cc3e104c
entity_id: light.office
domain: light
brightness_pct: 75
mode: single
This automation does not do anything at this point. However if I remove following, it does turn on lights from 30 min prior to sunset to until midnight.
before: sunrise
before_offset: '00:30:00'
- condition: and
conditions:
- condition: time
after: '5:00'
before: '22:00:00'
I have also tried listing all conditions under one AND condition block as well but that does not seem to work either.
alias: Office Motion Activated Lights - Turn On
description: >-
This automation triggers light on based on motion detected in room / area.
This will automation will work from Sunset (-30 min) until bed time and wake
up time until past an hour after sunrise.
trigger:
- type: motion
platform: device
device_id: b93c7f2f4457139b70823800acb3581e
entity_id: binary_sensor.motion_sensor_office
domain: binary_sensor
for:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
condition:
- condition: and
conditions:
- condition: time
after: '5:00'
before: '22:30:00'
- condition: sun
after: sunset
after_offset: '-00:30:00'
before: sunrise
before_offset: '00:30:00'
action:
- type: turn_on
device_id: 7d498ebe74e3caa2cbc359d6cc3e104c
entity_id: light.office
domain: light
brightness_pct: 75
mode: single