Use ZeroconfServiceInfo in nam (#60044)

This commit is contained in:
epenet 2021-11-21 10:25:34 +01:00 committed by GitHub
parent f606ba3b23
commit ba93a384a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -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

View File

@ -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"}