deCONZ - Add support for consumption and power sensors (#13218)

* Add support for consumption and power sensors

* Keep attr_current inside component
This commit is contained in:
Kane610 authored and Paulus Schoutsen committed 2018-03-14 20:07:37 -07:00
1 parent 76874e1cbc
commit e122692b46
4 files changed
+17 -14

No files matched your search

@@ -23,8 +23,7 @@ async def async_setup_platform(hass, config, async_add_devices,
sensors = hass.data[DATA_DECONZ].sensors
entities = []
for key in sorted(sensors.keys(), key=int):
sensor = sensors[key]
for sensor in sensors.values():
if sensor and sensor.type in DECONZ_BINARY_SENSOR:
entities.append(DeconzBinarySensor(sensor))
async_add_devices(entities, True)
@@ -93,9 +92,9 @@ class DeconzBinarySensor(BinarySensorDevice):
def device_state_attributes(self):
"""Return the state attributes of the sensor."""
from pydeconz.sensor import PRESENCE
attr = {
ATTR_BATTERY_LEVEL: self._sensor.battery,
}
if self._sensor.type in PRESENCE:
attr = {}
if self._sensor.battery:
attr[ATTR_BATTERY_LEVEL] = self._sensor.battery
if self._sensor.type in PRESENCE and self._sensor.dark:
attr['dark'] = self._sensor.dark
return attr