mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Huawei LTE device registry improvements (#38925)
* Fix getting software version in unauthenticated mode * Add serial number device identifier if available
This commit is contained in:
parent
decf3d320b
commit
3c0f766933
@ -162,6 +162,14 @@ class Router:
|
|||||||
pass
|
pass
|
||||||
return DEFAULT_DEVICE_NAME
|
return DEFAULT_DEVICE_NAME
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_identifiers(self) -> Set[Tuple[str, str]]:
|
||||||
|
"""Get router identifiers for device registry."""
|
||||||
|
try:
|
||||||
|
return {(DOMAIN, self.data[KEY_DEVICE_INFORMATION]["SerialNumber"])}
|
||||||
|
except (KeyError, TypeError):
|
||||||
|
return set()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_connections(self) -> Set[Tuple[str, str]]:
|
def device_connections(self) -> Set[Tuple[str, str]]:
|
||||||
"""Get router connections for device registry."""
|
"""Get router connections for device registry."""
|
||||||
@ -390,6 +398,7 @@ async def async_setup_entry(hass: HomeAssistantType, config_entry: ConfigEntry)
|
|||||||
device_registry.async_get_or_create(
|
device_registry.async_get_or_create(
|
||||||
config_entry_id=config_entry.entry_id,
|
config_entry_id=config_entry.entry_id,
|
||||||
connections=router.device_connections,
|
connections=router.device_connections,
|
||||||
|
identifiers=router.device_identifiers,
|
||||||
name=router.device_name,
|
name=router.device_name,
|
||||||
manufacturer="Huawei",
|
manufacturer="Huawei",
|
||||||
**device_data,
|
**device_data,
|
||||||
@ -594,7 +603,10 @@ class HuaweiLteBaseEntity(Entity):
|
|||||||
@property
|
@property
|
||||||
def device_info(self) -> Dict[str, Any]:
|
def device_info(self) -> Dict[str, Any]:
|
||||||
"""Get info for matching with parent router."""
|
"""Get info for matching with parent router."""
|
||||||
return {"connections": self.router.device_connections}
|
return {
|
||||||
|
"identifiers": self.router.device_identifiers,
|
||||||
|
"connections": self.router.device_connections,
|
||||||
|
}
|
||||||
|
|
||||||
async def async_update(self) -> None:
|
async def async_update(self) -> None:
|
||||||
"""Update state."""
|
"""Update state."""
|
||||||
|
@ -53,4 +53,10 @@ SENSOR_KEYS = {
|
|||||||
|
|
||||||
SWITCH_KEYS = {KEY_DIALUP_MOBILE_DATASWITCH}
|
SWITCH_KEYS = {KEY_DIALUP_MOBILE_DATASWITCH}
|
||||||
|
|
||||||
ALL_KEYS = BINARY_SENSOR_KEYS | DEVICE_TRACKER_KEYS | SENSOR_KEYS | SWITCH_KEYS
|
ALL_KEYS = (
|
||||||
|
BINARY_SENSOR_KEYS
|
||||||
|
| DEVICE_TRACKER_KEYS
|
||||||
|
| SENSOR_KEYS
|
||||||
|
| SWITCH_KEYS
|
||||||
|
| {KEY_DEVICE_BASIC_INFORMATION}
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user