Black
This commit is contained in:
1 parent
da05dfe708
commit
4de97abc3a
2676 files changed
+163166
-140084
No files matched your search
@@ -1,24 +1,29 @@
|
||||
"""Demo platform that has a couple of fake sensors."""
|
||||
from homeassistant.const import (
|
||||
ATTR_BATTERY_LEVEL, TEMP_CELSIUS, DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_TEMPERATURE)
|
||||
ATTR_BATTERY_LEVEL,
|
||||
TEMP_CELSIUS,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
)
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Demo sensors."""
|
||||
add_entities([
|
||||
DemoSensor('Outside Temperature', 15.6, DEVICE_CLASS_TEMPERATURE,
|
||||
TEMP_CELSIUS, 12),
|
||||
DemoSensor('Outside Humidity', 54, DEVICE_CLASS_HUMIDITY, '%', None),
|
||||
])
|
||||
add_entities(
|
||||
[
|
||||
DemoSensor(
|
||||
"Outside Temperature", 15.6, DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, 12
|
||||
),
|
||||
DemoSensor("Outside Humidity", 54, DEVICE_CLASS_HUMIDITY, "%", None),
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
class DemoSensor(Entity):
|
||||
"""Representation of a Demo sensor."""
|
||||
|
||||
def __init__(self, name, state, device_class,
|
||||
unit_of_measurement, battery):
|
||||
def __init__(self, name, state, device_class, unit_of_measurement, battery):
|
||||
"""Initialize the sensor."""
|
||||
self._name = name
|
||||
self._state = state
|
||||
@@ -55,6 +60,4 @@ class DemoSensor(Entity):
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
if self._battery:
|
||||
return {
|
||||
ATTR_BATTERY_LEVEL: self._battery,
|
||||
}
|
||||
return {ATTR_BATTERY_LEVEL: self._battery}
|
||||
Reference in new issue
Block a user