2015-05-13 19:18:30 +02:00
|
|
|
"""
|
|
|
|
homeassistant.components.switch.wink
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
Support for Wink switches.
|
2015-10-21 10:47:31 +02:00
|
|
|
|
|
|
|
For more details about this platform, please refer to the documentation at
|
2015-11-09 13:12:18 +01:00
|
|
|
https://home-assistant.io/components/switch.wink/
|
2015-05-13 19:18:30 +02:00
|
|
|
"""
|
2014-12-16 00:01:15 -08:00
|
|
|
import logging
|
|
|
|
|
2015-01-15 21:25:24 -08:00
|
|
|
from homeassistant.components.wink import WinkToggleDevice
|
|
|
|
from homeassistant.const import CONF_ACCESS_TOKEN
|
2014-12-16 00:01:15 -08:00
|
|
|
|
2016-02-23 14:20:54 -05:00
|
|
|
REQUIREMENTS = ['python-wink==0.6.2']
|
2014-12-16 00:01:15 -08:00
|
|
|
|
2015-12-16 22:45:58 -05:00
|
|
|
|
2015-03-01 01:35:58 -08:00
|
|
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
|
|
|
""" Sets up the Wink platform. """
|
2015-07-20 00:41:57 -07:00
|
|
|
import pywink
|
|
|
|
|
2015-03-01 01:35:58 -08:00
|
|
|
if discovery_info is None:
|
|
|
|
token = config.get(CONF_ACCESS_TOKEN)
|
2014-12-16 00:01:15 -08:00
|
|
|
|
2015-03-01 01:35:58 -08:00
|
|
|
if token is None:
|
|
|
|
logging.getLogger(__name__).error(
|
2015-10-21 10:47:31 +02:00
|
|
|
"Missing wink access_token. "
|
|
|
|
"Get one at https://winkbearertoken.appspot.com/")
|
2015-03-01 01:35:58 -08:00
|
|
|
return
|
2014-12-16 00:01:15 -08:00
|
|
|
|
2015-03-01 01:35:58 -08:00
|
|
|
pywink.set_bearer_token(token)
|
2014-12-16 00:01:15 -08:00
|
|
|
|
2015-03-01 01:35:58 -08:00
|
|
|
add_devices(WinkToggleDevice(switch) for switch in pywink.get_switches())
|
2016-01-14 08:56:59 -05:00
|
|
|
add_devices(WinkToggleDevice(switch) for switch in
|
|
|
|
pywink.get_powerstrip_outlets())
|
2016-01-21 11:12:00 -05:00
|
|
|
add_devices(WinkToggleDevice(switch) for switch in pywink.get_sirens())
|