take yearshift into account
This commit is contained in:
@@ -177,11 +177,10 @@ class Cost
|
|||||||
hour_start = date.in_time_zone("Amsterdam").beginning_of_day
|
hour_start = date.in_time_zone("Amsterdam").beginning_of_day
|
||||||
day_end = hour_start.advance(days: 1)
|
day_end = hour_start.advance(days: 1)
|
||||||
result = []
|
result = []
|
||||||
lowest_hour, highest_hour,high_hours = entsoe.high_low_hours(date)
|
lowest_hour, highest_hour,high_hours = entsoe.high_low_hours(date.advance(years: year_shift))
|
||||||
|
|
||||||
while(hour_start < day_end) do
|
while(hour_start < day_end) do
|
||||||
hour_end = hour_start.end_of_hour
|
hour_end = hour_start.end_of_hour
|
||||||
formatted_hour = hour_start.strftime("%F %H")
|
|
||||||
|
|
||||||
#p "Fetching meter readings between %s and %s" % [hour_start,hour_end]
|
#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})
|
hour_readings = Reading.where("created_at > :begin AND created_at < :end", {:begin => hour_start, :end => hour_end})
|
||||||
@@ -189,6 +188,8 @@ class Cost
|
|||||||
# calculate cost of this hour
|
# calculate cost of this hour
|
||||||
usage_kwh = hour_diff[:total_kwh_consumed_high] + hour_diff[:total_kwh_consumed_low] rescue nil
|
usage_kwh = hour_diff[:total_kwh_consumed_high] + hour_diff[:total_kwh_consumed_low] rescue nil
|
||||||
return_kwh = hour_diff[:total_kwh_produced_high] + hour_diff[:total_kwh_produced_low] rescue nil
|
return_kwh = hour_diff[:total_kwh_produced_high] + hour_diff[:total_kwh_produced_low] rescue nil
|
||||||
|
|
||||||
|
formatted_hour = hour_start.advance(years: year_shift).strftime("%F %H")
|
||||||
entsoe_cost = entsoe_energy_cost(formatted_hour, usage_kwh, return_kwh) # without battery use
|
entsoe_cost = entsoe_energy_cost(formatted_hour, usage_kwh, return_kwh) # without battery use
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ class Entsoe
|
|||||||
prices.map{|p| [start_time.advance(hours: (p[0]-1)), p[1]]}.to_h
|
prices.map{|p| [start_time.advance(hours: (p[0]-1)), p[1]]}.to_h
|
||||||
rescue Date::Error => e
|
rescue Date::Error => e
|
||||||
p e.message
|
p e.message
|
||||||
|
{}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user