Device Registry (#15980)

* First draft

* Generate device id

* No obscure registry

* Dont store config_entry_id in device

* Storage

* Small mistake on rebase

* Do storage more like entity registry

* Improve device identification

* Add tests

* Remove deconz device support from PR

* Fix hound comments, voff!

* Fix comments and clean up

* Fix proper indentation

* Fix pydoc issues

* Fix mochad component to not use self.device

* Fix mochad light platform to not use self.device

* Fix TankUtilitySensor to not use self.device

* Fix Soundtouch to not use self.device

* Fix Plex to not use self.device

* Fix Emby to not use self.device

* Fix Heatmiser to not use self.device

* Fix Wemo lights to not use self.device

* Fix Lifx to not use self.device

* Fix Radiotherm to not use self.device

* Fix Juicenet to not use self.device

* Fix Qwikswitch to not use self.device

* Fix Xiaomi miio to not use self.device

* Fix Nest to not use self.device

* Fix Tellduslive to not use self.device

* Fix Knx to not use self.device

* Clean up a small mistake in soundtouch

* Fix comment from Ballob

* Fix bad indentation

* Fix indentatin

* Lint

* Remove unused variable

* Lint
This commit is contained in:
Robert Svensson authored and Paulus Schoutsen committed 2018-08-22 10:46:37 +02:00
1 parent 7e7f9bc6ac
commit 0009be595c
40 files changed
+538 -331

No files matched your search

+6 -6
View File
@@ -63,7 +63,7 @@ class KNXSwitch(SwitchDevice):
def __init__(self, hass, device):
"""Initialize of KNX switch."""
self.device = device
self._device = device
self.hass = hass
self.async_register_callbacks()
@@ -73,12 +73,12 @@ class KNXSwitch(SwitchDevice):
async def after_update_callback(device):
"""Call after device was updated."""
await self.async_update_ha_state()
self.device.register_device_updated_cb(after_update_callback)
self._device.register_device_updated_cb(after_update_callback)
@property
def name(self):
"""Return the name of the KNX device."""
return self.device.name
return self._device.name
@property
def available(self):
@@ -93,12 +93,12 @@ class KNXSwitch(SwitchDevice):
@property
def is_on(self):
"""Return true if device is on."""
return self.device.state
return self._device.state
async def async_turn_on(self, **kwargs):
"""Turn the device on."""
await self.device.set_on()
await self._device.set_on()
async def async_turn_off(self, **kwargs):
"""Turn the device off."""
await self.device.set_off()
await self._device.set_off()
+4 -4
View File
@@ -48,7 +48,7 @@ class MochadSwitch(SwitchDevice):
self._address = dev[CONF_ADDRESS]
self._name = dev.get(CONF_NAME, 'x10_switch_dev_%s' % self._address)
self._comm_type = dev.get(mochad.CONF_COMM_TYPE, 'pl')
self.device = device.Device(ctrl, self._address,
self.switch = device.Device(ctrl, self._address,
comm_type=self._comm_type)
# Init with false to avoid locking HA for long on CM19A (goes from rf
# to pl via TM751, but not other way around)
@@ -71,7 +71,7 @@ class MochadSwitch(SwitchDevice):
try:
# Recycle socket on new command to recover mochad connection
self._controller.reconnect()
self.device.send_cmd('on')
self.switch.send_cmd('on')
# No read data on CM19A which is rf only
if self._comm_type == 'pl':
self._controller.read_data()
@@ -88,7 +88,7 @@ class MochadSwitch(SwitchDevice):
try:
# Recycle socket on new command to recover mochad connection
self._controller.reconnect()
self.device.send_cmd('off')
self.switch.send_cmd('off')
# No read data on CM19A which is rf only
if self._comm_type == 'pl':
self._controller.read_data()
@@ -99,7 +99,7 @@ class MochadSwitch(SwitchDevice):
def _get_device_status(self):
"""Get the status of the switch from mochad."""
with mochad.REQ_LOCK:
status = self.device.get_status().rstrip()
status = self.switch.get_status().rstrip()
return status == 'on'
@property
@@ -28,14 +28,14 @@ class TelldusLiveSwitch(TelldusLiveEntity, ToggleEntity):
@property
def is_on(self):
"""Return true if switch is on."""
return self.device.is_on
return self._device.is_on
def turn_on(self, **kwargs):
"""Turn the switch on."""
self.device.turn_on()
self._device.turn_on()
self.changed()
def turn_off(self, **kwargs):
"""Turn the switch off."""
self.device.turn_off()
self._device.turn_off()
self.changed()