* 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
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
"""
|
|
Support for Qwikswitch Relays and Dimmers.
|
|
|
|
For more details about this platform, please refer to the documentation at
|
|
https://home-assistant.io/components/light.qwikswitch/
|
|
"""
|
|
from homeassistant.components.qwikswitch import (
|
|
QSToggleEntity, DOMAIN as QWIKSWITCH)
|
|
from homeassistant.components.light import SUPPORT_BRIGHTNESS, Light
|
|
|
|
DEPENDENCIES = [QWIKSWITCH]
|
|
|
|
|
|
async def async_setup_platform(hass, _, add_devices, discovery_info=None):
|
|
"""Add lights from the main Qwikswitch component."""
|
|
if discovery_info is None:
|
|
return
|
|
|
|
qsusb = hass.data[QWIKSWITCH]
|
|
devs = [QSLight(qsid, qsusb) for qsid in discovery_info[QWIKSWITCH]]
|
|
add_devices(devs)
|
|
|
|
|
|
class QSLight(QSToggleEntity, Light):
|
|
"""Light based on a Qwikswitch relay/dimmer module."""
|
|
|
|
@property
|
|
def brightness(self):
|
|
"""Return the brightness of this light (0-255)."""
|
|
return self._device.value if self._device.is_dimmer else None
|
|
|
|
@property
|
|
def supported_features(self):
|
|
"""Flag supported features."""
|
|
return SUPPORT_BRIGHTNESS if self._device.is_dimmer else 0
|