diff --git a/homeassistant/components/gogogate2/config_flow.py b/homeassistant/components/gogogate2/config_flow.py index 3695703b509..d3df62c3b6e 100644 --- a/homeassistant/components/gogogate2/config_flow.py +++ b/homeassistant/components/gogogate2/config_flow.py @@ -7,8 +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.components import dhcp, zeroconf from homeassistant.config_entries import ConfigFlow from homeassistant.const import ( CONF_DEVICE, @@ -43,10 +42,12 @@ class Gogogate2FlowHandler(ConfigFlow, domain=DOMAIN): 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): + async def async_step_dhcp( + self, discovery_info: dhcp.DhcpServiceInfo + ) -> data_entry_flow.FlowResult: """Handle dhcp discovery.""" - await self.async_set_unique_id(discovery_info[MAC_ADDRESS]) - return await self._async_discovery_handler(discovery_info[IP_ADDRESS]) + await self.async_set_unique_id(discovery_info[dhcp.MAC_ADDRESS]) + return await self._async_discovery_handler(discovery_info[dhcp.IP_ADDRESS]) async def _async_discovery_handler(self, ip_address): """Start the user flow from any discovery.""" diff --git a/tests/components/gogogate2/test_config_flow.py b/tests/components/gogogate2/test_config_flow.py index 74997e827aa..202e7840456 100644 --- a/tests/components/gogogate2/test_config_flow.py +++ b/tests/components/gogogate2/test_config_flow.py @@ -6,7 +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 import dhcp, zeroconf from homeassistant.components.gogogate2.const import ( DEVICE_TYPE_GOGOGATE2, DEVICE_TYPE_ISMARTGATE, @@ -191,7 +191,7 @@ async def test_discovered_dhcp( result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_DHCP}, - data={"ip": "1.2.3.4", "macaddress": MOCK_MAC_ADDR}, + data=dhcp.DhcpServiceInfo(ip="1.2.3.4", macaddress=MOCK_MAC_ADDR), ) assert result["type"] == RESULT_TYPE_FORM assert result["errors"] == {} @@ -246,7 +246,7 @@ async def test_discovered_by_homekit_and_dhcp(hass): result2 = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_DHCP}, - data={"ip": "1.2.3.4", "macaddress": MOCK_MAC_ADDR}, + data=dhcp.DhcpServiceInfo(ip="1.2.3.4", macaddress=MOCK_MAC_ADDR), ) assert result2["type"] == RESULT_TYPE_ABORT assert result2["reason"] == "already_in_progress" @@ -254,7 +254,7 @@ async def test_discovered_by_homekit_and_dhcp(hass): result3 = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_DHCP}, - data={"ip": "1.2.3.4", "macaddress": "00:00:00:00:00:00"}, + data=dhcp.DhcpServiceInfo(ip="1.2.3.4", macaddress="00:00:00:00:00:00"), ) assert result3["type"] == RESULT_TYPE_ABORT assert result3["reason"] == "already_in_progress"