Hi,
I want to present the electrical cost for today, this month and this year using data from the Energy statistics. However, my templates render unexpectedly and I cannot really find out why.
I fetch the consumption data for the day:
- platform: sql
db_url: !secret recorder_db_entry
queries:
- name: electric_energy_startofday
query: "SELECT state FROM statistics WHERE metadata_id=103 AND start>=CURDATE() AND state <> 'unknown' ORDER BY id ASC LIMIT 1;"
column: 'state'
The state of electric_energy_startofday is as expected:
72118.6899414062
The state of the current energy reading (sensor.electric_mains_energy_consumption) is also as expected:
72124.5500488281
I have made an template to calculate the difference
- platform: template
sensors:
electric_meter_consumption_today:
value_template: >
{{ (states("sensor.electric_mains_energy_consumption")|float) - (states("sensor.electric_energy_startofday")|float) }}
I expect the electric_meter_consumption_today to contain the difference between the two values. However, it contains:
#5.8779296875873115 5.8779296875873115
What am I missing…? Thankful for support!