core: Unexpected statistics state after upgrade to 2022.2.0

The problem

After upgrading to 2022.2.0, all my statistics sensors report an unexpected state. This is a screenshot of one of them:

imatge

I didn’t change anything from my configuration before nor after upgrading.

What version of Home Assistant Core has the issue?

2022.2.0

What was the last working version of Home Assistant Core?

2021.12.10

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Statistics

Link to integration documentation on our website

https://www.home-assistant.io/integrations/statistics/

Example YAML snippet

- platform: statistics
  name: Temperatura
  entity_id: sensor.temperatura
  state_characteristic: average_linear
  sampling_size: 10000
  precision: 1
  scan_interval: 1800
  max_age:
    days: 1

Anything in the logs that might be useful for us?

<Nothing relevant in logs>

Additional information

Attributes from statistics sensor:

imatge

Buffer seems nearly empty, while referenced entity sensor.temperatura is recorded correctly:

imatge

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (3 by maintainers)

Most upvoted comments

Confirmed! It is an issue with min_max platform. I changed this:

  - platform: min_max
    name: Temperatura
    type: mean
    round_digits: 1
    entity_ids:
      - sensor.temperature_1
      - sensor.temperature_2

By this:

  - platform: template
    sensors:
      temperatura:
        friendly_name: "Temperatura"
        unit_of_measurement: "°C"
        value_template: "{{ (
                              ( states('sensor.temperature_1')|float(default='0') +
                              states('sensor.temperature_2')|float(default='0')
                              ) / 2
                            )|float(default='0') }}"
        availability_template: "{{ not (
                                    is_state('sensor.temperature_1','unavailable') or
                                    is_state('sensor.temperature_1','unknown') or
                                    is_state('sensor.temperature_2','unavailable') or
                                    is_state('sensor.temperature_2','unknown')
                                    ) }}"

And now statistics sensor is not breaking at restart.

No. I restarted with this configuration and the behaviour is the same:

- platform: statistics
  name: Temperatura 
  entity_id: sensor.temperatura
  state_characteristic: average_linear
  sampling_size: 10000
  precision: 1
  # scan_interval: 1800
  max_age:
    days: 1

imatge