This is a question about why HA appears to depend on some devices never changing their IP’s.
(N.B.: This is NOT a question about how-to make addresses static, as I’ve been doing IP networking for 35+ years, and generally avoid statically nailing down IP addresses wherever possible, as that’s what name-services like DNS and mDNS were designed for.)
So, all my devices (mostly ESPHome-based) get their IPs from the router’s DHCP (dnsmasq) service, and so each of their hostnames do always point to whatever address a device has.
But if I restart everything (e.g. power-cycle of the whole house), the devices might get IPs that are different from what they had prior. Their hostnames still resolve to their current IPs of course, but the IPs may differ from the past.
… And this seems to easily create problems for HA (observed with Shelly and ESPHome so far). This is the focus of my question.
HA will accuse devices of being unavailable (they’re online, and findable by name), or it will sometimes show two devices (the current and former holders of the given IP addr) when I search the integrations’ page for one by name.
Looking in .storage/core.* files, I see that HA is remembering devices names and their last-known IP’s.
Why? I’m guessing it’s for efficiency during runtime, perhaps. That makes sense. But when a surprise happens (e.g. device is ‘unavailable’) shouldn’t HA then fallback to just asking for it by name (and voila! there’s the device!) and recover the connection gracefully?
It’s clear to me that the designer(s) of HA and its major integrations are very wise and intelligent people, so questioning this design aspect is something I do humbly, expecting that there is a reasonable answer. But I haven’t been able to find it yet.
Searching docs and forum posts for the basis of this design choice has not been fruitful - I’ve certainly tried - probably due to the wide usage of the search terms involved.
Can anyone familiar with the core design philosophies tell me why it does this, and why it doesn’t fallback to a name lookup when something unexpected happens?