Add kWH cost to daily email
This commit is contained in:
@@ -25,6 +25,9 @@ class ReadingsMailer
|
|||||||
|
|
||||||
# Fetch today's usage
|
# Fetch today's usage
|
||||||
usage_today = Reading.diff_on(Date.today)
|
usage_today = Reading.diff_on(Date.today)
|
||||||
|
c = Cost.new
|
||||||
|
oxxio_cost = c.oxxio_energy_cost(Date.today.to_s,usage_today[:total_kwh_consumed_high]-usage_today[:total_kwh_produced_high], usage_today[:total_kwh_consumed_low]-usage_today[:total_kwh_produced_low])
|
||||||
|
easy_cost = c.easy_energy_cost_barplot(Date.today) # side effect: generates a PNG
|
||||||
|
|
||||||
mail = Mail.new do
|
mail = Mail.new do
|
||||||
delivery_method :smtp, smtp_opts
|
delivery_method :smtp, smtp_opts
|
||||||
@@ -37,7 +40,9 @@ class ReadingsMailer
|
|||||||
-------------------------------\n\n
|
-------------------------------\n\n
|
||||||
Total kWH electricity consumed: #{usage_today[:total_kwh_consumed_high] + usage_today[:total_kwh_consumed_low]}\n
|
Total kWH electricity consumed: #{usage_today[:total_kwh_consumed_high] + usage_today[:total_kwh_consumed_low]}\n
|
||||||
Total kWH electricity produced: #{usage_today[:total_kwh_produced_high] + usage_today[:total_kwh_produced_low]}\n
|
Total kWH electricity produced: #{usage_today[:total_kwh_produced_high] + usage_today[:total_kwh_produced_low]}\n
|
||||||
Total m3 gas consumed: #{usage_today[:total_m3_gas_consumed]}\n
|
Total m3 gas consumed: #{usage_today[:total_m3_gas_consumed]}\n\n
|
||||||
|
kWH cost (Oxxio): EUR #{ oxxio_cost }\n
|
||||||
|
kWH cost (EasyEnergy): EUR #{ easy_cost }\n
|
||||||
"
|
"
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -46,7 +51,10 @@ class ReadingsMailer
|
|||||||
body "<h1>Summary for #{Date.today}</h1>" +
|
body "<h1>Summary for #{Date.today}</h1>" +
|
||||||
"<p>Total kWH electricity consumed: #{usage_today[:total_kwh_consumed_high] + usage_today[:total_kwh_consumed_low]}</p>" +
|
"<p>Total kWH electricity consumed: #{usage_today[:total_kwh_consumed_high] + usage_today[:total_kwh_consumed_low]}</p>" +
|
||||||
"<p>Total kWH electricity produced: #{usage_today[:total_kwh_produced_high] + usage_today[:total_kwh_produced_low]}</p>" +
|
"<p>Total kWH electricity produced: #{usage_today[:total_kwh_produced_high] + usage_today[:total_kwh_produced_low]}</p>" +
|
||||||
"<p>Total m3 gas consumed: #{usage_today[:total_m3_gas_consumed]}</p>"
|
"<p>Total m3 gas consumed: #{usage_today[:total_m3_gas_consumed]}</p>" +
|
||||||
|
"</br>" +
|
||||||
|
"<p>kWH cost (Oxxio): EUR #{ oxxio_cost} </p>" +
|
||||||
|
"<p>kWH cost (EasyEnergy): EUR #{ easy_cost} </p>"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -118,8 +118,10 @@ class Cost
|
|||||||
title = "Verbruikskosten (incl. belastingen en BTW) - %s" % date.strftime("%A, %e %B %Y")
|
title = "Verbruikskosten (incl. belastingen en BTW) - %s" % date.strftime("%A, %e %B %Y")
|
||||||
xlabel = "uur"
|
xlabel = "uur"
|
||||||
ylabel = "EUR"
|
ylabel = "EUR"
|
||||||
GR.savefig("easy_cost_%s.png" % date.strftime("%F"), title: title, xlabel: xlabel, ylabel: ylabel)
|
GR.savefig("plots/easy_cost_%s.png" % date.strftime("%F"), title: title, xlabel: xlabel, ylabel: ylabel)
|
||||||
|
|
||||||
|
# return the sum cost
|
||||||
|
costs.sum
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user