I set up some sensors to combine state for my thermostats. Now I want to see historical data on them. I’m having trouble having the history_stats sensors show up in Home Assistant. I don’t see any errors in the logs, and the YAML checker passes. Does it just take time for history_stats to appear?
configuration.yaml:
# Loads default set of integrations. Do not remove.
default_config:
# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
template: !include template.yaml
sensor: !include sensors.yaml
entity_controller: !include entitycontroller.yaml
template.yaml:
sensor:
- name: Upstairs Thermostat State
state: "{{ state_attr('climate.upstairs_thermostat', 'hvac_action') }}"
- name: Downstairs Thermostat State
state: "{{ state_attr('climate.downstairs_thermostat', 'hvac_action') }}"
- name: Overall Thermostat State
state: >
{% set hvac = [states('sensor.upstairs_thermostat_state'), states('sensor.downstairs_thermostat_state')] %}
{% set num_heating = hvac | select('eq', 'heating') | list | count %}
{% set num_cooling = hvac | select('eq', 'cooling') | list | count %}
{% set num_idle = hvac | select('eq', 'idle') | list | count %}
{% if num_heating > 0 and num_cooling > 0 %}
mixed!
{% elif num_heating > 0 %}
heating
{% elif num_cooling > 0 %}
cooling
{% elif num_idle > 0 %}
idle
{% else %}
off
{% endif %}
sensors.yaml:
# HVAC Stats
- platform: history_stats
name: HVAC Heating Last 24 Hrs
entity_id: sensor.overall_thermostat_state
state: heating
type: time
end: "{{ now() }}"
duration:
hours: 24
- platform: history_stats
name: HVAC Cooling Last 24 Hrs
entity_id: sensor.overall_thermostat_state
state: cooling
type: time
end: "{{ now() }}"
duration:
hours: 24