diff --git a/homeassistant/components/homekit/__init__.py b/homeassistant/components/homekit/__init__.py index 32b528f567c..3f297892446 100644 --- a/homeassistant/components/homekit/__init__.py +++ b/homeassistant/components/homekit/__init__.py @@ -456,7 +456,7 @@ class HomeKit: self.bridge = None self.driver = None - def setup(self, zeroconf_instance): + def setup(self, async_zeroconf_instance): """Set up bridge and accessory driver.""" ip_addr = self._ip_address or get_local_ip() persist_file = get_persist_fullpath_for_entry_id(self.hass, self._entry_id) @@ -471,7 +471,7 @@ class HomeKit: port=self._port, persist_file=persist_file, advertised_address=self._advertise_ip, - zeroconf_instance=zeroconf_instance, + async_zeroconf_instance=async_zeroconf_instance, ) # If we do not load the mac address will be wrong @@ -595,8 +595,8 @@ class HomeKit: if self.status != STATUS_READY: return self.status = STATUS_WAIT - zc_instance = await zeroconf.async_get_instance(self.hass) - await self.hass.async_add_executor_job(self.setup, zc_instance) + async_zc_instance = await zeroconf.async_get_async_instance(self.hass) + await self.hass.async_add_executor_job(self.setup, async_zc_instance) self.aid_storage = AccessoryAidStorage(self.hass, self._entry_id) await self.aid_storage.async_initialize() await self._async_create_accessories() diff --git a/homeassistant/components/homekit/manifest.json b/homeassistant/components/homekit/manifest.json index 483279d55f3..d2c2f094a0f 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==3.4.1", + "HAP-python==3.5.0", "fnvhash==0.1.0", "PyQRCode==1.2.1", "base36==0.1.1", diff --git a/requirements_all.txt b/requirements_all.txt index e6c1045a8f3..d6d871d3126 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==3.4.1 +HAP-python==3.5.0 # homeassistant.components.mastodon Mastodon.py==1.5.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 3acf168d339..9961342391d 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==3.4.1 +HAP-python==3.5.0 # homeassistant.components.flick_electric PyFlick==0.0.2 diff --git a/tests/components/homekit/conftest.py b/tests/components/homekit/conftest.py index 469a0a7deb7..5441bcc195c 100644 --- a/tests/components/homekit/conftest.py +++ b/tests/components/homekit/conftest.py @@ -12,7 +12,7 @@ from tests.common import async_capture_events @pytest.fixture def hk_driver(loop): """Return a custom AccessoryDriver instance for HomeKit accessory init.""" - with patch("pyhap.accessory_driver.Zeroconf"), patch( + with patch("pyhap.accessory_driver.AsyncZeroconf"), patch( "pyhap.accessory_driver.AccessoryEncoder" ), patch("pyhap.accessory_driver.HAPServer.async_stop"), patch( "pyhap.accessory_driver.HAPServer.async_start" diff --git a/tests/components/homekit/test_homekit.py b/tests/components/homekit/test_homekit.py index fd7d74aeaba..bd7af3b3596 100644 --- a/tests/components/homekit/test_homekit.py +++ b/tests/components/homekit/test_homekit.py @@ -250,7 +250,7 @@ async def test_homekit_setup(hass, hk_driver, mock_zeroconf): port=DEFAULT_PORT, persist_file=path, advertised_address=None, - zeroconf_instance=zeroconf_mock, + async_zeroconf_instance=zeroconf_mock, ) assert homekit.driver.safe_mode is False @@ -290,7 +290,7 @@ async def test_homekit_setup_ip_address(hass, hk_driver, mock_zeroconf): port=DEFAULT_PORT, persist_file=path, advertised_address=None, - zeroconf_instance=mock_zeroconf, + async_zeroconf_instance=mock_zeroconf, ) @@ -315,10 +315,10 @@ async def test_homekit_setup_advertise_ip(hass, hk_driver, mock_zeroconf): entry_title=entry.title, ) - zeroconf_instance = MagicMock() + async_zeroconf_instance = MagicMock() path = get_persist_fullpath_for_entry_id(hass, entry.entry_id) with patch(f"{PATH_HOMEKIT}.HomeDriver", return_value=hk_driver) as mock_driver: - await hass.async_add_executor_job(homekit.setup, zeroconf_instance) + await hass.async_add_executor_job(homekit.setup, async_zeroconf_instance) mock_driver.assert_called_with( hass, entry.entry_id, @@ -329,7 +329,7 @@ async def test_homekit_setup_advertise_ip(hass, hk_driver, mock_zeroconf): port=DEFAULT_PORT, persist_file=path, advertised_address="192.168.1.100", - zeroconf_instance=zeroconf_instance, + async_zeroconf_instance=async_zeroconf_instance, ) @@ -851,7 +851,7 @@ async def test_homekit_uses_system_zeroconf(hass, hk_driver, mock_zeroconf): options={}, ) assert await async_setup_component(hass, "zeroconf", {"zeroconf": {}}) - system_zc = await zeroconf.async_get_instance(hass) + system_async_zc = await zeroconf.async_get_async_instance(hass) with patch("pyhap.accessory_driver.AccessoryDriver.async_start"), patch( f"{PATH_HOMEKIT}.HomeKit.async_stop" @@ -859,7 +859,10 @@ async def test_homekit_uses_system_zeroconf(hass, hk_driver, mock_zeroconf): entry.add_to_hass(hass) assert await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert hass.data[DOMAIN][entry.entry_id][HOMEKIT].driver.advertiser == system_zc + assert ( + hass.data[DOMAIN][entry.entry_id][HOMEKIT].driver.advertiser + == system_async_zc + ) assert await hass.config_entries.async_unload(entry.entry_id) await hass.async_block_till_done() diff --git a/tests/components/homekit/test_type_cameras.py b/tests/components/homekit/test_type_cameras.py index ba08ea3caaf..354db900470 100644 --- a/tests/components/homekit/test_type_cameras.py +++ b/tests/components/homekit/test_type_cameras.py @@ -80,7 +80,7 @@ async def _async_stop_stream(hass, acc, session_info): @pytest.fixture() def run_driver(hass): """Return a custom AccessoryDriver instance for HomeKit accessory init.""" - with patch("pyhap.accessory_driver.Zeroconf"), patch( + with patch("pyhap.accessory_driver.AsyncZeroconf"), patch( "pyhap.accessory_driver.AccessoryEncoder" ), patch("pyhap.accessory_driver.HAPServer"), patch( "pyhap.accessory_driver.AccessoryDriver.publish"