Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 16 additions & 23 deletions homeassistant/components/zha/core/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from zigpy import types
import zigpy.exceptions
from zigpy.profiles import zha, zll
from zigpy.profiles import PROFILES
import zigpy.quirks
from zigpy.zcl.clusters.general import Groups
import zigpy.zdo.types as zdo_types
Expand Down Expand Up @@ -456,27 +456,20 @@ def zha_device_info(self):
]

# Return endpoint device type Names
try:
device_info[ATTR_ENDPOINT_NAMES] = [
{
"name": endpoint.device_type.name,
}
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)
]
except AttributeError as ex:
# Some device types are not using an enumeration
self.warning(
"Failed to identify endpoint name in '%s' with exception '%s'",
self._zigpy_device.endpoints.items(),
ex,
)
device_info[ATTR_ENDPOINT_NAMES] = [
{
"name": "unknown",
}
]
names = []
for endpoint in (ep for epid, ep in self.device.endpoints.items() if epid):
profile = PROFILES.get(endpoint.profile_id)
if profile and endpoint.device_type is not None:
# DeviceType provides undefined enums
names.append({ATTR_NAME: profile.DeviceType(endpoint.device_type).name})
else:
names.append(
{
ATTR_NAME: f"unknown {endpoint.device_type} device_type "
"of 0x{endpoint.profile_id:04x} profile id"
}
)
device_info[ATTR_ENDPOINT_NAMES] = names

reg_device = self.gateway.ha_device_registry.async_get(self.device_id)
if reg_device is not None:
Expand Down Expand Up @@ -516,7 +509,7 @@ def async_get_std_clusters(self):
CLUSTER_TYPE_OUT: endpoint.out_clusters,
}
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
Expand Down