Hello,
I’m using the generic thermostat component and it’s working quite well.
But I’d like to retrieve the data of the state (heat or idle) to use it as a consumption monitor. My emitter is an electric heater that uses between 980 to 1020 W so I’d like to create a sensor that outputs 1000W every time the heater is turned on.
Can you help me with that ?
Thanks !
Ok, so I’ve got to this
sensor:
platform: template
sensors:
livingroom:
friendly_name: “HeaterPower”
unit_of_measurement: ‘W’
device_class: sensor
value_template: >-
{% if is_state(‘climate.salon’, ‘heat’) %}
1000
{% elif is_state(‘climate.salon’, ‘idle’)%}
0
{%- endif %}
I believe the state of a generic thermostat climate entity is ‘heat’ when it’s actively heating, and ‘idle’ or ‘off’ when not. So this should work:
sensor:
- platform: template
sensors:
heater_power:
friendly_name: Heater Power
value_template: >
{{ 1000 if is_state('climate.my_therm', 'heat')
else 0 }}
unit_of_measurement: watt
EDIT: Oops, got the test wrong. (I have a Nest and it works differently.) Anyway, adjusted accordingly.
1 Like
Close, but you should never have an if without an else. Especially in this case, because if the climate entity is off, your sensor won’t have a value.
1 Like
It worked !
And Yes I knew about the ‘off’ state but I was trying to get a value to begin with !
Would you know how to calculate the consumption based upon a template sensor ?
Thanks !
1 Like
nickrout
(Nick Rout)
February 2, 2019, 10:19pm
6
I think you’d start with this. https://www.home-assistant.io/components/sensor.history_stats/ once you know how long it has been on, the math is simple.