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 d6573ea8936..042a7d04d15 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -26,7 +26,7 @@ CO2Signal==0.4.2 DoorBirdPy==2.1.0 # homeassistant.components.homekit -HAP-python==4.6.0 +HAP-python==4.7.0 # homeassistant.components.tasmota HATasmota==0.6.5 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 23885e2c5e3..0bfbeb8024c 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -25,7 +25,7 @@ CO2Signal==0.4.2 DoorBirdPy==2.1.0 # homeassistant.components.homekit -HAP-python==4.6.0 +HAP-python==4.7.0 # homeassistant.components.tasmota HATasmota==0.6.5 diff --git a/tests/components/homekit/test_homekit.py b/tests/components/homekit/test_homekit.py index 690bb7fef37..fb1191b59de 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