From b45e814effe205850d245131ccaeac1eb13e05cd Mon Sep 17 00:00:00 2001 From: salewis38 <46199139+salewis38@users.noreply.github.com> Date: Mon, 25 Sep 2023 07:58:38 +0100 Subject: [PATCH] Added integer definition for tgt_soc Defensive coding to avoid tgt_soc being set as non-integer externally and failing comparison checks --- palm_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/palm_utils.py b/palm_utils.py index b442307..5065089 100644 --- a/palm_utils.py +++ b/palm_utils.py @@ -87,7 +87,7 @@ def __init__(self): self.consumption: int = 0 self.soc: int = 0 self.base_load = stgs.GE.base_load - self.tgt_soc = 100 + self.tgt_soc: int = 100 self.cmd_list = stgs.GE_Command_list['data'] self.plot = [""] * 5 @@ -393,6 +393,7 @@ def compute_tgt_soc(self, gen_fcast, weight: int, commit: bool) -> str: if weight > 50: wgt_50 = 90 - weight else: + wgt_50 = weight - 10 wgt_90 = max(0, weight - 50) @@ -400,6 +401,7 @@ def compute_tgt_soc(self, gen_fcast, weight: int, commit: bool) -> str: logger.info("{:<20} {:>10} {:>10} {:>10} {:>10} {:>10} {:>10}".format("SoC Calc;", "Day", "Hour", "Charge", "Cons", "Gen", "SoC")) + tgt_soc: int = 100 # Definitions for export of SoC forecast in chart form plot_x = ["Time"] plot_y1 = ["Calculated SoC"]