Im having problems with what I thought was a pretty basic presence based automation.
Presence detection is handled by the sky hub component, and I use the following automation to set an input select to either Home or Away
I can see that the device tracker is changing to not_home when I leave, and the input select is being set to Away, but the script.home_mode_away
I know the presence detection is working, as I have other automations that fire OK when I leave home (e.g. turn our lights left on etc.)
If I manually trigger the script it fires, and the automations are toggled on/off as I expect.
Am I missing something here?
Ah OK, I suspected this, but I could not find any documentation on calling scripts in automations?
Has this changed in recent version of HA?
These automations and scripts fired perfect in the past (before updating to v0.88.x)
well, ive just checked from the services dev tab, and I can fire the script by calling the script.turn_on service.
but can also fire it by calling the service script.home_mode_home
im stuck!
OK, so both of us have confirmed the action: section of the automation is valid. If the action: never happens then it means there may be something wrong with the trigger: section.
Please post the configuration for input_select.home_mode.
agreed.
the trigger is initially device_tracker.rich_phone_s8 changing state. Data template will change an input select according to whether im home or away
The home mode automation is triggered by this input_select.home_mode
I can see in my frontend that this input select is correctly showing Away
The trigger for the “away mode” automation is the input select being at Away for 5 minutes…which it is…yet it does not fire?
I don’t know that this will solve the problem, but at the very least you should change:
data_template:
option: >
{% if is_state('device_tracker.rich_phone_s8', 'home') %}
Home
{% elif is_state('device_tracker.rich_phone_s8', 'not_home') %}
Away
{% endif %}
to:
data_template:
option: >
{% if is_state('device_tracker.rich_phone_s8', 'home') %}
Home
{% else %}
Away
{% endif %}
You should never have a potential for a service_template or data_template to return nothing. E.g., if the state of device_tracker.rich_phone_s8 ever changed to something other than home or not_home, which it would if you ever entered a zone other than zone.home, this automation wouldn’t work. Ending with an else clause will cause it to always return something, which in this case, is what I think you would want.
But getting back to the automation not triggering. There are only two possibilities that I can think of. The first is the automation is somehow off when the five minute interval expires. I see you have initial_state set to on, which is a good thing, but are you sure something else isn’t turning it off?
The other possibility is that input_select.home_mode is not staying in the Away state for a full five minutes. Could it possibly be changing to something else before five minutes is up (and, I guess, staying in some other state than Away)?
If none of that helps, then make sure you have logger set to debug (for everything), then analyze home-assistant.log. The details of what is, and isn’t, happening should be in there.
Thanks for the tip, I will change it as it makes sense, but I have no other zones set up and have never seen the device tracker show as anything other than home or not_home
Positive, if I check the state of the automation it shows as on
Again, positive this is not the case. As mentioned in the OP the input select is showing as being set to Away
logger is set to debut already, and having a look through, I don’t see anything obvious.
Ill take a closer look later…im actually away on business now, so this will have to be put on hold unfortunately.
I doubt this would be the case, but it is possible for it to change to something other than Away (e.g., unknown) so shortly you don’t see it, but even a microsecond would be enough to cause the 5 minute “for” period to restart. That’s why you really need to check the log. But, like I said, doubt that’s what’s happening. Good luck!