No charging from grid during sunny months

This commit is contained in:
Aart van Halteren
2022-01-10 21:22:51 +01:00
parent 849ce0ea1c
commit 1372f01000

View File

@@ -40,8 +40,15 @@ class Entsoe
def high_low_hours(date) def high_low_hours(date)
sorted_prices = prices_at(date).to_a.sort_by(&:last) # sort according to price sorted_prices = prices_at(date).to_a.sort_by(&:last) # sort according to price
lowest_hour = sorted_prices.first[0]
highest_hour = sorted_prices.last[0] highest_hour = sorted_prices.last[0]
# From Apr-Oct: do not charge; every hour that has cost > charge_rate is a high_hour
if [4,5,6,7,8,9,10].include?(date.month)
lowest_hour = "" # effectively no charging from grid
high_hours = sorted_prices.select{|p| p[1] > storage_cost}
else
lowest_hour = sorted_prices.first[0]
# calculate hours where rate > charge_rate + storage_cost (typically 0.05) # calculate hours where rate > charge_rate + storage_cost (typically 0.05)
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
@@ -49,6 +56,7 @@ class Entsoe
# reset lowest_hour (effectively not charging), when price difference smaller than storage_cost # reset lowest_hour (effectively not charging), when price difference smaller than storage_cost
highest_price = sorted_prices.last[1] highest_price = sorted_prices.last[1]
lowest_hour = "" if (highest_price-charge_rate) < storage_cost lowest_hour = "" if (highest_price-charge_rate) < storage_cost
end
return lowest_hour,highest_hour,high_hours return lowest_hour,highest_hour,high_hours
end end