diff --git a/app/helpers/ReadingsMailer.rb b/app/helpers/ReadingsMailer.rb index 05b48be..07ec11c 100644 --- a/app/helpers/ReadingsMailer.rb +++ b/app/helpers/ReadingsMailer.rb @@ -28,6 +28,9 @@ class ReadingsMailer c = Cost.new oxxio_cost = c.oxxio_energy_cost(date.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) # side effect: generates a PNG + # rounding + oxxio_cost = oxxio_cost.round(2) + easy_cost = easy_cost.round(2) mail = Mail.new do delivery_method :smtp, smtp_opts @@ -53,9 +56,13 @@ class ReadingsMailer "

Total kWH electricity produced: #{usage_today[:total_kwh_produced_high] + usage_today[:total_kwh_produced_low]}

" + "

Total m3 gas consumed: #{usage_today[:total_m3_gas_consumed]}

" + "
" + - "

kWH cost (Oxxio): EUR #{ oxxio_cost}

" + - "

kWH cost (EasyEnergy): EUR #{ easy_cost}

" - end + "

kWH cost (Oxxio): EUR #{ oxxio_cost}

" + + "

kWH cost (EasyEnergy): EUR #{ easy_cost}

" + end + + # add attachment + filename = "easy_cost_%s.png" % date.strftime("%F") + add_file :filename => filename, :content => File.read("plots/%s" % filename) end mail.deliver!