core: history_stats sensor displaying 'Unknown' after upgrading to 0.111.4

The problem

Upgraded from 0.109.6 to 0.111.4. I have a history_stats sensor that no longer works and just displays ‘Unknown’.

Environment

arch | armv7l dev | false docker | false hassio | false installation_type | Home Assistant Core os_name | Linux os_version | 4.19.97-v7+ python_version | 3.7.3 timezone | America/Chicago version | 0.111.4 virtualenv | true

database: postgres 11.7

  • Home Assistant Core release with the issue: 0.111.0
  • Last working Home Assistant Core release (if known): 0.110.7
  • Operating environment (OS/Container/Supervised/Core): Core
  • Integration causing this issue: history_stats
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/history_stats/

Problem-relevant configuration.yaml

Config for the sensor that’s NOT working:

sensor:
  - platform: history_stats
    name: HVAC On Last 24 Hrs Percentage
    entity_id: sensor.hvac_running
    state: 'on'
    type: ratio
    end: '{{ now() }}'
    duration:
      hours: 24
    scan_interval: 900

  - platform: template
    sensors:
      hvac_running:
        # Set to on if HVAC is running (cooling or heating); off otherwise
        friendly_name: "HVAC Running"
        value_template: "{% if is_state('sensor.kitchen_thermostat_hvac_state', 'off') %}off{% else %}on{% endif %}"

recorder:
  db_url: postgres://@/homeassistant
  auto_purge: False

I also have another very similar history_stats sensor that IS working. Here’s that config:

sensor:
  - platform: history_stats
    name: Humidifier On Last 24 Hrs Percentage
    entity_id: binary_sensor.humidifier_state
    state: 'on'
    type: ratio
    end: '{{ now() }}'
    duration:
      hours: 24
    scan_interval: 900

binary_sensor:
  - platform: command_line
    name: 'Humidifier State'
    command: '/usr/bin/php /home/homeassistant/custom/sensors/humidifier_state_sensor.php'
    scan_interval: 300

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 21 (20 by maintainers)

Most upvoted comments

Ok, I guess I’ll remove the hidden attribute then. Thank you for your help figuring this out!