Bug fixes for Wink
This commit is contained in:
1 parent
c116cb095d
commit
702498ca09
7 files changed
+193
-140
No files matched your search
@@ -4,8 +4,8 @@ import logging
|
||||
# pylint: disable=no-name-in-module, import-error
|
||||
import homeassistant.external.wink.pywink as pywink
|
||||
|
||||
from homeassistant.helpers import ToggleDevice
|
||||
from homeassistant.const import ATTR_FRIENDLY_NAME, CONF_ACCESS_TOKEN
|
||||
from homeassistant.components.wink import WinkToggleDevice
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
||||
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
@@ -32,32 +32,4 @@ def devices_discovered(hass, config, info):
|
||||
|
||||
def get_switches():
|
||||
""" Returns the Wink switches. """
|
||||
return [WinkSwitch(switch) for switch in pywink.get_switches()]
|
||||
|
||||
|
||||
class WinkSwitch(ToggleDevice):
|
||||
""" represents a WeMo switch within home assistant. """
|
||||
|
||||
def __init__(self, wink):
|
||||
self.wink = wink
|
||||
self.state_attr = {ATTR_FRIENDLY_NAME: wink.name()}
|
||||
|
||||
def get_name(self):
|
||||
""" Returns the name of the switch if any. """
|
||||
return self.wink.name()
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
""" Turns the switch on. """
|
||||
self.wink.setState(True)
|
||||
|
||||
def turn_off(self):
|
||||
""" Turns the switch off. """
|
||||
self.wink.setState(False)
|
||||
|
||||
def is_on(self):
|
||||
""" True if switch is on. """
|
||||
return self.wink.state()
|
||||
|
||||
def get_state_attributes(self):
|
||||
""" Returns optional state attributes. """
|
||||
return self.state_attr
|
||||
return [WinkToggleDevice(switch) for switch in pywink.get_switches()]
|
||||
Reference in new issue
Block a user