Hello all.
I’m hoping someone can see the error in my code here.
What I want to do is when a user comes home after sundown, the outside lights turn on, then turn off 10 minutes later.
I am using the ping instruction for presence detect as some of the users do not have data plans on their phones, so it says they’re home when they connect to the house wifi.
I’ve setup tracker id’s for each user and on the main screen of home assistant, it does show them as home and away correctly.
I can also turn the outside light on and off from the main page as well, so those things seem to be setup correctly.
The problem is the automation doesn’t work. I turn my phone wifi on and off and watch home assistant show me as away, then home, but the lights don’t turn on. I’ve even removed the first sun.sun condition, and still no lights.
Any ideas? Please note that I’m a bit of a noob to programming, so speak slooooooowly.
If I’ve formatted this wrong, or you need more info, please let me know.
Thank you.
Here is the section of my configuration.yaml
# Triggers for light automation for user1
automation:
- alias: 'Turn on outside light when user1 comes home after dark'
trigger:
- platform: state
entity_id: device_tracker.user1
to: 'home'
condition:
condition: state
entity_id: sun.sun
state: 'below_horizon'
action:
service: light.turn_on
entity_id: switch.outside_front_lights
- alias: 'Turn off outside light 10min after user1 comes home'
trigger:
- platform: state
entity_id: device_tracker.user1
to: 'home'
for:
minutes: 10
condition:
condition: state
entity_id: sun.sun
state: 'below_horizon'
action:
service: light.turn_off
entity_id: switch.outside_front_lights