Add logical Zigbee device type to ZHA device info (#30954)

* add device type to device info
* capitalize
* use zigpy logical device type
This commit is contained in:
David F. Mulcahey 2020-01-18 19:27:55 -05:00 committed by Alexei Chetroi
parent 656ef6566b
commit 078ce24e5a
2 changed files with 10 additions and 0 deletions

View file

@ -18,6 +18,7 @@ ATTR_CLUSTER_ID = "cluster_id"
ATTR_CLUSTER_TYPE = "cluster_type"
ATTR_COMMAND = "command"
ATTR_COMMAND_TYPE = "command_type"
ATTR_DEVICE_TYPE = "device_type"
ATTR_ENDPOINT_ID = "endpoint_id"
ATTR_IEEE = "ieee"
ATTR_LAST_SEEN = "last_seen"

View file

@ -32,6 +32,7 @@ from .const import (
ATTR_CLUSTER_ID,
ATTR_COMMAND,
ATTR_COMMAND_TYPE,
ATTR_DEVICE_TYPE,
ATTR_ENDPOINT_ID,
ATTR_IEEE,
ATTR_LAST_SEEN,
@ -57,6 +58,7 @@ from .const import (
POWER_BATTERY_OR_UNKNOWN,
POWER_MAINS_POWERED,
SIGNAL_AVAILABLE,
UNKNOWN,
UNKNOWN_MANUFACTURER,
UNKNOWN_MODEL,
)
@ -160,6 +162,12 @@ class ZHADevice(LogMixin):
"""Return true if device is mains powered."""
return self._zigpy_device.node_desc.is_mains_powered
@property
def device_type(self):
"""Return the logical device type for the device."""
device_type = self._zigpy_device.node_desc.logical_type
return device_type.name if device_type else UNKNOWN
@property
def power_source(self):
"""Return the power source for the device."""
@ -281,6 +289,7 @@ class ZHADevice(LogMixin):
ATTR_RSSI: self.rssi,
ATTR_LAST_SEEN: update_time,
ATTR_AVAILABLE: self.available,
ATTR_DEVICE_TYPE: self.device_type,
}
def add_cluster_channel(self, cluster_channel):