Hi all, first time post - still a novice but learning a lot!
I have pasted the YAML code below for an automation I’m working on that removes an “away” hold on my home Ecobee thermostats and resumes their normally scheduled program/setting.
It runs perfectly if I disable the condition of the navigation arrival time being between 1-45 minutes. (Reason I’d like that condition is that if I begin navigating to ‘home’ from somewhere that’s a few hours away, I wouldn’t want the thermostats to release the ‘away’ hold until I’m about 45 minutes away).
However, when I enable the condition, the automation will not trigger - even when the arrival time is between 1-45 minutes.
Any idea why the condition is not working the way I’d like? When testing (going out for a drive, and navigating to ‘home’) if in Home Assistant I click on the entity ‘White Rabbit Arrival time’ and within that entity click on the attribute: ‘Minutes to arrival’, Home Assistant correctly displays the minutes to arrival correctly (matches the minutes to arrival shown on the Tesla navigation screen).
Any and all guidance would be appreciated, I’m having a blast learning this stuff - thanks!
When you perform the test, does the device_tracker’s state change to home earlier than the desired time frame? For example, does it change to home 50 minutes before arrival?
If it does then when the automation is triggered, the condition won’t pass, and the actions won’t be executed. The automation won’t trigger again until the device_tracker’s state changes to home again. In other words, it must first change to not_home before it can change to home.
If you thought that after the automation is triggered, it will wait until the condition is fulfilled, that’s not how it works. The condition is tested and if it’s not fulfilled immediately, the automation ends. The automation won’t trigger again until its State Trigger detects the device_tracker changing to home.
If minutes_to_arrival reports a value only when the device_tracker’s state changes to home then perhaps your automation’s trigger should be using a Numeric State Trigger to detect when minutes_to_arrival is below 45.
Got it, that makes sense - in that case, would it work if I reverse the order - making the arrival time the trigger and the device_tracker state: home the condition? Although, at the time I tested, it should have simultaneous changed the device_tracker state and the arrival time I think
Yes. As suggested above, use a Numeric State Trigger.
If the device_tracker only reports proximity for one location then there may be no need to add a State Condition (to confirm the device_tracker’s state is home).
Double-check because that may change what needs to be done to fix it.
BTW, you can test the automation by “forcing” the device_tracker’s values. Select the device_tracker in Developer Tools > States, set values for state and minutes_to_arrival then click the Set State button.
Settings its values this way is sufficient to activate the automation’s trigger but the values are not permanent and will be changed by the device_tracker’s integration, whenever it updates, or when Home Assistant is restarted.
Well it looks like I did test it the way we’re discussing as well and it didn’t trigger:
I believe the destination_location_tracker state being ‘home’ is needed - because the automation should only trigger if I’m navigating home - not if I’m navigating to any other destination
The developer tools insight for testing you gave me is very interesting, I’m going to look at that right now a bit - and I’m trying to go through the logbook to show you what Home Assistant displayed while I was out doing the live tests. But the Unknown in the screenshot above is only because it’s a live screenshot and the car is not currently navigating to any destination. When it is - those two values show correctly (minutes to arrival shows a decimal like 4.6 and Destination location tracker shows home)
I think I’m going to go out and do a live test in the car while watching the developer tools state and see if it shows numbers as I’d expect them to look… because the arrival time is seeming to update in the logbook but the minutes to arrival attribute doesn’t show up in the logbook… making me curious
Idea: Maybe I put in a 2 minute wait here before the minutes to arrival attribute condition kicks in (because the data is polled from Tesla every 1 minute). It may be a timing issue?
I fixed the attribute’s spelling and that fixed the issue, all is working well thanks again for all your guidance - lots of it will be helpful for the future too! Warm Regards!