mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Use dataclass properties in netgear discovery (#60730)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
16942fc8e9
commit
59f87b9488
@ -123,11 +123,11 @@ class NetgearFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
"""Import a config entry."""
|
"""Import a config entry."""
|
||||||
return await self.async_step_user(user_input)
|
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."""
|
"""Initialize flow from ssdp."""
|
||||||
updated_data = {}
|
updated_data = {}
|
||||||
|
|
||||||
device_url = urlparse(discovery_info[ssdp.ATTR_SSDP_LOCATION])
|
device_url = urlparse(discovery_info.ssdp_location)
|
||||||
if device_url.hostname:
|
if device_url.hostname:
|
||||||
updated_data[CONF_HOST] = device_url.hostname
|
updated_data[CONF_HOST] = device_url.hostname
|
||||||
if device_url.scheme == "https":
|
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)
|
_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)
|
self._abort_if_unique_id_configured(updates=updated_data)
|
||||||
|
|
||||||
updated_data[CONF_PORT] = DEFAULT_PORT
|
updated_data[CONF_PORT] = DEFAULT_PORT
|
||||||
for model in MODELS_V2:
|
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
|
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
|
updated_data[CONF_PORT] = ORBI_PORT
|
||||||
|
|
||||||
self.placeholders.update(updated_data)
|
self.placeholders.update(updated_data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user