Retry lookin setup later if the wrong device is found (#98881)

This commit is contained in:
J. Nick Koston 2023-08-23 10:21:38 -05:00 committed by GitHub
parent b884dafa81
commit ba9c969d91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -104,6 +104,17 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
except (asyncio.TimeoutError, aiohttp.ClientError, NoUsableService) as ex:
raise ConfigEntryNotReady from ex
if entry.unique_id != (found_uuid := lookin_device.id.upper()):
# If the uuid of the device does not match the unique_id
# of the config entry, it likely means the DHCP lease has expired
# and the device has been assigned a new IP address. We need to
# wait for the next discovery to find the device at its new address
# and update the config entry so we do not mix up devices.
raise ConfigEntryNotReady(
f"Unexpected device found at {host}; expected {entry.unique_id}, "
f"found {found_uuid}"
)
push_coordinator = LookinPushCoordinator(entry.title)
if lookin_device.model >= 2: