mirror of
https://github.com/elisspace/core.git
synced 2026-09-24 11:36:53 +00:00
* Remove dependencies and requirements * Revert "Remove dependencies and requirements" This reverts commit fe7171b4cd30889bad5adc9a4fd60059d05ba5a7. * Remove dependencies and requirements * Revert "Remove dependencies and requirements" This reverts commit 391355ee2cc53cbe6954f940062b18ae34b05621. * Remove dependencies and requirements * Fix flake8 complaints * Fix more flake8 complaints * Revert non-component removals
29 lines
903 B
Python
29 lines
903 B
Python
"""Support for Qwikswitch Relays and Dimmers."""
|
|
from homeassistant.components.light import SUPPORT_BRIGHTNESS, Light
|
|
|
|
from . import DOMAIN as QWIKSWITCH, QSToggleEntity
|
|
|
|
|
|
async def async_setup_platform(hass, _, add_entities, 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_entities(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
|