mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Fix ZHA battery when readings produce an unknown value (#23854)
* check for unknown readings * only publish valid readings * remove unused constant
This commit is contained in:
parent
eaf4a75402
commit
9b21774392
@ -142,8 +142,8 @@ class ZhaDeviceEntity(ZhaEntity):
|
|||||||
"""Get the latest battery reading from channels cache."""
|
"""Get the latest battery reading from channels cache."""
|
||||||
battery = await self._battery_channel.get_attribute_value(
|
battery = await self._battery_channel.get_attribute_value(
|
||||||
'battery_percentage_remaining')
|
'battery_percentage_remaining')
|
||||||
if battery is not None:
|
# per zcl specs battery percent is reported at 200% ¯\_(ツ)_/¯
|
||||||
# per zcl specs battery percent is reported at 200% ¯\_(ツ)_/¯
|
if battery is not None and battery != -1:
|
||||||
battery = battery / 2
|
battery = battery / 2
|
||||||
battery = int(round(battery))
|
battery = int(round(battery))
|
||||||
self._device_state_attributes['battery_level'] = battery
|
self._device_state_attributes['battery_level'] = battery
|
||||||
|
Loading…
x
Reference in New Issue
Block a user