diff --git a/homeassistant/components/homekit/__init__.py b/homeassistant/components/homekit/__init__.py index 705b671f28a..58f3ab14ca9 100644 --- a/homeassistant/components/homekit/__init__.py +++ b/homeassistant/components/homekit/__init__.py @@ -532,11 +532,6 @@ class HomeKit: # as pyhap uses a random one until state is restored if os.path.exists(persist_file): self.driver.load() - self.driver.state.config_version += 1 - if self.driver.state.config_version > 65535: - self.driver.state.config_version = 1 - - self.driver.persist() async def async_reset_accessories(self, entity_ids): """Reset the accessory to load the latest configuration.""" @@ -688,6 +683,7 @@ class HomeKit: self._async_register_bridge() _LOGGER.debug("Driver start for %s", self._name) await self.driver.async_start() + self.driver.async_persist() self.status = STATUS_RUNNING if self.driver.state.paired: diff --git a/homeassistant/components/homekit/accessories.py b/homeassistant/components/homekit/accessories.py index ec6ef670f44..2cd63facf24 100644 --- a/homeassistant/components/homekit/accessories.py +++ b/homeassistant/components/homekit/accessories.py @@ -528,9 +528,9 @@ class HomeDriver(AccessoryDriver): self._bridge_name = bridge_name self._entry_title = entry_title - def pair(self, client_uuid, client_public): + def pair(self, client_uuid, client_public, client_permissions): """Override super function to dismiss setup message if paired.""" - success = super().pair(client_uuid, client_public) + success = super().pair(client_uuid, client_public, client_permissions) if success: dismiss_setup_message(self.hass, self._entry_id) return success diff --git a/homeassistant/components/homekit/manifest.json b/homeassistant/components/homekit/manifest.json index c63ce2a8927..e40d743068c 100644 --- a/homeassistant/components/homekit/manifest.json +++ b/homeassistant/components/homekit/manifest.json @@ -3,7 +3,7 @@ "name": "HomeKit", "documentation": "https://www.home-assistant.io/integrations/homekit", "requirements": [ - "HAP-python==4.0.0", + "HAP-python==4.1.0", "fnvhash==0.1.0", "PyQRCode==1.2.1", "base36==0.1.1" diff --git a/requirements_all.txt b/requirements_all.txt index e79382fef33..1163c6f5a5d 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -14,7 +14,7 @@ Adafruit-SHT31==1.0.2 # Adafruit_BBIO==1.1.1 # homeassistant.components.homekit -HAP-python==4.0.0 +HAP-python==4.1.0 # homeassistant.components.mastodon Mastodon.py==1.5.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 9704fdc168a..a32c0fad370 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -7,7 +7,7 @@ AEMET-OpenData==0.2.1 # homeassistant.components.homekit -HAP-python==4.0.0 +HAP-python==4.1.0 # homeassistant.components.flick_electric PyFlick==0.0.2 diff --git a/tests/components/homekit/test_accessories.py b/tests/components/homekit/test_accessories.py index 975864b42d5..3f08ca6fda2 100644 --- a/tests/components/homekit/test_accessories.py +++ b/tests/components/homekit/test_accessories.py @@ -696,9 +696,9 @@ def test_home_driver(): with patch("pyhap.accessory_driver.AccessoryDriver.pair") as mock_pair, patch( "homeassistant.components.homekit.accessories.dismiss_setup_message" ) as mock_dissmiss_msg: - driver.pair("client_uuid", "client_public") + driver.pair("client_uuid", "client_public", b"1") - mock_pair.assert_called_with("client_uuid", "client_public") + mock_pair.assert_called_with("client_uuid", "client_public", b"1") mock_dissmiss_msg.assert_called_with("hass", "entry_id") # unpair diff --git a/tests/components/homekit/test_homekit.py b/tests/components/homekit/test_homekit.py index 138c8fd8209..17c03ba1dcd 100644 --- a/tests/components/homekit/test_homekit.py +++ b/tests/components/homekit/test_homekit.py @@ -560,7 +560,7 @@ async def test_homekit_start(hass, hk_driver, mock_zeroconf, device_reg): assert (device_registry.CONNECTION_NETWORK_MAC, formatted_mac) in device.connections assert len(device_reg.devices) == 1 - assert homekit.driver.state.config_version == 2 + assert homekit.driver.state.config_version == 1 async def test_homekit_start_with_a_broken_accessory(hass, hk_driver, mock_zeroconf): @@ -695,7 +695,7 @@ async def test_homekit_unpair(hass, device_reg, mock_zeroconf): homekit.status = STATUS_RUNNING state = homekit.driver.state - state.paired_clients = {"client1": "any"} + state.add_paired_client("client1", "any", b"1") formatted_mac = device_registry.format_mac(state.mac) hk_bridge_dev = device_reg.async_get_device( {}, {(device_registry.CONNECTION_NETWORK_MAC, formatted_mac)} @@ -734,7 +734,7 @@ async def test_homekit_unpair_missing_device_id(hass, device_reg, mock_zeroconf) homekit.status = STATUS_RUNNING state = homekit.driver.state - state.paired_clients = {"client1": "any"} + state.add_paired_client("client1", "any", b"1") with pytest.raises(HomeAssistantError): await hass.services.async_call( DOMAIN, @@ -780,7 +780,7 @@ async def test_homekit_unpair_not_homekit_device(hass, device_reg, mock_zeroconf ) state = homekit.driver.state - state.paired_clients = {"client1": "any"} + state.add_paired_client("client1", "any", b"1") with pytest.raises(HomeAssistantError): await hass.services.async_call( DOMAIN,