mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Fix KeyError during call to homekit.unpair (#63627)
This commit is contained in:
parent
1ea3a17d89
commit
945477a482
@ -708,7 +708,12 @@ class HomeKit:
|
||||
"""Remove all pairings for an accessory so it can be repaired."""
|
||||
state = self.driver.state
|
||||
for client_uuid in list(state.paired_clients):
|
||||
state.remove_paired_client(client_uuid)
|
||||
# We need to check again since removing a single client
|
||||
# can result in removing all the clients that the client
|
||||
# granted access to if it was an admin, otherwise
|
||||
# remove_paired_client can generate a KeyError
|
||||
if client_uuid in state.paired_clients:
|
||||
state.remove_paired_client(client_uuid)
|
||||
self.driver.async_persist()
|
||||
self.driver.async_update_advertisement()
|
||||
self._async_show_setup_message()
|
||||
|
@ -679,6 +679,11 @@ async def test_homekit_unpair(hass, device_reg, mock_async_zeroconf):
|
||||
|
||||
state = homekit.driver.state
|
||||
state.add_paired_client("client1", "any", b"1")
|
||||
state.add_paired_client("client2", "any", b"0")
|
||||
state.add_paired_client("client3", "any", b"1")
|
||||
state.add_paired_client("client4", "any", b"0")
|
||||
state.add_paired_client("client5", "any", b"0")
|
||||
|
||||
formatted_mac = device_registry.format_mac(state.mac)
|
||||
hk_bridge_dev = device_reg.async_get_device(
|
||||
{}, {(device_registry.CONNECTION_NETWORK_MAC, formatted_mac)}
|
||||
|
Loading…
x
Reference in New Issue
Block a user