Move state

pull/608/head
Fabian Affolter 2015-11-20 14:58:49 +01:00
parent b9730e6914
commit a6006b1835
2 changed files with 10 additions and 10 deletions

View File

@ -11,6 +11,7 @@ import logging
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.entity import Entity
from homeassistant.const import (STATE_ON, STATE_OFF)
DOMAIN = 'binary_sensor'
DEPENDENCIES = []
@ -31,12 +32,17 @@ def setup(hass, config):
# pylint: disable=no-self-use
class BinarySensorDevice(Entity):
""" Represents a binary sensor.. """
""" Represents a binary sensor. """
@property
def is_on(self):
""" True if the binary sensor is on. """
return False
return None
@property
def state(self):
""" Returns the state of the binary sensor. """
return STATE_ON if self.is_on else STATE_OFF
@property
def friendly_state(self):

View File

@ -4,7 +4,6 @@ homeassistant.components.binary_sensor.demo
Demo platform that has two fake binary sensors.
"""
from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.const import (STATE_ON, STATE_OFF, DEVICE_DEFAULT_NAME)
def setup_platform(hass, config, add_devices, discovery_info=None):
@ -19,7 +18,7 @@ class DemoBinarySensor(BinarySensorDevice):
""" A Demo binary sensor. """
def __init__(self, name, state, icon=None):
self._name = name or DEVICE_DEFAULT_NAME
self._name = name
self._state = state
self._icon = icon
@ -40,10 +39,5 @@ class DemoBinarySensor(BinarySensorDevice):
@property
def is_on(self):
""" True if the sensor is on. """
""" True if the binary sensor is on. """
return self._state
@property
def state(self):
""" Returns the state of the binary sensor. """
return STATE_ON if self.is_on else STATE_OFF