2015-05-13 17:18:30 +00:00
|
|
|
"""
|
|
|
|
Support for Wink switches.
|
2015-10-21 08:47:31 +00:00
|
|
|
|
|
|
|
For more details about this platform, please refer to the documentation at
|
2015-11-09 12:12:18 +00:00
|
|
|
https://home-assistant.io/components/switch.wink/
|
2015-05-13 17:18:30 +00:00
|
|
|
"""
|
2014-12-16 08:01:15 +00:00
|
|
|
|
2016-06-29 21:16:53 +00:00
|
|
|
from homeassistant.components.wink import WinkDevice
|
|
|
|
from homeassistant.helpers.entity import ToggleEntity
|
2014-12-16 08:01:15 +00:00
|
|
|
|
2016-09-20 07:05:54 +00:00
|
|
|
DEPENDENCIES = ['wink']
|
2014-12-16 08:01:15 +00:00
|
|
|
|
2015-12-17 03:45:58 +00:00
|
|
|
|
2015-03-01 09:35:58 +00:00
|
|
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
2016-03-08 12:35:39 +00:00
|
|
|
"""Setup the Wink platform."""
|
2015-07-20 07:41:57 +00:00
|
|
|
import pywink
|
|
|
|
|
2015-03-01 09:35:58 +00:00
|
|
|
add_devices(WinkToggleDevice(switch) for switch in pywink.get_switches())
|
2016-01-14 13:56:59 +00:00
|
|
|
add_devices(WinkToggleDevice(switch) for switch in
|
|
|
|
pywink.get_powerstrip_outlets())
|
2016-01-21 16:12:00 +00:00
|
|
|
add_devices(WinkToggleDevice(switch) for switch in pywink.get_sirens())
|
2016-06-29 21:16:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
class WinkToggleDevice(WinkDevice, ToggleEntity):
|
2016-09-20 07:05:54 +00:00
|
|
|
"""Representation of a Wink toggle device."""
|
2016-06-29 21:16:53 +00:00
|
|
|
|
|
|
|
def __init__(self, wink):
|
|
|
|
"""Initialize the Wink device."""
|
|
|
|
WinkDevice.__init__(self, wink)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def is_on(self):
|
|
|
|
"""Return true if device is on."""
|
|
|
|
return self.wink.state()
|
|
|
|
|
|
|
|
def turn_on(self, **kwargs):
|
|
|
|
"""Turn the device on."""
|
|
|
|
self.wink.set_state(True)
|
|
|
|
|
|
|
|
def turn_off(self):
|
|
|
|
"""Turn the device off."""
|
|
|
|
self.wink.set_state(False)
|