hass-core/homeassistant/components/switch/wink.py

33 lines
933 B
Python
Raw Normal View History

2015-05-13 19:18:30 +02:00
"""
homeassistant.components.switch.wink
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for Wink switches.
"""
import logging
2015-01-15 21:25:24 -08:00
from homeassistant.components.wink import WinkToggleDevice
from homeassistant.const import CONF_ACCESS_TOKEN
2015-09-09 12:40:28 -07:00
REQUIREMENTS = ['https://github.com/balloob/python-wink/archive/'
'c2b700e8ca866159566ecf5e644d9c297f69f257.zip'
'#python-wink==0.1']
2015-08-08 21:22:34 -07:00
2015-03-01 01:35:58 -08:00
def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the Wink platform. """
import pywink
2015-03-01 01:35:58 -08:00
if discovery_info is None:
token = config.get(CONF_ACCESS_TOKEN)
2015-03-01 01:35:58 -08:00
if token is None:
logging.getLogger(__name__).error(
"Missing wink access_token - "
"get one at https://winkbearertoken.appspot.com/")
return
2015-03-01 01:35:58 -08:00
pywink.set_bearer_token(token)
2015-03-01 01:35:58 -08:00
add_devices(WinkToggleDevice(switch) for switch in pywink.get_switches())