Changed locked method of lock support to "is_locked".

Added lock and unlock methods
Updated wink components to use the new version of the wink library.
This commit is contained in:
miniconfig 2015-11-20 16:34:27 -05:00
parent fa7391cdf6
commit 105dc2847e
7 changed files with 25 additions and 17 deletions

View file

@ -13,8 +13,8 @@ from homeassistant.components.wink import WinkToggleDevice
from homeassistant.const import CONF_ACCESS_TOKEN
REQUIREMENTS = ['https://github.com/balloob/python-wink/archive/'
'9eb39eaba0717922815e673ad1114c685839d890.zip'
'#python-wink==0.1.1']
'42fdcfa721b1bc583688e3592d8427f4c13ba6d9.zip'
'#python-wink==0.2']
def setup_platform(hass, config, add_devices_callback, discovery_info=None):

View file

@ -44,7 +44,7 @@ PROP_TO_ATTR = {
_LOGGER = logging.getLogger(__name__)
def locked(hass, entity_id=None):
def is_locked(hass, entity_id=None):
""" Returns if the lock is locked based on the statemachine. """
entity_id = entity_id or ENTITY_ID_ALL_LOCKS
return hass.states.is_state(entity_id, STATE_LOCKED)
@ -97,13 +97,21 @@ class LockDevice(Entity):
# pylint: disable=no-self-use
@property
def locked(self):
def is_locked(self):
""" Is the lock locked or unlocked. """
return None
def lock(self):
""" Locks the lock. """
raise NotImplementedError()
def unlock(self):
""" Unlocks the lock. """
raise NotImplementedError()
@property
def state(self):
is_locked = self.locked
if is_locked is None:
locked = self.is_locked
if locked is None:
return STATE_UNKNOWN
return STATE_LOCKED if is_locked else STATE_UNLOCKED
return STATE_LOCKED if locked else STATE_UNLOCKED

View file

@ -41,7 +41,7 @@ class DemoLock(LockDevice):
return self._icon
@property
def locked(self):
def is_locked(self):
""" True if device is locked. """
if self._state == STATE_LOCKED:
return True

View file

@ -12,8 +12,8 @@ from homeassistant.components.lock import LockDevice
from homeassistant.const import CONF_ACCESS_TOKEN
REQUIREMENTS = ['https://github.com/balloob/python-wink/archive/'
'9eb39eaba0717922815e673ad1114c685839d890.zip'
'#python-wink==0.1.1']
'42fdcfa721b1bc583688e3592d8427f4c13ba6d9.zip'
'#python-wink==0.2']
def setup_platform(hass, config, add_devices, discovery_info=None):
@ -55,7 +55,7 @@ class WinkLockDevice(LockDevice):
self.wink.updateState()
@property
def locked(self):
def is_locked(self):
""" True if device is locked. """
return self.wink.state()

View file

@ -12,8 +12,8 @@ from homeassistant.helpers.entity import Entity
from homeassistant.const import CONF_ACCESS_TOKEN, STATE_OPEN, STATE_CLOSED
REQUIREMENTS = ['https://github.com/balloob/python-wink/archive/'
'9eb39eaba0717922815e673ad1114c685839d890.zip'
'#python-wink==0.1.1']
'42fdcfa721b1bc583688e3592d8427f4c13ba6d9.zip'
'#python-wink==0.2']
def setup_platform(hass, config, add_devices, discovery_info=None):

View file

@ -12,8 +12,8 @@ from homeassistant.components.wink import WinkToggleDevice
from homeassistant.const import CONF_ACCESS_TOKEN
REQUIREMENTS = ['https://github.com/balloob/python-wink/archive/'
'9eb39eaba0717922815e673ad1114c685839d890.zip'
'#python-wink==0.1.1']
'42fdcfa721b1bc583688e3592d8427f4c13ba6d9.zip'
'#python-wink==0.2']
def setup_platform(hass, config, add_devices, discovery_info=None):

View file

@ -19,8 +19,8 @@ from homeassistant.const import (
DOMAIN = "wink"
DEPENDENCIES = []
REQUIREMENTS = ['https://github.com/balloob/python-wink/archive/'
'9eb39eaba0717922815e673ad1114c685839d890.zip'
'#python-wink==0.1.1']
'42fdcfa721b1bc583688e3592d8427f4c13ba6d9.zip'
'#python-wink==0.2']
DISCOVER_LIGHTS = "wink.lights"
DISCOVER_SWITCHES = "wink.switches"