From ac5ccd651cfaa8a0a144ba1fde82b22c0be44d0f Mon Sep 17 00:00:00 2001 From: "David F. Mulcahey" Date: Sat, 9 Mar 2019 15:14:58 -0500 Subject: [PATCH] Bump quirks for ZHA and handle resulting battery % change (#21869) * bump quirks and handle battery change * move inside guard * round battery --- homeassistant/components/zha/__init__.py | 2 +- homeassistant/components/zha/device_entity.py | 3 +++ requirements_all.txt | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/zha/__init__.py b/homeassistant/components/zha/__init__.py index cafbae13421..ec4d9082dc5 100644 --- a/homeassistant/components/zha/__init__.py +++ b/homeassistant/components/zha/__init__.py @@ -32,7 +32,7 @@ REQUIREMENTS = [ 'bellows-homeassistant==0.7.1', 'zigpy-homeassistant==0.3.0', 'zigpy-xbee-homeassistant==0.1.2', - 'zha-quirks==0.0.6', + 'zha-quirks==0.0.7', 'zigpy-deconz==0.1.2' ] diff --git a/homeassistant/components/zha/device_entity.py b/homeassistant/components/zha/device_entity.py index 5632c849d59..b3fe7a72526 100644 --- a/homeassistant/components/zha/device_entity.py +++ b/homeassistant/components/zha/device_entity.py @@ -147,4 +147,7 @@ class ZhaDeviceEntity(ZhaEntity): 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% ¯\_(ツ)_/¯ + battery = battery / 2 + battery = int(round(battery)) self._device_state_attributes['battery_level'] = battery diff --git a/requirements_all.txt b/requirements_all.txt index ac1883a4b73..b845f432c59 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1826,7 +1826,7 @@ zengge==0.2 zeroconf==0.21.3 # homeassistant.components.zha -zha-quirks==0.0.6 +zha-quirks==0.0.7 # homeassistant.components.climate.zhong_hong zhong_hong_hvac==1.0.9