Do not try to cleanup invalid config entries without an AccessoryPairingID (#108830)

This commit is contained in:
J. Nick Koston 2024-01-24 22:49:27 -10:00 committed by GitHub
parent da7d2ef228
commit 82d21136bd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 48 additions and 4 deletions

View file

@ -272,8 +272,14 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
# Device isn't paired with us or anyone else.
# But we have a 'complete' config entry for it - that is probably
# invalid. Remove it automatically.
if not paired and existing_entry:
# invalid. Remove it automatically if it has an accessory pairing id
# (which means it was paired with us at some point) and was not
# ignored by the user.
if (
not paired
and existing_entry
and (accessory_pairing_id := existing_entry.data.get("AccessoryPairingID"))
):
if self.controller is None:
await self._async_setup_controller()
@ -282,7 +288,7 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
assert self.controller
pairing = self.controller.load_pairing(
existing_entry.data["AccessoryPairingID"], dict(existing_entry.data)
accessory_pairing_id, dict(existing_entry.data)
)
try: