Programmatically setting a person location to "home" when it opens the door

I understand that sometimes the Home Assistant app will get delayed in updating a person’s location.

At my house, sometimes something odd happens: one of my sons opens the front door using our Nuki smart lock’s keypad fingerprint reader, so I know he is home, but his location is still outdated and shows that he is kilometers away from home. That happens especially with my older son, who has an iPhone.

What I would like to do is to update a person’s location to “home” when some event, like opening the door with his password or fingerprint, happens.

Does anybody know if this is possible? Could you give me some pointers?

P.S. 1: I have already set all possible sensor update settings, power management, and sleep settings. Most of the time, it works fine (sometimes even too well, like one of my sons who has an Android phone and whose school is one block away, and sometimes the location goes bonkers, and he falsely moves zones very quickly).
So this is out of my question’s scope (though suggestions are welcome).

P.S. 2: I’m still looking for a good way of getting a specific event from the Nuki smark lock when a particular person opens the door. I did something based on API checks, but it is still clumsy and unreliable. However, I’m on my way to getting this to work. So, this is also out of the scope of the question (but suggestions are also welcome).

Yes you can set the state but as long as the phone is also setting the state, it will likely re-set to the phone state. Now… if (!) the phone state does not update to th e’away’ state and the next state value would be ‘home’ as well then this may work.
And our iPhones are slow too, so join the club :frowning:

If you have a way to get the person from Nuki, you can use device_tracker.see to create and populate a device_tracker entity.

You may also want to see what other tracker sources are available particularly stationary trackers like router or Bluetooth-based options.

I am combining ESPresense (everyone has an apple watch, don’t know if that matters, it’s pretty reliable this way) and network presence to detect if a person is “at home”, no need to waste battery with GPS.

And you could use the Bayesian integration to work out whether a person is “probably” home, based on device trackers, wi-fi usage, Bluetooth proxies, movement in particular rooms, time of day and anything else you can think of.

If you take enough factors into account this is more accurate and more responsive than device trackers alone.