From 9b217743924ffedd39ca44202d6075f1afc806ca Mon Sep 17 00:00:00 2001 From: "David F. Mulcahey" Date: Tue, 14 May 2019 01:16:21 -0400 Subject: [PATCH] Fix ZHA battery when readings produce an unknown value (#23854) * check for unknown readings * only publish valid readings * remove unused constant --- homeassistant/components/zha/device_entity.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/zha/device_entity.py b/homeassistant/components/zha/device_entity.py index 3937e597b78..94fe598b6ec 100644 --- a/homeassistant/components/zha/device_entity.py +++ b/homeassistant/components/zha/device_entity.py @@ -142,8 +142,8 @@ class ZhaDeviceEntity(ZhaEntity): """Get the latest battery reading from channels cache.""" battery = await self._battery_channel.get_attribute_value( '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 = int(round(battery)) self._device_state_attributes['battery_level'] = battery