I have set an automation to turn on the light when someone gets back home after sunset and before sunrise but it won’t trigger.
Here is the code:
alias: Welcome Home
description: Run welcome home automations
trigger:
- platform: zone
entity_id: person.xxx
zone: zone.home
event: enter
- platform: zone
entity_id: person.yyy
zone: zone.home
event: enter
condition:
- condition: sun
before: sunrise
after: sunset
action:
- type: turn_on
device_id: ac7954f610e522ec095f3498fe2e862f
entity_id: light.entrance
domain: light
brightness_pct: 40
mode: single
I can see the state of the triggers and condition being met in the logbook:
[xxx] was at home
20:00:42 - 21 minutes ago
[Sun] set
19:18:00 - 1 hour ago
But the light is not turned on. When I click on execute manually, the light is turned on.
I set this up with the GUI so the device and entity are correct.
No seriously there appear to be uses for the Sun object like defining offsets, checking elevation etc but for the simple use case that you need just check the state