Use dataclass properties in modern_forms discovery (#60584)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-11-30 10:18:25 +01:00 committed by GitHub
parent efebd1b657
commit 7182827818
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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