From 99465f53c773ea81d751f4bd4deabf876f9983fe Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 23 Aug 2021 14:00:26 -0500 Subject: [PATCH] Bump HAP-python to 4.1.0 (#55005) --- homeassistant/components/homekit/__init__.py | 6 +----- homeassistant/components/homekit/accessories.py | 4 ++-- homeassistant/components/homekit/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- tests/components/homekit/test_accessories.py | 4 ++-- tests/components/homekit/test_homekit.py | 8 ++++---- 7 files changed, 12 insertions(+), 16 deletions(-) diff --git a/homeassistant/components/homekit/__init__.py b/homeassistant/components/homekit/__init__.py index 705b671f28a129..58f3ab14ca9c74 100644 --- a/homeassistant/components/homekit/__init__.py +++ b/homeassistant/components/homekit/__init__.py @@ -532,11 +532,6 @@ def setup(self, async_zeroconf_instance): # 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 @@ async def async_start(self, *args): 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 ec6ef670f44c61..2cd63facf24656 100644 --- a/homeassistant/components/homekit/accessories.py +++ b/homeassistant/components/homekit/accessories.py @@ -528,9 +528,9 @@ def __init__(self, hass, entry_id, bridge_name, entry_title, **kwargs): 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 c63ce2a89270a4..e40d743068cadb 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 e79382fef33f32..1163c6f5a5d64b 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 9704fdc168a34e..a32c0fad370edc 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 975864b42d5376..3f08ca6fda2f55 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 138c8fd820919b..17c03ba1dcdf42 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,