mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 00:37:13 +00:00
parent
a14c299a78
commit
c6c4c07f2d
@ -1,5 +1,5 @@
|
|||||||
"""Support for deCONZ sensors."""
|
"""Support for deCONZ sensors."""
|
||||||
from pydeconz.sensor import LightLevel, Switch
|
from pydeconz.sensor import Consumption, Daylight, LightLevel, Power, Switch
|
||||||
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_BATTERY_LEVEL, ATTR_TEMPERATURE, ATTR_VOLTAGE, DEVICE_CLASS_BATTERY)
|
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:
|
if self._device.secondary_temperature is not None:
|
||||||
attr[ATTR_TEMPERATURE] = self._device.secondary_temperature
|
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:
|
self._device.dark is not None:
|
||||||
attr[ATTR_DARK] = self._device.dark
|
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_CURRENT] = self._device.current
|
||||||
attr[ATTR_VOLTAGE] = self._device.voltage
|
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
|
return attr
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user