From e1b36787db8e2986c8f98a6be18dcf2b4a56bce6 Mon Sep 17 00:00:00 2001 From: Morteum9 <82905352+Morteum9@users.noreply.github.com> Date: Tue, 11 Oct 2022 22:02:25 -0400 Subject: [PATCH] Update responses.py Attempting to implement changes suggested via https://github.com/home-assistant/core/issues/68520 to correct this use with Home Assistant. --- pycarwings2/responses.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pycarwings2/responses.py b/pycarwings2/responses.py index dd9c006..4a9ee6e 100644 --- a/pycarwings2/responses.py +++ b/pycarwings2/responses.py @@ -658,7 +658,10 @@ def __init__(self, status): log.debug("battery_capacity=0, status=%s", status) self.battery_percent = 0 else: - self.battery_percent = 100 * float(self.battery_remaining_amount) / 12 + if self.battery_remaining_amount == '': + self.battery_percent = 0 + else: + self.battery_percent = 100 * float(self.battery_remaining_amount) / 12 # Leaf 2016 has SOC (State Of Charge) in BatteryStatus, a more accurate battery_percentage if "SOC" in bs: