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
2 changed files with 20 additions and 2 deletions
|
@ -162,6 +162,14 @@ class Router:
|
|||
pass
|
||||
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
|
||||
def device_connections(self) -> Set[Tuple[str, str]]:
|
||||
"""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(
|
||||
config_entry_id=config_entry.entry_id,
|
||||
connections=router.device_connections,
|
||||
identifiers=router.device_identifiers,
|
||||
name=router.device_name,
|
||||
manufacturer="Huawei",
|
||||
**device_data,
|
||||
|
@ -594,7 +603,10 @@ class HuaweiLteBaseEntity(Entity):
|
|||
@property
|
||||
def device_info(self) -> Dict[str, Any]:
|
||||
"""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:
|
||||
"""Update state."""
|
||||
|
|
|
@ -53,4 +53,10 @@ SENSOR_KEYS = {
|
|||
|
||||
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…
Add table
Reference in a new issue