Ok, so maybe I’m blind, or misunderstanding something, but I’m having an issue with a history_stats sensor. Maybe someone can help.
Background:
I’m trying to break out the hvac_action attribute of the hive system, so I can then create an automation to track if the heating has been on in the last 12 hours. This is to aid me in the mornings, when I’m a zombie, to know if I should use the electric shower, or if there’s sufficient hot water. (Note, when heating is active, the system also heats my water.) The automation will cause my bathroom light to change colour or flash, when there’s hot water, so I don’t need to think, or check my phone. Remember, I’m a zombie in the morning!
Sensors:
The attributes I need are part of climate.upstairs, and climate.downstairs, and I’ve managed to break these out into their own sensors.
#
### Break out Hvac_action from hive climate sensor
#
downstairs_hvac:
friendly_name: Downstairs Hvac
value_template: '{{ state_attr("climate.downstairs", "hvac_action") }}'
#
upstairs_hvac:
friendly_name: Upstairs Hvac
value_template: '{{ state_attr("climate.upstairs", "hvac_action") }}'
All good so far.
The next step was to use the history_stats function to track those two sensors for 12 hours.
sensor:
# Keep track of how long the heating has been on.
- platform: history_stats
name: downstairs heating
entity_id: sensor.downstairs_hvac
state: "heating"
type: time
end: "{{ now() }}"
duration:
hours: 12
- platform: history_stats
name: upstairs heating
entity_id: sensor.upstairs_hvac
state: "heating"
type: time
end: "{{ now() }}"
duration:
hours: 12
I thought I was tracking the sensors successfully, but it’s become obvious that sensor.upstairs_heating is not working, while sensor.downstairs_heating is working as intended.
Can anyone help? What have I missed?