I’m really getting it in the last few days and my automations getting more and more complex.
But at the moment I am a bit stucked with my presence detection.
As I have IPhones for presence detection I am using the way to have an input boolean which is switched on via Apple Home when I come home or leave home. The same is for my son’s IPhone.
When this switch goes from off to on there is a input_select to choose from several options (just left, away, extended away, just arrived, at home, at school).
I also made state sensors to make the automations work.
After a few problems it works flawless.
But to go on I need to work out how to do it when the last person has left or entered the house.
For example I’d like the house to turn down the heating when the last input_select has changed to “away”. It should not happen when one of two input selects has the state “just left”.
On the other hand all lights should be switched off when the input_select of the last person who has left is changed to “just left”.
Is it understandable what I mean? How can I solve this? I guess, when I have a solution for one situation I can figure out all the others.
The state of a zone is a count of how many people are in the zone. So you don’t really need to deal with all the helpers to figure out what you’re trying to do, just look at the state of the zone.
My personal opinion - input helpers set via automations vastly increase the complexity of automations. Now when you’re trying to figure out what’s going on you have this extra layer of indirection to track through. Not only is it why did my automation go sideways, it is how did my even helper get into this state which made my automation go sideways? You have to track that back through automations/scripts which can modify its state.
Instead its usually preferable to try and trigger your automations directly from the sensors or event that you’re interested in. And not use that event to set something else that fires your automation. Not always possible obviously but reduces the complexity.
I personally avoid input helpers other then ones that I intend to set myself in the UI (like a setting for how long a delay should be before the lights turn off). If I have an automation setting an input helper I treat that as a code smell and try and get rid of it.