I’ve been using Home Assistant for a couple of months now, and love it. I’ve written several automations, but I need some help with this one. I’ve been puzzling over this, looking at all kinds of automation examples with time and sunset, and I can’t figure out how to make this work. I want to turn a light on when a motion detector triggers, but only between sunset and 10pm. This is where I am so far:
- alias: Turn on light when motion between sunset and 10pm
trigger:
platform: state
entity_id: sensor.motion_sensor
to: 'motion detected'
condition:
condition: and
conditions:
- condition: state
entity_id: sun.sun
state: 'below_horizon'
- condition: time
before: '22:00:00'
action:
service: light.turn_on
entity_id: light.my_light
data:
brightness: 120
It partially works…The problem is that after midnight, when the day changes, the conditions become true again (until sunrise). I do not want the light to turn on between midnight and sunrise. I’m probably missing something obvious, but if someone could help I’d really appreciate it. Thanks in advance!