Use dataclass properties in keenetic_ndms2 discovery (#60716)

Co-authored-by: epenet <epenet@users.noreply.github.com>
pull/60595/head
epenet 2021-12-01 13:59:34 +01:00 committed by GitHub
parent 2a1f0cadaa
commit c7c2b810a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -20,7 +20,7 @@ from homeassistant.const import (
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from homeassistant.helpers.typing import ConfigType
from .const import (
CONF_CONSIDER_HOME,
@ -104,20 +104,20 @@ class KeeneticFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
"""Import a config entry."""
return await self.async_step_user(user_input)
async def async_step_ssdp(self, discovery_info: DiscoveryInfoType) -> FlowResult:
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
"""Handle a discovered device."""
friendly_name = discovery_info.get(ssdp.ATTR_UPNP_FRIENDLY_NAME, "")
friendly_name = discovery_info.upnp.get(ssdp.ATTR_UPNP_FRIENDLY_NAME, "")
# Filter out items not having "keenetic" in their name
if "keenetic" not in friendly_name.lower():
return self.async_abort(reason="not_keenetic_ndms2")
# Filters out items having no/empty UDN
if not discovery_info.get(ssdp.ATTR_UPNP_UDN):
if not discovery_info.upnp.get(ssdp.ATTR_UPNP_UDN):
return self.async_abort(reason="no_udn")
host = urlparse(discovery_info[ssdp.ATTR_SSDP_LOCATION]).hostname
await self.async_set_unique_id(discovery_info[ssdp.ATTR_UPNP_UDN])
host = urlparse(discovery_info.ssdp_location).hostname
await self.async_set_unique_id(discovery_info.upnp[ssdp.ATTR_UPNP_UDN])
self._abort_if_unique_id_configured(updates={CONF_HOST: host})
self._async_abort_entries_match({CONF_HOST: host})