Changed do_lock and do_unlock methods to lock and unlock.
Implemented state method. Fixed locked method for demo interface. Changed LockDevice to extend Entity instead of ToggleEntity
This commit is contained in:
1 parent
c78899c4f3
commit
fa7391cdf6
3 files changed
+31
-48
No files matched your search
@@ -8,8 +8,8 @@ https://home-assistant.io/components/lock.wink/
|
||||
"""
|
||||
import logging
|
||||
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN, STATE_LOCKED, STATE_UNLOCKED
|
||||
from homeassistant.components.lock import LockDevice
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
||||
|
||||
REQUIREMENTS = ['https://github.com/balloob/python-wink/archive/'
|
||||
'9eb39eaba0717922815e673ad1114c685839d890.zip'
|
||||
@@ -34,17 +34,12 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
add_devices(WinkLockDevice(lock) for lock in pywink.get_locks())
|
||||
|
||||
|
||||
class WinkLockDevice(Entity):
|
||||
class WinkLockDevice(LockDevice):
|
||||
""" Represents a Wink lock. """
|
||||
|
||||
def __init__(self, wink):
|
||||
self.wink = wink
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
""" Returns the state. """
|
||||
return STATE_LOCKED if self.is_locked else STATE_UNLOCKED
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
""" Returns the id of this wink lock """
|
||||
@@ -60,14 +55,14 @@ class WinkLockDevice(Entity):
|
||||
self.wink.updateState()
|
||||
|
||||
@property
|
||||
def is_locked(self):
|
||||
def locked(self):
|
||||
""" True if device is locked. """
|
||||
return self.wink.state()
|
||||
|
||||
def do_lock(self):
|
||||
def lock(self):
|
||||
""" Lock the device. """
|
||||
self.wink.setState(True)
|
||||
|
||||
def do_unlock(self):
|
||||
def unlock(self):
|
||||
""" Unlock the device. """
|
||||
self.wink.setState(False)
|
||||
Reference in new issue
Block a user