The template sensor should create a sensor that reports the current operational state, obtained from the climate entity of the thermostat. In the corrected configuration below that entity_id: will be sensor.test
The hvac_modes
attribute of the climate entity only contains a list of supported operation modes, not the current operating state of the thermostat. Check for the existence of the attribute hvac_action
and see what changes to when the thermostat calls for heat. Not all thermostat integrations may support hvac_action
or properly update the status.
The history_stats sensor looks at sensor.test
and measures the time its state is heat
.
- platform: template
sensors:
test:
friendly_name: test_test
icon_template: mdi:radiator
value_template: "{{ state_attr('climate.salon' , 'hvac_action' )}}"
- platform: history_stats
name: "duree_de_chauffe"
entity_id: sensor.test
state: "heating"
type: time
# end today at 00:00:00
end: "{{ now().replace(hour=0, minute=0, second=0, microsecond=0) }}"
duration:
hours: 24
Iâm not sure what time period you are wanting to look at. I think your history_stats sensor will give you yesterdayâs runtime, not todayâs.
To get the run time starting at midnight today, the interval resetting every midnightâŠ
start: "{{ now().replace(hour=0, minute=0, second=0, microsecond=0) }}"
end: "{{ now() }}"
To get the usage continuously over a rolling 24 hour period, use the below.
end: "{{ now() }}"
duration:
hours: 24