2019-04-03 15:40:03 +00:00
|
|
|
"""Support for Qwikswitch relays."""
|
2018-03-29 21:29:46 +00:00
|
|
|
from homeassistant.components.switch import SwitchDevice
|
2017-01-17 22:40:34 +00:00
|
|
|
|
2019-03-21 05:56:46 +00:00
|
|
|
from . import DOMAIN as QWIKSWITCH, QSToggleEntity
|
|
|
|
|
2016-05-13 04:39:30 +00:00
|
|
|
|
2018-08-24 14:37:30 +00:00
|
|
|
async def async_setup_platform(hass, _, add_entities, discovery_info=None):
|
2018-03-25 21:32:13 +00:00
|
|
|
"""Add switches from the main Qwikswitch component."""
|
2016-07-24 00:03:29 +00:00
|
|
|
if discovery_info is None:
|
2018-03-29 21:29:46 +00:00
|
|
|
return
|
2016-05-13 04:39:30 +00:00
|
|
|
|
2018-03-29 21:29:46 +00:00
|
|
|
qsusb = hass.data[QWIKSWITCH]
|
|
|
|
devs = [QSSwitch(qsid, qsusb) for qsid in discovery_info[QWIKSWITCH]]
|
2018-08-24 14:37:30 +00:00
|
|
|
add_entities(devs)
|
2018-03-29 21:29:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
class QSSwitch(QSToggleEntity, SwitchDevice):
|
|
|
|
"""Switch based on a Qwikswitch relay module."""
|