Start of charge after checking before peak script

This commit is contained in:
Paul Warren 2024-10-17 20:52:47 +11:00
parent 3f6ab9067d
commit be33908a76

View file

@ -14,13 +14,14 @@ fronius1.connect()
current_time = datetime.now() current_time = datetime.now()
soc = gen24_registers.scaledChaState.get(fronius1) soc_percent = gen24_registers.scaledChaState.get(fronius1)
total_wh = gen24_registers.scaledWHRtg.get(fronius1)
charge_data = [] charge_data = []
discharge_data = [] discharge_data = []
print("Gathering 20 second average of battery Charge") print("Gathering 20 second average of battery power")
while( (datetime.now() - current_time).seconds < 20): while( (datetime.now() - current_time).seconds < 5):
charge_data.append(gen24_registers.scaledmodule_3_DCW.get(fronius1)) charge_data.append(gen24_registers.scaledmodule_3_DCW.get(fronius1))
discharge_data.append(gen24_registers.scaledmodule_4_DCW.get(fronius1)) discharge_data.append(gen24_registers.scaledmodule_4_DCW.get(fronius1))
@ -28,8 +29,16 @@ avg_charge = statistics.mean(charge_data)
avg_discharge = statistics.mean(discharge_data) avg_discharge = statistics.mean(discharge_data)
print(" Charge: %.2f" % avg_charge) print(" Charge: %.2f" % avg_charge)
print("DisCharge: %.2f" % avg_discharge) print("DisCharge: %.2f" % avg_discharge)
print(" SOC: %.2f" % soc) 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_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)
# Logic of this is: # Logic of this is:
# #
@ -37,3 +46,4 @@ print(" SOC: %.2f" % soc)
# #
# if it's 15:00 and battery SoC will be < 25% at 16:00: charge at full beans for 1 hour # if it's 15:00 and battery SoC will be < 25% at 16:00: charge at full beans for 1 hour