deCONZ - Support device registry (#16115)

Add support for device registry in deCONZ component
This commit is contained in:
Robert Svensson
2018-08-24 19:37:22 +02:00
committed by GitHub
parent e8775ba2b4
commit e91a1529e4
12 changed files with 162 additions and 36 deletions

View File

@@ -6,9 +6,10 @@ https://home-assistant.io/components/switch.deconz/
"""
from homeassistant.components.deconz.const import (
DOMAIN as DATA_DECONZ, DATA_DECONZ_ID, DATA_DECONZ_UNSUB,
POWER_PLUGS, SIRENS)
DECONZ_DOMAIN, POWER_PLUGS, SIRENS)
from homeassistant.components.switch import SwitchDevice
from homeassistant.core import callback
from homeassistant.helpers.device_registry import CONNECTION_ZIGBEE
from homeassistant.helpers.dispatcher import async_dispatcher_connect
DEPENDENCIES = ['deconz']
@@ -79,6 +80,22 @@ class DeconzSwitch(SwitchDevice):
"""No polling needed."""
return False
@property
def device(self):
"""Return a device description for device registry."""
if (self._switch.uniqueid is None or
self._switch.uniqueid.count(':') != 7):
return None
serial = self._switch.uniqueid.split('-', 1)[0]
return {
'connection': [[CONNECTION_ZIGBEE, serial]],
'identifiers': [[DECONZ_DOMAIN, serial]],
'manufacturer': self._switch.manufacturer,
'model': self._switch.modelid,
'name': self._switch.name,
'sw_version': self._switch.swversion,
}
class DeconzPowerPlug(DeconzSwitch):
"""Representation of power plugs from deCONZ."""