ps: Add a global config object to Home Assistant

This commit is contained in:
Paulus Schoutsen committed 2015-03-18 23:02:58 -07:00
1 parent 569b15d790
commit 9b643d57f0
23 files changed
+224 -173

No files matched your search

+14 -9
View File
@@ -1,25 +1,25 @@
""" Support for Wink sensors. """
from homeassistant.helpers.device import Device
from homeassistant.const import (
TEMP_CELCIUS, ATTR_UNIT_OF_MEASUREMENT, ATTR_FRIENDLY_NAME)
from homeassistant.const import TEMP_CELCIUS, ATTR_BATTERY_LEVEL
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the Demo sensors. """
add_devices([
DemoSensor('Outside Temperature', 15.6, TEMP_CELCIUS),
DemoSensor('Outside Humidity', 54, '%'),
DemoSensor('Outside Temperature', 15.6, TEMP_CELCIUS, 12),
DemoSensor('Outside Humidity', 54, '%', None),
])
class DemoSensor(Device):
""" A Demo sensor. """
def __init__(self, name, state, unit_of_measurement):
def __init__(self, name, state, unit_of_measurement, battery):
self._name = name
self._state = state
self._unit_of_measurement = unit_of_measurement
self._battery = battery
@property
def should_poll(self):
@@ -36,10 +36,15 @@ class DemoSensor(Device):
""" Returns the state of the device. """
return self._state
@property
def unit_of_measurement(self):
""" Unit this state is expressed in. """
return self._unit_of_measurement
@property
def state_attributes(self):
""" Returns the state attributes. """
return {
ATTR_FRIENDLY_NAME: self._name,
ATTR_UNIT_OF_MEASUREMENT: self._unit_of_measurement,
}
if self._battery:
return {
ATTR_BATTERY_LEVEL: self._battery,
}