mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Better parsing of the ZHA device profile id (#41024)
This commit is contained in:
parent
aba3cdc7b3
commit
f1f23c0453
@ -9,7 +9,7 @@ from typing import Any, Dict
|
|||||||
|
|
||||||
from zigpy import types
|
from zigpy import types
|
||||||
import zigpy.exceptions
|
import zigpy.exceptions
|
||||||
from zigpy.profiles import zha, zll
|
from zigpy.profiles import PROFILES
|
||||||
import zigpy.quirks
|
import zigpy.quirks
|
||||||
from zigpy.zcl.clusters.general import Groups
|
from zigpy.zcl.clusters.general import Groups
|
||||||
import zigpy.zdo.types as zdo_types
|
import zigpy.zdo.types as zdo_types
|
||||||
@ -456,27 +456,20 @@ class ZHADevice(LogMixin):
|
|||||||
]
|
]
|
||||||
|
|
||||||
# Return endpoint device type Names
|
# Return endpoint device type Names
|
||||||
try:
|
names = []
|
||||||
device_info[ATTR_ENDPOINT_NAMES] = [
|
for endpoint in (ep for epid, ep in self.device.endpoints.items() if epid):
|
||||||
{
|
profile = PROFILES.get(endpoint.profile_id)
|
||||||
"name": endpoint.device_type.name,
|
if profile and endpoint.device_type is not None:
|
||||||
}
|
# DeviceType provides undefined enums
|
||||||
for (ep_id, endpoint) in self._zigpy_device.endpoints.items()
|
names.append({ATTR_NAME: profile.DeviceType(endpoint.device_type).name})
|
||||||
if ep_id != 0
|
else:
|
||||||
and endpoint.profile_id in (zha.PROFILE_ID, zll.PROFILE_ID)
|
names.append(
|
||||||
]
|
{
|
||||||
except AttributeError as ex:
|
ATTR_NAME: f"unknown {endpoint.device_type} device_type "
|
||||||
# Some device types are not using an enumeration
|
"of 0x{endpoint.profile_id:04x} profile id"
|
||||||
self.warning(
|
}
|
||||||
"Failed to identify endpoint name in '%s' with exception '%s'",
|
)
|
||||||
self._zigpy_device.endpoints.items(),
|
device_info[ATTR_ENDPOINT_NAMES] = names
|
||||||
ex,
|
|
||||||
)
|
|
||||||
device_info[ATTR_ENDPOINT_NAMES] = [
|
|
||||||
{
|
|
||||||
"name": "unknown",
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
reg_device = self.gateway.ha_device_registry.async_get(self.device_id)
|
reg_device = self.gateway.ha_device_registry.async_get(self.device_id)
|
||||||
if reg_device is not None:
|
if reg_device is not None:
|
||||||
@ -516,7 +509,7 @@ class ZHADevice(LogMixin):
|
|||||||
CLUSTER_TYPE_OUT: endpoint.out_clusters,
|
CLUSTER_TYPE_OUT: endpoint.out_clusters,
|
||||||
}
|
}
|
||||||
for (ep_id, endpoint) in self._zigpy_device.endpoints.items()
|
for (ep_id, endpoint) in self._zigpy_device.endpoints.items()
|
||||||
if ep_id != 0 and endpoint.profile_id in (zha.PROFILE_ID, zll.PROFILE_ID)
|
if ep_id != 0 and endpoint.profile_id in PROFILES
|
||||||
}
|
}
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
Loading…
x
Reference in New Issue
Block a user