Fewer no grid charge months

This commit is contained in:
Aart van Halteren
2022-01-10 22:27:25 +01:00
parent 8725c12a68
commit 28a806f584
2 changed files with 9 additions and 7 deletions

View File

@@ -10,12 +10,14 @@ class Entsoe
URL = 'https://transparency.entsoe.eu'
attr_accessor :no_grid_charge_months
attr_reader :storage_cost
def initialize(api_key = "c2287e07-0c26-4950-b430-22b7f75a8f2e")
@api_key = api_key
@kwh_prices = {}
@storage_cost = 0.05 # how much does it cost to store 1 kwh in battery
@no_grid_charge_months = [5,6,7] # months where we assume there is enough surplus from sun power
end
def price_at(formatted_hour)
@@ -42,8 +44,8 @@ class Entsoe
sorted_prices = prices_at(date).to_a.sort_by(&:last) # sort according to price
highest_hour = sorted_prices.last[0]
# From Apr-Oct: do not charge; every hour that has cost > 0 is a high_hour
if [4,5,6,7,8,9,10].include?(date.month)
# Some months: do not charge; every hour that has cost > 0 is a high_hour
if @no_grid_charge_months.include?(date.month)
lowest_hour = "" # effectively no charging from grid
high_hours = sorted_prices.select{|p| p[1] > 0}.to_h.keys
else