diff --git a/homeassistant/components/gogogate2/config_flow.py b/homeassistant/components/gogogate2/config_flow.py index 6fd61b79795..3695703b509 100644 --- a/homeassistant/components/gogogate2/config_flow.py +++ b/homeassistant/components/gogogate2/config_flow.py @@ -7,6 +7,7 @@ from ismartgate.const import GogoGate2ApiErrorCode, ISmartGateApiErrorCode import voluptuous as vol from homeassistant import data_entry_flow +from homeassistant.components import zeroconf from homeassistant.components.dhcp import IP_ADDRESS, MAC_ADDRESS from homeassistant.config_entries import ConfigFlow from homeassistant.const import ( @@ -35,10 +36,12 @@ class Gogogate2FlowHandler(ConfigFlow, domain=DOMAIN): self._ip_address = None self._device_type = None - async def async_step_homekit(self, discovery_info): + async def async_step_homekit( + self, discovery_info: zeroconf.ZeroconfServiceInfo + ) -> data_entry_flow.FlowResult: """Handle homekit discovery.""" - await self.async_set_unique_id(discovery_info["properties"]["id"]) - return await self._async_discovery_handler(discovery_info["host"]) + await self.async_set_unique_id(discovery_info[zeroconf.ATTR_PROPERTIES]["id"]) + return await self._async_discovery_handler(discovery_info[zeroconf.ATTR_HOST]) async def async_step_dhcp(self, discovery_info): """Handle dhcp discovery.""" diff --git a/tests/components/gogogate2/test_config_flow.py b/tests/components/gogogate2/test_config_flow.py index 18ed7334b8d..74997e827aa 100644 --- a/tests/components/gogogate2/test_config_flow.py +++ b/tests/components/gogogate2/test_config_flow.py @@ -6,6 +6,7 @@ from ismartgate.common import ApiError from ismartgate.const import GogoGate2ApiErrorCode from homeassistant import config_entries +from homeassistant.components import zeroconf from homeassistant.components.gogogate2.const import ( DEVICE_TYPE_GOGOGATE2, DEVICE_TYPE_ISMARTGATE, @@ -106,7 +107,9 @@ async def test_form_homekit_unique_id_already_setup(hass): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_HOMEKIT}, - data={"host": "1.2.3.4", "properties": {"id": MOCK_MAC_ADDR}}, + data=zeroconf.ZeroconfServiceInfo( + host="1.2.3.4", properties={"id": MOCK_MAC_ADDR} + ), ) assert result["type"] == RESULT_TYPE_FORM assert result["errors"] == {} @@ -126,7 +129,9 @@ async def test_form_homekit_unique_id_already_setup(hass): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_HOMEKIT}, - data={"host": "1.2.3.4", "properties": {"id": MOCK_MAC_ADDR}}, + data=zeroconf.ZeroconfServiceInfo( + host="1.2.3.4", properties={"id": MOCK_MAC_ADDR} + ), ) assert result["type"] == RESULT_TYPE_ABORT @@ -143,7 +148,9 @@ async def test_form_homekit_ip_address_already_setup(hass): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_HOMEKIT}, - data={"host": "1.2.3.4", "properties": {"id": MOCK_MAC_ADDR}}, + data=zeroconf.ZeroconfServiceInfo( + host="1.2.3.4", properties={"id": MOCK_MAC_ADDR} + ), ) assert result["type"] == RESULT_TYPE_ABORT @@ -154,7 +161,9 @@ async def test_form_homekit_ip_address(hass): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_HOMEKIT}, - data={"host": "1.2.3.4", "properties": {"id": MOCK_MAC_ADDR}}, + data=zeroconf.ZeroconfServiceInfo( + host="1.2.3.4", properties={"id": MOCK_MAC_ADDR} + ), ) assert result["type"] == RESULT_TYPE_FORM assert result["errors"] == {} @@ -227,7 +236,9 @@ async def test_discovered_by_homekit_and_dhcp(hass): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_HOMEKIT}, - data={"host": "1.2.3.4", "properties": {"id": MOCK_MAC_ADDR}}, + data=zeroconf.ZeroconfServiceInfo( + host="1.2.3.4", properties={"id": MOCK_MAC_ADDR} + ), ) assert result["type"] == RESULT_TYPE_FORM assert result["errors"] == {}