No charging from grid during sunny months
This commit is contained in:
@@ -40,15 +40,23 @@ 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]
|
||||||
# calculate hours where rate > charge_rate + storage_cost (typically 0.05)
|
|
||||||
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
|
|
||||||
|
|
||||||
# reset lowest_hour (effectively not charging), when price difference smaller than storage_cost
|
# From Apr-Oct: do not charge; every hour that has cost > charge_rate is a high_hour
|
||||||
highest_price = sorted_prices.last[1]
|
if [4,5,6,7,8,9,10].include?(date.month)
|
||||||
lowest_hour = "" if (highest_price-charge_rate) < storage_cost
|
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)
|
||||||
|
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
|
||||||
|
|
||||||
|
# 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
|
||||||
|
end
|
||||||
|
|
||||||
return lowest_hour,highest_hour,high_hours
|
return lowest_hour,highest_hour,high_hours
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user