Please Help Me Figure Out If I'm Coming or Going

I have an HA setup that has been working just fine for some time, and have mobile devices set up on iPhone and Android for various users. For the past week or two, my Android Companion app keeps toggling between Home and Away. It seems to be doing this multiple times per hour, if you can believe the logbook for the device itself. For example, there are 5 toggles between “X was detected away” and “X was detected at home” in the last hour alone, and at least one per hour for the rest of today.

By itself, I wouldn’t care about this, except that I have two automations based on location. The first is a simple Automation whenever me or my wife “enters Home zone”, where it sends out an Email via the SMTP gateway. When these “phantom” transitions occur (where I don’t actually leave), I do NOT get the SMTP Email, which is perfect. This means that HA detects the odd flip and doesn’t act on it.

The other automation is the problem. As it is a bit more complicated, I have set it up in NodeRed. It starts with a Zone Node “Someone comes home”, which is defined as me or the wife “enter” the “zone.home”. It then checks to see if the sun is down, and if it is, pop on additional lighting around the outside of the house, delay for 15 minutes, and then turn the lights off.

With the odd “coming and going” on the Android Companion app, this is triggering the NodeRed job and turning the lights on and off again all night long – sometimes multiple times per hour. I have tried changing the location settings to various combinations, to no avail. I can remove my phone from the list, but then the lights will only come on when the wife is with me and we come home together. I would really like the lights to come on when I get home, but the constant lighting over night keeps waking us up.

Does anyone have any suggestions to get this working?

Is the device tracker provided by the companion app the only tracker attached to your person entity?

There are several ways to create a workaround for this. Though I would start by trying to fix this and look at the settings of the phone. Battery saving, location precision and so on.

But if you really need a workaround I would create a helper that keeps track of how long you are away before getting home. If that is shorter then, let’s say, 10 minutes the automation should not trigger. So the helper (timestamp) has to have it’s own automation which triggers when your phone “leaves” and sets the helper to the current timestamp. Then the coming home automation could check if the difference between the timestamp (on trigger) is more then 600 second higher then the value of the helper.