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