From da26dc019286edc239354057fe5e64ef60894530 Mon Sep 17 00:00:00 2001 From: Paul Warren Date: Fri, 18 Oct 2024 17:13:09 +1100 Subject: [PATCH] logic for check_peak --- examples/check_peak.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/examples/check_peak.py b/examples/check_peak.py index 30c1938..68740ba 100755 --- a/examples/check_peak.py +++ b/examples/check_peak.py @@ -20,7 +20,7 @@ total_wh = gen24_registers.scaledWHRtg.get(fronius1) charge_data = [] discharge_data = [] -print("Gathering 20 second average of battery power") +print("Gathering 5 second average of battery power") while( (datetime.now() - current_time).seconds < 5): charge_data.append(gen24_registers.scaledmodule_3_DCW.get(fronius1)) discharge_data.append(gen24_registers.scaledmodule_4_DCW.get(fronius1)) @@ -33,13 +33,22 @@ print(" SoC: %.2f" % soc_percent) print("Total WH: %.2f" % total_wh) wh_remain = (soc_percent / 100.0) * total_wh -h_estim = wh_remain - avg_discharge +h_estim = wh_remain - (avg_charge - avg_discharge) h_estpct = (h_estim / total_wh) * 100 print("WH remain: %.2f" % wh_remain) print("1h est WH: %.2f" % h_estim) print("1hr est %%: %.2f" % h_estpct) + +time_check = (current_time.hour == 9 or current_time.hour == 15) +estimate_check = (h_estpct < 18.0) + +if (time_check and estimate_check): + print("Full BEEEEEAAAAANS!") +else: + print("Nothing doing") + # Logic of this is: # # If it's 05:00 and battery SoC will be < 18% at 07:00: charge at full beans for 1 hour