Use ZeroconfServiceInfo in modern_forms (#60043)

This commit is contained in:
epenet 2021-11-21 17:37:09 +01:00 committed by GitHub
parent 95075448bd
commit 2270e920c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 11 deletions

View file

@ -30,14 +30,14 @@ class ModernFormsFlowHandler(ConfigFlow, domain=DOMAIN):
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
"""Handle zeroconf discovery."""
host = discovery_info["hostname"].rstrip(".")
host = discovery_info[zeroconf.ATTR_HOSTNAME].rstrip(".")
name, _ = host.rsplit(".")
self.context.update(
{
CONF_HOST: discovery_info["host"],
CONF_HOST: discovery_info[zeroconf.ATTR_HOST],
CONF_NAME: name,
CONF_MAC: discovery_info["properties"].get(CONF_MAC),
CONF_MAC: discovery_info[zeroconf.ATTR_PROPERTIES].get(CONF_MAC),
"title_placeholders": {"name": name},
}
)