mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Add huawei_lte device registry upnp udn connection (#148370)
This commit is contained in:
parent
b0f7c985e4
commit
ccc80c78a0
@ -57,6 +57,7 @@ from .const import (
|
||||
ATTR_CONFIG_ENTRY_ID,
|
||||
CONF_MANUFACTURER,
|
||||
CONF_UNAUTHENTICATED_MODE,
|
||||
CONF_UPNP_UDN,
|
||||
CONNECTION_TIMEOUT,
|
||||
DEFAULT_DEVICE_NAME,
|
||||
DEFAULT_MANUFACTURER,
|
||||
@ -147,9 +148,12 @@ class Router:
|
||||
@property
|
||||
def device_connections(self) -> set[tuple[str, str]]:
|
||||
"""Get router connections for device registry."""
|
||||
return {
|
||||
connections = {
|
||||
(dr.CONNECTION_NETWORK_MAC, x) for x in self.config_entry.data[CONF_MAC]
|
||||
}
|
||||
if udn := self.config_entry.data.get(CONF_UPNP_UDN):
|
||||
connections.add((dr.CONNECTION_UPNP, udn))
|
||||
return connections
|
||||
|
||||
def _get_data(self, key: str, func: Callable[[], Any]) -> None:
|
||||
if not self.subscriptions.get(key):
|
||||
|
@ -51,6 +51,7 @@ from .const import (
|
||||
CONF_MANUFACTURER,
|
||||
CONF_TRACK_WIRED_CLIENTS,
|
||||
CONF_UNAUTHENTICATED_MODE,
|
||||
CONF_UPNP_UDN,
|
||||
CONNECTION_TIMEOUT,
|
||||
DEFAULT_DEVICE_NAME,
|
||||
DEFAULT_NOTIFY_SERVICE_NAME,
|
||||
@ -69,6 +70,7 @@ class HuaweiLteConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
VERSION = 3
|
||||
|
||||
manufacturer: str | None = None
|
||||
upnp_udn: str | None = None
|
||||
url: str | None = None
|
||||
|
||||
@staticmethod
|
||||
@ -250,6 +252,7 @@ class HuaweiLteConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
{
|
||||
CONF_MAC: get_device_macs(info, wlan_settings),
|
||||
CONF_MANUFACTURER: self.manufacturer,
|
||||
CONF_UPNP_UDN: self.upnp_udn,
|
||||
}
|
||||
)
|
||||
|
||||
@ -284,11 +287,12 @@ class HuaweiLteConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
# url_normalize only returns None if passed None, and we don't do that
|
||||
assert url is not None
|
||||
|
||||
unique_id = discovery_info.upnp.get(
|
||||
ATTR_UPNP_SERIAL, discovery_info.upnp[ATTR_UPNP_UDN]
|
||||
)
|
||||
upnp_udn = discovery_info.upnp.get(ATTR_UPNP_UDN)
|
||||
unique_id = discovery_info.upnp.get(ATTR_UPNP_SERIAL, upnp_udn)
|
||||
await self.async_set_unique_id(unique_id)
|
||||
self._abort_if_unique_id_configured(updates={CONF_URL: url})
|
||||
self._abort_if_unique_id_configured(
|
||||
updates={CONF_UPNP_UDN: upnp_udn, CONF_URL: url}
|
||||
)
|
||||
|
||||
def _is_supported_device() -> bool:
|
||||
"""See if we are looking at a possibly supported device.
|
||||
@ -319,6 +323,7 @@ class HuaweiLteConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
}
|
||||
)
|
||||
self.manufacturer = discovery_info.upnp.get(ATTR_UPNP_MANUFACTURER)
|
||||
self.upnp_udn = upnp_udn
|
||||
self.url = url
|
||||
return await self._async_show_user_form()
|
||||
|
||||
|
@ -7,6 +7,7 @@ ATTR_CONFIG_ENTRY_ID = "config_entry_id"
|
||||
CONF_MANUFACTURER = "manufacturer"
|
||||
CONF_TRACK_WIRED_CLIENTS = "track_wired_clients"
|
||||
CONF_UNAUTHENTICATED_MODE = "unauthenticated_mode"
|
||||
CONF_UPNP_UDN = "upnp_udn"
|
||||
|
||||
DEFAULT_DEVICE_NAME = "LTE"
|
||||
DEFAULT_MANUFACTURER = "Huawei Technologies Co., Ltd."
|
||||
|
@ -13,7 +13,11 @@ import requests_mock
|
||||
from requests_mock import ANY
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.huawei_lte.const import CONF_UNAUTHENTICATED_MODE, DOMAIN
|
||||
from homeassistant.components.huawei_lte.const import (
|
||||
CONF_UNAUTHENTICATED_MODE,
|
||||
CONF_UPNP_UDN,
|
||||
DOMAIN,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
CONF_NAME,
|
||||
CONF_PASSWORD,
|
||||
@ -373,6 +377,7 @@ async def test_ssdp(
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == service_info.upnp[ATTR_UPNP_MODEL_NAME]
|
||||
assert result["result"].data[CONF_UPNP_UDN] == service_info.upnp[ATTR_UPNP_UDN]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
Loading…
x
Reference in New Issue
Block a user