Light Automation Not Triggering

I am trying to automate turning on some lights when I return home.

I have the automation setup and when I trigger the state change (to Home) in HA manually the automation fires and the lights turn on.
However when I return home and the same state changes to “Home” the automation does not fire.

I’ve read the automation trigger page at (Automation Trigger - Home Assistant) and things look right. I did notice however that the page says “Warning: Use quotes around your values for from and to to avoid the YAML parser from interpreting values as booleans.”

But when I view the ‘Trigger’ in Yaml mode (edit in YAML) there are no quotes around the to: value
I have:

platform: state
entity_id: device_tracker.mobile
to: Home

When I edit it and put the quotes in and save it, they are automatically removed. I’m assuming this warning in docs has been depreciated.

Is there a way to step through the automation to see where or why it’s failing?

When you check the state value of device_tracker.mobile in Developer Tools > States, does it indicate Home or home? Use whichever one it is in the State Trigger.

@123 The state value is; Home
I did notice during my testing that this value is case sensitive.

So I do have have 4 triggers and I believe Trigger’s are ‘or’ as I can manually set the state of any of the Triggers and the automation fires.
If I am wrong on the Trigger’s being ‘or’ I’ll have to setup 4 automations for this which is absolutely fine.

For conditions I have 2; After Sunset, and the light being ‘off’. I believe Conditions are ‘and’. If I change them (say to before sunset) the automation fires properly when the state is manually set.

Check the automation’s trace.

For more information refer to Troubleshooting Automations.

@123

Damn that’s awesome!

So it seems that the only time the automation is being fired is when I manually change the State value of device_tracker.mobile.

I’ve triple checked and this is the right device. If I pull up the hstate history on the device in ‘Developer Tools’ I can see my exciting daily travels to and from work. So for some reason when I get home and the device’s state is set to Home the automation is not firing.

I’m going to duplicate the automation and change ‘Home’ to ‘home’ and see what happens. I’m positive nothing will change.

I also just added an entity card to the dashboard with device_tracker.mobile as the only entry. Currently I’m “At Rob’s Work” (a zone I created).

The reason why I asked is because the documentation for Device Tracker indicates the states are home/not_home.

@123

I set up a ‘Home’ zone which should be the value used. The docs say if there is a zone it’s value will be used and is case sensitive.

I’ve duplicated the automation TO: to ‘home’. I also removed the From: value in both automations.
I changed the sun condition to ‘after sunrise’ so I can test it at lunch.

@123

‘home’ did the trick. Thank you for the second set of eyes!

1 Like