Adds timezone
This commit is contained in:
@@ -12,9 +12,10 @@ TAX_KWH = ENERGY_TAX_KWH.merge(ODE_KWH){|key, energy_tax, ode| energy_tax + ode}
|
||||
class Cost
|
||||
|
||||
attr_accessor :max_charge_kwh
|
||||
attr_reader :battery, :entsoe
|
||||
attr_reader :battery, :entsoe, :zone
|
||||
|
||||
def initialize(zone="Amsterdam", battery_capacity=10.0, max_charge=5.0, storage_cost=0.05)
|
||||
@zone = zone
|
||||
@entsoe = Entsoe.new(zone, storage_cost)
|
||||
@max_charge_kwh = max_charge
|
||||
@battery = Battery.new(battery_capacity)
|
||||
@@ -173,14 +174,14 @@ class Cost
|
||||
######################################################
|
||||
|
||||
def hours(date, year_shift=0)
|
||||
hour_start = date.beginning_of_day
|
||||
hour_start = date.in_time_zone("Amsterdam").beginning_of_day
|
||||
day_end = hour_start.advance(days: 1)
|
||||
result = []
|
||||
lowest_hour, highest_hour,high_hours = entsoe.high_low_hours(date)
|
||||
|
||||
while(hour_start < day_end) do
|
||||
hour_end = hour_start.end_of_hour
|
||||
formatted_hour = hour_start.strftime("%F-%H")
|
||||
formatted_hour = hour_start.strftime("%F %H")
|
||||
|
||||
#p "Fetching meter readings between %s and %s" % [hour_start,hour_end]
|
||||
hour_readings = Reading.where("created_at > :begin AND created_at < :end", {:begin => hour_start, :end => hour_end})
|
||||
|
||||
Reference in New Issue
Block a user