Hello,
I would like to track some energy usage for my heating system.
What I have right now:
Heater is controlled by a generic thermostat, let’s call it climate.thermostat
here, this part works well without issue.
This thermostat is using a basic switch to drive the heater, switch.heater
.
I know that my heater itself is drawing 2kW when it’s running.
From that, I think there is enough information to create a sensor using configuration.yaml that would be at 2000W when switch.heater is on (and then the heater is heating), and 0W when switch.heater is off, and from there, derive another sensor that would aggregate the daily energy used by the heater, that i would be able to plug into the Energy panel of HA.
(Why i don’t want to use a shelly1pm or something like that to measure power consumption precisely? Well, if I can achieve the same result using a few lines of yaml, that’s about the same, and less intrusive right?)
template:
- sensor:
- name: heating_power
state_class: measurement
unit_of_measurement: "W"
device_class: energy
state: >
{% if states('switch.heater') | state == 'on') }
{{ 2000 | float }}
{% else %}
{{ 0 | float }}
{% endif %}
- name: heating_daily_energy
state_class: measurement
unit_of_measurement: "kWh"
device_class: energy
[...]
I am failing to create those sensors so far. From what I understand, to be able to plug them into the Energy dashboard, the state_class, and device_class attributes must be set.
Thanks. R