From 3c2502918f81044c3b1be841965ab28de3207896 Mon Sep 17 00:00:00 2001 From: Trefor Southwell <48591903+springfall2008@users.noreply.github.com> Date: Wed, 31 Jan 2024 21:05:29 +0000 Subject: [PATCH] Rate scaling divide by 0 protection in charge curve calcuation --- apps/predbat/predbat.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/predbat/predbat.py b/apps/predbat/predbat.py index 37fb7ec6a..daf5fc4f7 100644 --- a/apps/predbat/predbat.py +++ b/apps/predbat/predbat.py @@ -18,7 +18,7 @@ import os import yaml -THIS_VERSION = "v7.15.9" +THIS_VERSION = "v7.15.10" TIME_FORMAT = "%Y-%m-%dT%H:%M:%S%z" TIME_FORMAT_SECONDS = "%Y-%m-%dT%H:%M:%S.%f%z" TIME_FORMAT_OCTOPUS = "%Y-%m-%d %H:%M:%S%z" @@ -1107,8 +1107,9 @@ def find_charge_curve(self): rate_scaling = 0 for index in final_curve: rate_scaling = max(final_curve[index], rate_scaling) - for index in final_curve: - final_curve[index] = round(final_curve[index] / rate_scaling, 2) + if rate_scaling > 0: + for index in final_curve: + final_curve[index] = round(final_curve[index] / rate_scaling, 2) text = " battery_charge_power_curve:\n" keys = sorted(final_curve.keys()) keys.reverse()