Add attributs and fix lightlevel inconsistency for LightLevel sensor (#24439)

* Add attributs and fix state level

* Update sensor.py

* Update sensor.py
pull/24485/head
Save me 2019-06-11 19:41:20 +02:00 committed by Paulus Schoutsen
parent 7559e70027
commit a6a3555684
1 changed files with 4 additions and 1 deletions

View File

@ -40,13 +40,16 @@ class HueLightLevel(GenericHueGaugeSensorEntity):
# scale used because the human eye adjusts to light levels and small
# changes at low lux levels are more noticeable than at high lux
# levels.
return 10 ** ((self.sensor.lightlevel - 1) / 10000)
return round(float(10 ** ((self.sensor.lightlevel - 1) / 10000)), 2)
@property
def device_state_attributes(self):
"""Return the device state attributes."""
attributes = super().device_state_attributes
attributes.update({
"lightlevel": self.sensor.lightlevel,
"daylight": self.sensor.daylight,
"dark": self.sensor.dark,
"threshold_dark": self.sensor.tholddark,
"threshold_offset": self.sensor.tholdoffset,
})