fix(config_flow): per-host zeroconf updates — blank auto-detect hosts self-heal from the discovery address, a deliberately-different ADB host is never clobbered, same-IP with both hosts current is a no-op (F2)

This commit is contained in:
James Mackay committed 2026-10-08 11:22:04 +01:00
1 parent b37a14b920
commit f03ef1f531
2 files changed
+78 -14

No files matched your search

+16 -12
View File
@@ -280,21 +280,25 @@ class NvidiaShieldConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
for entry in self._async_current_entries():
if getattr(entry, "unique_id", None) != mac:
continue
# Known device — update hosts only on a real IP change
# (core androidtv_remote pattern, simplified): an explicitly
# configured host that moved to the discovery address.
# Known device — per-host updates (t21 F2): each host is
# tracked independently against the discovery address.
# - a blank (auto-detect) host self-heals from the address;
# - a stale protocol host is the IP change and is updated;
# - a deliberately-different ADB host (an explicit override
# that differs from both the address and the stored
# protocol host) is never clobbered.
protocol_host = entry.options.get(CONF_PROTOCOL_HOST, "")
adb_host = entry.options.get(CONF_ADB_HOST, "")
if (protocol_host and protocol_host != host) or (
adb_host and adb_host != host
):
options = dict(entry.options)
if protocol_host != host:
options[CONF_PROTOCOL_HOST] = host
if not adb_host or adb_host == protocol_host:
# blank (self-heal) or auto-synced alongside the protocol
# host — safe to follow the device address on discovery
options[CONF_ADB_HOST] = host
if options != entry.options:
self.hass.config_entries.async_update_entry(
entry,
options={
**entry.options,
CONF_PROTOCOL_HOST: host,
CONF_ADB_HOST: host,
},
entry, options=options
)
self.hass.config_entries.async_schedule_reload(entry.entry_id)
return self.async_abort(reason="already_configured")