I’m stumped as to why the following automation is not getting trigger.
- id: turn_on_family_room_lamps_with_motion_at_night
alias: Turn On Family Room Lamps If There Is Motion At Night
trigger:
platform: state
entity_id: sensor.foyer_motion
to: 'active'
condition:
condition: and
conditions:
- condition: state
entity_id: sun.sun
state: 'below_horizon'
- condition: time
after: '22:30'
- condition: sun
before: sunrise
action:
service: homeassistant.turn_on
entity_id: switch.family_room_lamps
Is it necessary to check if the sun is below the horizon AND the time is later than 22:30? Unless you live near the Arctic, it can be assumed the sun is below the horizon by 22:30.
If we use that assumption then we can simplify the filtering to: (Time > 22:30) OR (Before sunrise)
Then I think it looks like this in YAML (I have not tested it):
condition:
condition: or
conditions:
- condition: time
after: '22:30'
- condition: sun
before: sunrise