Implement state for the sensor device
This commit is contained in:
parent
80c2d81f41
commit
78f7c3cbea
1 changed files with 11 additions and 0 deletions
|
@ -11,6 +11,7 @@ from homeassistant.loader import get_component
|
||||||
from homeassistant.helpers import validate_config, ToggleDevice, Device
|
from homeassistant.helpers import validate_config, ToggleDevice, Device
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
EVENT_PLATFORM_DISCOVERED, CONF_ACCESS_TOKEN,
|
EVENT_PLATFORM_DISCOVERED, CONF_ACCESS_TOKEN,
|
||||||
|
STATE_OPEN, STATE_CLOSED,
|
||||||
ATTR_SERVICE, ATTR_DISCOVERED, ATTR_FRIENDLY_NAME)
|
ATTR_SERVICE, ATTR_DISCOVERED, ATTR_FRIENDLY_NAME)
|
||||||
|
|
||||||
DOMAIN = "wink"
|
DOMAIN = "wink"
|
||||||
|
@ -56,6 +57,11 @@ class WinkSensorDevice(Device):
|
||||||
def __init__(self, wink):
|
def __init__(self, wink):
|
||||||
self.wink = wink
|
self.wink = wink
|
||||||
|
|
||||||
|
@property
|
||||||
|
def state(self):
|
||||||
|
""" Returns the state. """
|
||||||
|
return STATE_OPEN if self.is_open else STATE_CLOSED
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
""" Returns the id of this wink switch """
|
""" Returns the id of this wink switch """
|
||||||
|
@ -77,6 +83,11 @@ class WinkSensorDevice(Device):
|
||||||
""" Update state of the sensor. """
|
""" Update state of the sensor. """
|
||||||
self.wink.updateState()
|
self.wink.updateState()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_open(self):
|
||||||
|
""" True if door is open. """
|
||||||
|
return self.wink.state()
|
||||||
|
|
||||||
class WinkToggleDevice(ToggleDevice):
|
class WinkToggleDevice(ToggleDevice):
|
||||||
""" represents a WeMo switch within home assistant. """
|
""" represents a WeMo switch within home assistant. """
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue