diff --git a/homeassistant/components/lookin/config_flow.py b/homeassistant/components/lookin/config_flow.py index e41aad0406b..af42febbb3f 100644 --- a/homeassistant/components/lookin/config_flow.py +++ b/homeassistant/components/lookin/config_flow.py @@ -31,8 +31,8 @@ class LookinFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): self, discovery_info: zeroconf.ZeroconfServiceInfo ) -> FlowResult: """Start a discovery flow from zeroconf.""" - uid: str = discovery_info["hostname"][: -len(".local.")] - host: str = discovery_info["host"] + uid: str = discovery_info[zeroconf.ATTR_HOSTNAME][: -len(".local.")] + host: str = discovery_info[zeroconf.ATTR_HOST] await self.async_set_unique_id(uid.upper()) self._abort_if_unique_id_configured(updates={CONF_HOST: host}) diff --git a/tests/components/lookin/__init__.py b/tests/components/lookin/__init__.py index c55b5228b47..911e984a57e 100644 --- a/tests/components/lookin/__init__.py +++ b/tests/components/lookin/__init__.py @@ -17,14 +17,14 @@ DEFAULT_ENTRY_TITLE = DEVICE_NAME ZC_NAME = f"LOOKin_{DEVICE_ID}" ZC_TYPE = "_lookin._tcp." -ZEROCONF_DATA: ZeroconfServiceInfo = { - "host": IP_ADDRESS, - "hostname": f"{ZC_NAME.lower()}.local.", - "port": 80, - "type": ZC_TYPE, - "name": ZC_NAME, - "properties": {}, -} +ZEROCONF_DATA = ZeroconfServiceInfo( + host=IP_ADDRESS, + hostname=f"{ZC_NAME.lower()}.local.", + port=80, + type=ZC_TYPE, + name=ZC_NAME, + properties={}, +) def _mocked_climate() -> Climate: diff --git a/tests/components/lookin/test_config_flow.py b/tests/components/lookin/test_config_flow.py index 92f6e500045..2050e80392d 100644 --- a/tests/components/lookin/test_config_flow.py +++ b/tests/components/lookin/test_config_flow.py @@ -6,6 +6,7 @@ from unittest.mock import patch from aiolookin import NoUsableService from homeassistant import config_entries +from homeassistant.components import zeroconf from homeassistant.components.lookin.const import DOMAIN from homeassistant.const import CONF_HOST from homeassistant.core import HomeAssistant @@ -138,7 +139,7 @@ async def test_discovered_zeroconf(hass): entry = hass.config_entries.async_entries(DOMAIN)[0] zc_data_new_ip = ZEROCONF_DATA.copy() - zc_data_new_ip["host"] = "127.0.0.2" + zc_data_new_ip[zeroconf.ATTR_HOST] = "127.0.0.2" with _patch_get_info(), patch( f"{MODULE}.async_setup_entry", return_value=True