From 78f7c3cbead7b51e868762d3256404e89c28ba3b Mon Sep 17 00:00:00 2001 From: Geoff Norton Date: Tue, 20 Jan 2015 02:58:21 +0000 Subject: [PATCH] Implement state for the sensor device --- homeassistant/components/wink.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/homeassistant/components/wink.py b/homeassistant/components/wink.py index dba73dc1dae..da15bed6dd5 100644 --- a/homeassistant/components/wink.py +++ b/homeassistant/components/wink.py @@ -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. """