Device tracker should remember state after restart

With a device tracker provided by iOS companion app, after restarting Home Assistant, the state becomes Unknown for a few minutes until it receives an update from the iOS app. This can take up to 15 minutes. I think it would be better to remember the previous state, to avoid triggering automations that depend on presence.

I’ve had this happen just today with my android phone

There are situations where the unknown state are necessary for other automations, so getting rid of it is not a good idea.
You should instead exclude the “from unknown” state triggering in your automations.

Can you give an example of such a situation? I can see that unknown state is important when the device is not responding for some reason. But I’m talking about the time immediately after restarting Home Assistant. Most other entities remember their state during this time, why is device_tracker different?
I have automations triggered when the number of persons in the home zone changes to or from zero like this:

platform: state
entity_id:
  - zone.home
to: "0"
for:
  minutes: 1

How would the “from unknown” condition work with multiple residents?

There is an example for not_from in the documentation.

I read that example but I don’t understand what harm would come from this feature request.

You might have an automation that resend notifications once a device returns and that would be impossible.

That kind of automation makes sense when a device is unavailable because it lost its network connection or rebooted, etc. But that does not seem useful when the reason for the lost connection is Home Assistant core restarting.

There is no way to tell if the phone is online or not when HA comes up, so you might send important messages to a device that are not there yet.
The restart is just a shutdown and a start in HA and there is no way to tell for how long HA was down either.

+1. Seems to be an issue when manually adding zones. When HA is restarted, it doesn’t detect or call the correct zone again, instead fallbacks to Home/Away states.