Use dataclass properties in netgear discovery (#60730)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-12-01 14:38:17 +01:00 committed by GitHub
parent 16942fc8e9
commit 59f87b9488
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -123,11 +123,11 @@ class NetgearFlowHandler(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: dict) -> FlowResult:
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
"""Initialize flow from ssdp."""
updated_data = {}
device_url = urlparse(discovery_info[ssdp.ATTR_SSDP_LOCATION])
device_url = urlparse(discovery_info.ssdp_location)
if device_url.hostname:
updated_data[CONF_HOST] = device_url.hostname
if device_url.scheme == "https":
@ -137,14 +137,16 @@ class NetgearFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
_LOGGER.debug("Netgear ssdp discovery info: %s", discovery_info)
await self.async_set_unique_id(discovery_info[ssdp.ATTR_UPNP_SERIAL])
await self.async_set_unique_id(discovery_info.upnp[ssdp.ATTR_UPNP_SERIAL])
self._abort_if_unique_id_configured(updates=updated_data)
updated_data[CONF_PORT] = DEFAULT_PORT
for model in MODELS_V2:
if discovery_info.get(ssdp.ATTR_UPNP_MODEL_NUMBER, "").startswith(
if discovery_info.upnp.get(ssdp.ATTR_UPNP_MODEL_NUMBER, "").startswith(
model
) or discovery_info.get(ssdp.ATTR_UPNP_MODEL_NAME, "").startswith(model):
) or discovery_info.upnp.get(ssdp.ATTR_UPNP_MODEL_NAME, "").startswith(
model
):
updated_data[CONF_PORT] = ORBI_PORT
self.placeholders.update(updated_data)