diff --git a/homeassistant/components/elgato/config_flow.py b/homeassistant/components/elgato/config_flow.py index 7a4eb7a7519..327aeead4dc 100644 --- a/homeassistant/components/elgato/config_flow.py +++ b/homeassistant/components/elgato/config_flow.py @@ -46,8 +46,8 @@ class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN): self, discovery_info: zeroconf.ZeroconfServiceInfo ) -> FlowResult: """Handle zeroconf discovery.""" - self.host = discovery_info[CONF_HOST] - self.port = discovery_info[CONF_PORT] or 9123 + self.host = discovery_info[zeroconf.ATTR_HOST] + self.port = discovery_info[zeroconf.ATTR_PORT] or 9123 try: await self._get_elgato_serial_number() diff --git a/tests/components/elgato/test_config_flow.py b/tests/components/elgato/test_config_flow.py index 49c85c5f2a2..5a7487b5995 100644 --- a/tests/components/elgato/test_config_flow.py +++ b/tests/components/elgato/test_config_flow.py @@ -2,6 +2,7 @@ import aiohttp from homeassistant import data_entry_flow +from homeassistant.components import zeroconf from homeassistant.components.elgato.const import CONF_SERIAL_NUMBER, DOMAIN from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF from homeassistant.const import CONF_HOST, CONF_PORT, CONF_SOURCE, CONTENT_TYPE_JSON @@ -27,12 +28,12 @@ async def test_full_user_flow_implementation( await hass.config_entries.flow.async_init( DOMAIN, context={CONF_SOURCE: SOURCE_ZEROCONF}, - data={ - "host": "127.0.0.1", - "hostname": "example.local.", - "port": 9123, - "properties": {}, - }, + data=zeroconf.ZeroconfServiceInfo( + host="127.0.0.1", + hostname="example.local.", + port=9123, + properties={}, + ), ) result = await hass.config_entries.flow.async_init( @@ -70,12 +71,12 @@ async def test_full_zeroconf_flow_implementation( result = await hass.config_entries.flow.async_init( DOMAIN, context={CONF_SOURCE: SOURCE_ZEROCONF}, - data={ - "host": "127.0.0.1", - "hostname": "example.local.", - "port": 9123, - "properties": {}, - }, + data=zeroconf.ZeroconfServiceInfo( + host="127.0.0.1", + hostname="example.local.", + port=9123, + properties={}, + ), ) assert result["description_placeholders"] == {CONF_SERIAL_NUMBER: "CN11A1A00001"} @@ -127,7 +128,7 @@ async def test_zeroconf_connection_error( result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_ZEROCONF}, - data={"host": "127.0.0.1", "port": 9123}, + data=zeroconf.ZeroconfServiceInfo(host="127.0.0.1", port=9123), ) assert result["reason"] == "cannot_connect" @@ -158,7 +159,7 @@ async def test_zeroconf_device_exists_abort( result = await hass.config_entries.flow.async_init( DOMAIN, context={CONF_SOURCE: SOURCE_ZEROCONF}, - data={"host": "127.0.0.1", "port": 9123}, + data=zeroconf.ZeroconfServiceInfo(host="127.0.0.1", port=9123), ) assert result["reason"] == "already_configured" @@ -167,7 +168,7 @@ async def test_zeroconf_device_exists_abort( result = await hass.config_entries.flow.async_init( DOMAIN, context={CONF_SOURCE: SOURCE_ZEROCONF}, - data={"host": "127.0.0.2", "port": 9123}, + data=zeroconf.ZeroconfServiceInfo(host="127.0.0.2", port=9123), ) assert result["reason"] == "already_configured"