logic for check_peak

This commit is contained in:
Paul Warren 2024-10-18 17:13:09 +11:00
parent be33908a76
commit da26dc0192

View file

@ -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