I have a TP-Link Casa switch running my outdoor lights and I have it setup in the native app to turn on at sunset and turn off at 23:15.
I wanted home assistant to turn it back on if I get home after 23:15, but before sunrise.
I setup the following automation, that seems to fail at the after sunset, before sunrise condition
alias: Welcome home
description: When we come home at night and outside lights are off, turn them on
trigger:
- platform: state
entity_id:
- device_tracker.iphone_ian_2
- device_tracker.wok_2
to: home
condition:
- condition: sun
after: sunset
enabled: true
before: sunrise
- condition: device
type: is_off
device_id: 838c487b0380cd5fc80542d5da2ee686
entity_id: switch.lumieres_ext_entree
domain: switch
action:
- type: turn_on
device_id: 838c487b0380cd5fc80542d5da2ee686
entity_id: switch.lumieres_ext_entree
domain: switch
mode: single
I also added the condition that if it was already on, I did not want it to turn on again (not sure this is needed).
The last trigger ended with this:
Executed: July 16, 2022, 1:02:15 AM
Result:
wanted_time_before: ‘2022-07-16T09:07:35.851989+00:00’ wanted_time_after: ‘2022-07-17T00:33:47.220128+00:00’ result: false
As you can see from the trace log, we’re well after sunset, and well before sunrise…
I’m not sure why it’s not working.