From e1751647f4a21cabdc7a9327a2248c4e68e7e6d3 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 20 Jun 2023 22:06:26 +0100 Subject: [PATCH] Bump HAP-python to 4.7.0 (#94812) --- .../components/homekit/accessories.py | 4 ++-- .../components/homekit/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- tests/components/homekit/test_homekit.py | 21 +++++++++++-------- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/homekit/accessories.py b/homeassistant/components/homekit/accessories.py index dc8a2a7c639..a2e3f8487c6 100644 --- a/homeassistant/components/homekit/accessories.py +++ b/homeassistant/components/homekit/accessories.py @@ -626,10 +626,10 @@ class HomeDriver(AccessoryDriver): # type: ignore[misc] @pyhap_callback # type: ignore[misc] def pair( - self, client_uuid: UUID, client_public: str, client_permissions: int + self, client_username_bytes: bytes, client_public: str, client_permissions: int ) -> bool: """Override super function to dismiss setup message if paired.""" - success = super().pair(client_uuid, client_public, client_permissions) + success = super().pair(client_username_bytes, client_public, client_permissions) if success: async_dismiss_setup_message(self.hass, self._entry_id) return cast(bool, success) diff --git a/homeassistant/components/homekit/manifest.json b/homeassistant/components/homekit/manifest.json index 746b097e99a..245dbd0a19e 100644 --- a/homeassistant/components/homekit/manifest.json +++ b/homeassistant/components/homekit/manifest.json @@ -9,7 +9,7 @@ "iot_class": "local_push", "loggers": ["pyhap"], "requirements": [ - "HAP-python==4.6.0", + "HAP-python==4.7.0", "fnv-hash-fast==0.3.1", "PyQRCode==1.2.1", "base36==0.1.1" diff --git a/requirements_all.txt b/requirements_all.txt index 49db0fce4be..3ed442f2369 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -11,7 +11,7 @@ AIOAladdinConnect==0.1.56 Adax-local==0.1.5 # homeassistant.components.homekit -HAP-python==4.6.0 +HAP-python==4.7.0 # homeassistant.components.mastodon Mastodon.py==1.5.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 4c5ae788b41..ece221b109c 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -13,7 +13,7 @@ AIOAladdinConnect==0.1.56 Adax-local==0.1.5 # homeassistant.components.homekit -HAP-python==4.6.0 +HAP-python==4.7.0 # homeassistant.components.flick_electric PyFlick==0.0.2 diff --git a/tests/components/homekit/test_homekit.py b/tests/components/homekit/test_homekit.py index 0b74763c6a7..0ffa7893fbd 100644 --- a/tests/components/homekit/test_homekit.py +++ b/tests/components/homekit/test_homekit.py @@ -3,6 +3,7 @@ from __future__ import annotations import asyncio from unittest.mock import ANY, AsyncMock, MagicMock, Mock, patch +from uuid import uuid1 from pyhap.accessory import Accessory from pyhap.const import CATEGORY_CAMERA, CATEGORY_TELEVISION @@ -868,11 +869,11 @@ async def test_homekit_unpair( homekit.driver.aio_stop_event = MagicMock() 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") + state.add_paired_client(str(uuid1()).encode("utf-8"), "any", b"1") + state.add_paired_client(str(uuid1()).encode("utf-8"), "any", b"0") + state.add_paired_client(str(uuid1()).encode("utf-8"), "any", b"1") + state.add_paired_client(str(uuid1()).encode("utf-8"), "any", b"0") + state.add_paired_client(str(uuid1()).encode("utf-8"), "any", b"0") formatted_mac = dr.format_mac(state.mac) hk_bridge_dev = device_registry.async_get_device( @@ -917,7 +918,8 @@ async def test_homekit_unpair_missing_device_id( homekit.driver.aio_stop_event = MagicMock() state = homekit.driver.state - state.add_paired_client("client1", "any", b"1") + client_1 = str(uuid1()).encode("utf-8") + state.add_paired_client(client_1, "any", b"1") with pytest.raises(HomeAssistantError): await hass.services.async_call( DOMAIN, @@ -926,7 +928,7 @@ async def test_homekit_unpair_missing_device_id( blocking=True, ) await hass.async_block_till_done() - state.paired_clients = {"client1": "any"} + state.paired_clients = {client_1.decode("utf-8"): "any"} homekit.status = STATUS_STOPPED @@ -967,7 +969,8 @@ async def test_homekit_unpair_not_homekit_device( ) state = homekit.driver.state - state.add_paired_client("client1", "any", b"1") + client_1 = str(uuid1()).encode("utf-8") + state.add_paired_client(client_1, "any", b"1") with pytest.raises(HomeAssistantError): await hass.services.async_call( DOMAIN, @@ -976,7 +979,7 @@ async def test_homekit_unpair_not_homekit_device( blocking=True, ) await hass.async_block_till_done() - state.paired_clients = {"client1": "any"} + state.paired_clients = {client_1.decode("utf-8"): "any"} homekit.status = STATUS_STOPPED