mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 13:57:10 +00:00
Netgear fix port and device model beeing overwritten (#57277)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
4dafd42154
commit
830e2bc47a
@ -1,4 +1,5 @@
|
|||||||
"""Config flow to configure the Netgear integration."""
|
"""Config flow to configure the Netgear integration."""
|
||||||
|
import logging
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from pynetgear import DEFAULT_HOST, DEFAULT_PORT, DEFAULT_USER
|
from pynetgear import DEFAULT_HOST, DEFAULT_PORT, DEFAULT_USER
|
||||||
@ -20,6 +21,8 @@ from .const import CONF_CONSIDER_HOME, DEFAULT_CONSIDER_HOME, DEFAULT_NAME, DOMA
|
|||||||
from .errors import CannotLoginException
|
from .errors import CannotLoginException
|
||||||
from .router import get_api
|
from .router import get_api
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def _discovery_schema_with_defaults(discovery_info):
|
def _discovery_schema_with_defaults(discovery_info):
|
||||||
return vol.Schema(_ordered_shared_schema(discovery_info))
|
return vol.Schema(_ordered_shared_schema(discovery_info))
|
||||||
@ -120,15 +123,19 @@ class NetgearFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
device_url = urlparse(discovery_info[ssdp.ATTR_SSDP_LOCATION])
|
device_url = urlparse(discovery_info[ssdp.ATTR_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.port:
|
|
||||||
updated_data[CONF_PORT] = device_url.port
|
|
||||||
if device_url.scheme == "https":
|
if device_url.scheme == "https":
|
||||||
updated_data[CONF_SSL] = True
|
updated_data[CONF_SSL] = True
|
||||||
else:
|
else:
|
||||||
updated_data[CONF_SSL] = False
|
updated_data[CONF_SSL] = False
|
||||||
|
|
||||||
|
_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[ssdp.ATTR_UPNP_SERIAL])
|
||||||
self._abort_if_unique_id_configured(updates=updated_data)
|
self._abort_if_unique_id_configured(updates=updated_data)
|
||||||
|
|
||||||
|
if device_url.port:
|
||||||
|
updated_data[CONF_PORT] = device_url.port
|
||||||
|
|
||||||
self.placeholders.update(updated_data)
|
self.placeholders.update(updated_data)
|
||||||
self.discovered = True
|
self.discovered = True
|
||||||
|
|
||||||
|
@ -274,8 +274,8 @@ class NetgearDeviceEntity(Entity):
|
|||||||
"""Return the device information."""
|
"""Return the device information."""
|
||||||
return {
|
return {
|
||||||
"connections": {(CONNECTION_NETWORK_MAC, self._mac)},
|
"connections": {(CONNECTION_NETWORK_MAC, self._mac)},
|
||||||
"name": self._device_name,
|
"default_name": self._device_name,
|
||||||
"model": self._device["device_model"],
|
"default_model": self._device["device_model"],
|
||||||
"via_device": (DOMAIN, self._router.unique_id),
|
"via_device": (DOMAIN, self._router.unique_id),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user