Implement state for the sensor device

This commit is contained in:
Geoff Norton 2015-01-20 02:58:21 +00:00
parent 80c2d81f41
commit 78f7c3cbea

View file

@ -11,6 +11,7 @@ from homeassistant.loader import get_component
from homeassistant.helpers import validate_config, ToggleDevice, Device
from homeassistant.const import (
EVENT_PLATFORM_DISCOVERED, CONF_ACCESS_TOKEN,
STATE_OPEN, STATE_CLOSED,
ATTR_SERVICE, ATTR_DISCOVERED, ATTR_FRIENDLY_NAME)
DOMAIN = "wink"
@ -56,6 +57,11 @@ class WinkSensorDevice(Device):
def __init__(self, wink):
self.wink = wink
@property
def state(self):
""" Returns the state. """
return STATE_OPEN if self.is_open else STATE_CLOSED
@property
def unique_id(self):
""" Returns the id of this wink switch """
@ -77,6 +83,11 @@ class WinkSensorDevice(Device):
""" Update state of the sensor. """
self.wink.updateState()
@property
def is_open(self):
""" True if door is open. """
return self.wink.state()
class WinkToggleDevice(ToggleDevice):
""" represents a WeMo switch within home assistant. """