2016-05-13 06:39:30 +02:00
|
|
|
"""
|
2016-05-21 16:59:52 +02:00
|
|
|
Support for Qwikswitch relays.
|
2016-05-13 06:39:30 +02:00
|
|
|
|
2016-05-21 16:59:52 +02:00
|
|
|
For more details about this platform, please refer to the documentation at
|
|
|
|
https://home-assistant.io/components/switch.qwikswitch/
|
2016-05-13 06:39:30 +02:00
|
|
|
"""
|
|
|
|
import logging
|
|
|
|
import homeassistant.components.qwikswitch as qwikswitch
|
|
|
|
from homeassistant.components.switch import SwitchDevice
|
|
|
|
|
|
|
|
DEPENDENCIES = ['qwikswitch']
|
|
|
|
|
|
|
|
|
|
|
|
class QSSwitch(qwikswitch.QSToggleEntity, SwitchDevice):
|
|
|
|
"""Switch based on a Qwikswitch relay module."""
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
# pylint: disable=unused-argument
|
|
|
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
2016-05-21 16:59:52 +02:00
|
|
|
"""Store add_devices for the switch components."""
|
2016-05-13 06:39:30 +02:00
|
|
|
if discovery_info is None or 'qsusb_id' not in discovery_info:
|
|
|
|
logging.getLogger(__name__).error(
|
|
|
|
'Configure main Qwikswitch component')
|
|
|
|
return False
|
|
|
|
|
|
|
|
qsusb = qwikswitch.QSUSB[discovery_info['qsusb_id']]
|
|
|
|
|
|
|
|
for item in qsusb.ha_devices:
|
2016-05-14 23:21:05 +02:00
|
|
|
if item['type'] == 'switch':
|
2016-05-13 06:39:30 +02:00
|
|
|
dev = QSSwitch(item, qsusb)
|
|
|
|
add_devices([dev])
|
|
|
|
qsusb.ha_objects[item['id']] = dev
|