No charging at some days

This commit is contained in:
Aart van Halteren
2022-01-10 20:16:58 +01:00
parent d6213e963a
commit adb2e38efa
2 changed files with 9 additions and 3 deletions

View File

@@ -161,12 +161,13 @@ class Cost
# charge battery with return_kwh
return_kwh -= battery.charge(return_kwh)
if lowest_hour.eql?(formatted_hour)
if lowest_hour.eql?(formatted_hour) # lowest_hour = "" if small difference between high/low
# charge battery during lowest hour
usage_kwh += battery.charge(max_charge_kwh)
else
# if during expensive hours || more than <max_charge_kwh> kwh then discharge_battery
if (battery.battery_kwh > max_charge_kwh) || high_hours.include?(formatted_hour)
# if (battery.battery_kwh > max_charge_kwh) || high_hours.include?(formatted_hour)
if high_hours.include?(formatted_hour)
usage_kwh -= battery.discharge(usage_kwh)
end
end
@@ -196,7 +197,7 @@ class Cost
oxxio_rate,
oxxio_cost]
p "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s" % (one_hour[0..7] + one_hour[8..12].map{|c| format_cost(c)})
p "%s,%s,%s,%s,%s,%s,%s,%03f,%s,%s,%s,%s,%s" % (one_hour[0..7] + one_hour[8..12].map{|c| format_cost(c)})
result << one_hour
hour_start = hour_start.advance(:hours => 1)