Add zigbee information to ZHA device information (#33612)

* add zigbee signature to zha device info

* add typing

* use props and sort clusters

* review comment
This commit is contained in:
David F. Mulcahey 2020-04-04 08:40:55 -04:00 committed by GitHub
parent 05192b7164
commit debc1f78d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 1 deletions

View file

@ -5,6 +5,7 @@ from enum import Enum
import logging
import random
import time
from typing import Any, Dict
from zigpy import types
import zigpy.exceptions
@ -31,6 +32,7 @@ from .const import (
ATTR_COMMAND_TYPE,
ATTR_DEVICE_TYPE,
ATTR_ENDPOINT_ID,
ATTR_ENDPOINTS,
ATTR_IEEE,
ATTR_LAST_SEEN,
ATTR_LQI,
@ -38,11 +40,13 @@ from .const import (
ATTR_MANUFACTURER_CODE,
ATTR_MODEL,
ATTR_NAME,
ATTR_NODE_DESCRIPTOR,
ATTR_NWK,
ATTR_POWER_SOURCE,
ATTR_QUIRK_APPLIED,
ATTR_QUIRK_CLASS,
ATTR_RSSI,
ATTR_SIGNATURE,
ATTR_VALUE,
CLUSTER_COMMAND_SERVER,
CLUSTER_COMMANDS_CLIENT,
@ -267,6 +271,14 @@ class ZHADevice(LogMixin):
"""Return True if sensor is available."""
return self._available
@property
def zigbee_signature(self) -> Dict[str, Any]:
"""Get zigbee signature for this device."""
return {
ATTR_NODE_DESCRIPTOR: str(self._zigpy_device.node_desc),
ATTR_ENDPOINTS: self._channels.zigbee_signature,
}
def set_available(self, available):
"""Set availability from restore and prevent signals."""
self._available = available
@ -366,6 +378,7 @@ class ZHADevice(LogMixin):
ATTR_LAST_SEEN: update_time,
ATTR_AVAILABLE: self.available,
ATTR_DEVICE_TYPE: self.device_type,
ATTR_SIGNATURE: self.zigbee_signature,
}
async def async_configure(self):