I would like to setup presence detection to trigger a couple of automations I created, for example:
using the device_tracker of my iPhone (I am running the HA Companion App on it) I am able to pin-point on a map the location where I am at a specific moment.
I setup two zones (Home and Work), specified a radius for each of them and it seems that everything is working fine as far as tracking goes.
I then setup a simple automation where as soon as I leave my home (and I am outside of its radius) I want all my lights, the TV, etc. etc. to turn off
I am unable to get this to work. Or - to be more precise - I need to have the HA Companion App opened and running on my iPhone for it to work.
If I have the HA Companion App closed or even in the background, the automation does not work.
Which seems strange to me because the geolocation seems to work correctly since I am able to review when I was home and when I was away from the device_tracker history and I am 100% sure I wasn’t using the HA Companion App that time.
I also modified my automation to be triggered when my iPhone connection type switch from “Wi-Fi” to “Cellular” but it behaves as before. I need to have the HA Companion App up and running in foreground otherwise it does not work.
I gave the HA Companion App all the needed permissions (position tracking: always even if I am not using the app as well as update sensors every 20 seconds) but so far no luck.
To be fair, I’ve found that the HA companion app isn’t 100% accurate in terms of device tracking. So, what I’ve done is created 4 input_booleans and assigned them to a HomeKit bridge that I have linked to both my wife’s and my iPhones. Then, I use HomeKit automations on our phones to flips those input_booleans on and off when we leave the house and/or arrive at work.
I’ve been running this way for about 2-3 weeks now without a single event missed.
Have you looked at the Life 360 integration? I’m using that and altough it is not instant, it is accurate enough for the purpose of turning off lights, etc.
Thanks code-in-progress and Piggyback for the feedback. I’ll look at both of your suggestions.
It would be really nice if the companion app gets some love and an update that addresses the issue with reporting sensors’ state while being not opened (or in the background). This would be the major feature that would open up automations which are based on where you carry your device really easy to configure - without the need to lean on third party integrations.
The link that @code-in-progress posted (disclosure, I wrote it ) should solve for that (being unopened, in your pocket, whatever). I don’t use the HA app (or any app) for presence detection from me or my family’s iPhones. iOS has its quirks with geofencing, but most of them seem to be ironed out. I’ve been rock solid since I implemented the webhook method in September.
The obvious nit with everything I just said is that iOS relies on having pre-defined locations (your home) and using coarse (low power) GPS to do the geofencing. So obviously it isn’t going to persistently upload your lon,lat. You’ll just get a “home” or “not home.”
To be fair, it’s not really the app so much as it is iOS itself and it’s aggressive battery management for 3rd party apps that aren’t willing to pay a ton of money to Apple. I have a shortcut that launches the HA app every 6 hours so that the system learns to not put it into a deep hibernation state. It’s not a “good” workaround, but it does work (most of the time).