diff --git a/homeassistant/components/nam/config_flow.py b/homeassistant/components/nam/config_flow.py index 0e98e4f7ef5..00df0e0bf90 100644 --- a/homeassistant/components/nam/config_flow.py +++ b/homeassistant/components/nam/config_flow.py @@ -126,7 +126,7 @@ class NAMFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): self, discovery_info: zeroconf.ZeroconfServiceInfo ) -> FlowResult: """Handle zeroconf discovery.""" - self.host = discovery_info[CONF_HOST] + self.host = discovery_info[zeroconf.ATTR_HOST] self.context["title_placeholders"] = {"host": self.host} # Do not probe the device if the host is already configured diff --git a/tests/components/nam/test_config_flow.py b/tests/components/nam/test_config_flow.py index 3dbbe416831..5a3e46cedb9 100644 --- a/tests/components/nam/test_config_flow.py +++ b/tests/components/nam/test_config_flow.py @@ -6,12 +6,13 @@ from nettigo_air_monitor import ApiError, AuthFailed, CannotGetMac import pytest from homeassistant import data_entry_flow +from homeassistant.components import zeroconf from homeassistant.components.nam.const import DOMAIN from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER, SOURCE_ZEROCONF from tests.common import MockConfigEntry -DISCOVERY_INFO = {"host": "10.10.2.3"} +DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo(host="10.10.2.3") VALID_CONFIG = {"host": "10.10.2.3"} VALID_AUTH = {"username": "fake_username", "password": "fake_password"}