From 3ed8ea5f8a2fcf7da5d0aa7badb9d4cb8def87d5 Mon Sep 17 00:00:00 2001 From: Aart van Halteren Date: Tue, 11 Jan 2022 15:38:34 +0100 Subject: [PATCH] Make storage_cost configurable --- app/models/cost.rb | 6 +++--- app/models/entsoe.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/cost.rb b/app/models/cost.rb index 228bb4d..d182458 100644 --- a/app/models/cost.rb +++ b/app/models/cost.rb @@ -6,8 +6,8 @@ class Cost attr_accessor :max_charge_kwh attr_reader :battery, :entsoe - def initialize(battery_capacity=10.0, max_charge=5.0) - @entsoe = Entsoe.new + def initialize(battery_capacity=10.0, max_charge=5.0, storage_cost=0.05) + @entsoe = Entsoe.new(storage_cost) @max_charge_kwh = max_charge @battery = Battery.new(battery_capacity) end @@ -197,7 +197,7 @@ class Cost oxxio_rate, oxxio_cost] - p "%s,%s,%s,%s,%s,%s,%s,%0.02f,%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,%0.1f,%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) diff --git a/app/models/entsoe.rb b/app/models/entsoe.rb index 66ed0bb..a7f78e2 100644 --- a/app/models/entsoe.rb +++ b/app/models/entsoe.rb @@ -13,10 +13,10 @@ class Entsoe attr_accessor :no_grid_charge_months attr_reader :storage_cost - def initialize(api_key = "c2287e07-0c26-4950-b430-22b7f75a8f2e") + def initialize(storage_cost = 0.05, 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 + @storage_cost = storage_cost # 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