No charging at some days
This commit is contained in:
@@ -161,12 +161,13 @@ class Cost
|
|||||||
# charge battery with return_kwh
|
# charge battery with return_kwh
|
||||||
return_kwh -= battery.charge(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
|
# charge battery during lowest hour
|
||||||
usage_kwh += battery.charge(max_charge_kwh)
|
usage_kwh += battery.charge(max_charge_kwh)
|
||||||
else
|
else
|
||||||
# if during expensive hours || more than <max_charge_kwh> kwh then discharge_battery
|
# 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)
|
usage_kwh -= battery.discharge(usage_kwh)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -196,7 +197,7 @@ class Cost
|
|||||||
oxxio_rate,
|
oxxio_rate,
|
||||||
oxxio_cost]
|
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
|
result << one_hour
|
||||||
|
|
||||||
hour_start = hour_start.advance(:hours => 1)
|
hour_start = hour_start.advance(:hours => 1)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class Entsoe
|
|||||||
|
|
||||||
def price_at(formatted_hour)
|
def price_at(formatted_hour)
|
||||||
unless @kwh_prices.key?(formatted_hour)
|
unless @kwh_prices.key?(formatted_hour)
|
||||||
|
p "Fetching Entsoe tariffs for %s" % formatted_hour
|
||||||
@kwh_prices.merge!(query_day_ahead_prices(Date.parse(formatted_hour)))
|
@kwh_prices.merge!(query_day_ahead_prices(Date.parse(formatted_hour)))
|
||||||
end
|
end
|
||||||
@kwh_prices[formatted_hour]
|
@kwh_prices[formatted_hour]
|
||||||
@@ -45,6 +46,10 @@ class Entsoe
|
|||||||
charge_rate = sorted_prices.first[1] # assume we charge at lowest hour
|
charge_rate = sorted_prices.first[1] # assume we charge at lowest hour
|
||||||
high_hours = sorted_prices.select{|p| p[1] > charge_rate + storage_cost}.to_h.keys
|
high_hours = sorted_prices.select{|p| p[1] > charge_rate + storage_cost}.to_h.keys
|
||||||
|
|
||||||
|
# reset lowest_hour (effectively not charging), when price difference smaller than storage_cost
|
||||||
|
highest_price = sorted_prices.last[1]
|
||||||
|
lowest_hour = "" if (highest_price-charge_rate) < storage_cost
|
||||||
|
|
||||||
return lowest_hour,highest_hour,high_hours
|
return lowest_hour,highest_hour,high_hours
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user