deCONZ - cleanup sensor attributes (#25540)

* Improve attributes
This commit is contained in:
Robert Svensson 2019-07-28 21:01:52 +02:00 committed by GitHub
parent a14c299a78
commit c6c4c07f2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,5 @@
"""Support for deCONZ sensors."""
from pydeconz.sensor import LightLevel, Switch
from pydeconz.sensor import Consumption, Daylight, LightLevel, Power, Switch
from homeassistant.const import (
ATTR_BATTERY_LEVEL, ATTR_TEMPERATURE, ATTR_VOLTAGE, DEVICE_CLASS_BATTERY)
@ -97,20 +97,20 @@ class DeconzSensor(DeconzDevice):
if self._device.secondary_temperature is not None:
attr[ATTR_TEMPERATURE] = self._device.secondary_temperature
if self._device.type in LightLevel.ZHATYPE and \
if self._device.type in Consumption.ZHATYPE:
attr[ATTR_POWER] = self._device.power
elif self._device.type in Daylight.ZHATYPE:
attr[ATTR_DAYLIGHT] = self._device.daylight
elif self._device.type in LightLevel.ZHATYPE and \
self._device.dark is not None:
attr[ATTR_DARK] = self._device.dark
if self.unit_of_measurement == 'W':
elif self._device.type in Power.ZHATYPE:
attr[ATTR_CURRENT] = self._device.current
attr[ATTR_VOLTAGE] = self._device.voltage
if self.unit_of_measurement == 'kWh':
attr[ATTR_POWER] = self._device.power
if self._device.SENSOR_CLASS == 'daylight':
attr[ATTR_DAYLIGHT] = self._device.daylight
return attr