deCONZ - Support device registry (#16115)
Add support for device registry in deCONZ component
This commit is contained in:
1 parent
e8775ba2b4
commit
e91a1529e4
12 files changed
+162
-36
No files matched your search
@@ -6,10 +6,11 @@ https://home-assistant.io/components/sensor.deconz/
|
||||
"""
|
||||
from homeassistant.components.deconz.const import (
|
||||
ATTR_DARK, ATTR_ON, CONF_ALLOW_CLIP_SENSOR, DOMAIN as DATA_DECONZ,
|
||||
DATA_DECONZ_ID, DATA_DECONZ_UNSUB)
|
||||
DATA_DECONZ_ID, DATA_DECONZ_UNSUB, DECONZ_DOMAIN)
|
||||
from homeassistant.const import (
|
||||
ATTR_BATTERY_LEVEL, ATTR_VOLTAGE, DEVICE_CLASS_BATTERY)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.device_registry import CONNECTION_ZIGBEE
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util import slugify
|
||||
@@ -134,6 +135,22 @@ class DeconzSensor(Entity):
|
||||
attr[ATTR_DAYLIGHT] = self._sensor.daylight
|
||||
return attr
|
||||
|
||||
@property
|
||||
def device(self):
|
||||
"""Return a device description for device registry."""
|
||||
if (self._sensor.uniqueid is None or
|
||||
self._sensor.uniqueid.count(':') != 7):
|
||||
return None
|
||||
serial = self._sensor.uniqueid.split('-', 1)[0]
|
||||
return {
|
||||
'connection': [[CONNECTION_ZIGBEE, serial]],
|
||||
'identifiers': [[DECONZ_DOMAIN, serial]],
|
||||
'manufacturer': self._sensor.manufacturer,
|
||||
'model': self._sensor.modelid,
|
||||
'name': self._sensor.name,
|
||||
'sw_version': self._sensor.swversion,
|
||||
}
|
||||
|
||||
|
||||
class DeconzBattery(Entity):
|
||||
"""Battery class for when a device is only represented as an event."""
|
||||
@@ -192,3 +209,19 @@ class DeconzBattery(Entity):
|
||||
ATTR_EVENT_ID: slugify(self._device.name),
|
||||
}
|
||||
return attr
|
||||
|
||||
@property
|
||||
def device(self):
|
||||
"""Return a device description for device registry."""
|
||||
if (self._device.uniqueid is None or
|
||||
self._device.uniqueid.count(':') != 7):
|
||||
return None
|
||||
serial = self._device.uniqueid.split('-', 1)[0]
|
||||
return {
|
||||
'connection': [[CONNECTION_ZIGBEE, serial]],
|
||||
'identifiers': [[DECONZ_DOMAIN, serial]],
|
||||
'manufacturer': self._device.manufacturer,
|
||||
'model': self._device.modelid,
|
||||
'name': self._device.name,
|
||||
'sw_version': self._device.swversion,
|
||||
}
|
||||
Reference in new issue
Block a user