Entity not being recorded. But I want statistics!

I would like to have statistics of sensor.battery_1_charge_discharge_power, but for some reason, the Statistics tab for this entity says it is excluded from being recorded.

So looking at my recorder config, I can’t seem to find anything wrong. Any suggestions? Is my database corrupt?

# Recorder for database housekeeping
recorder:
  purge_keep_days: 7
  exclude:
    domains:
      - automation
      - update
      - device_tracker
      - light
      - weather
      - zone
      - media_player
      - person
    entity_globs:
      - sensor.past*
      - sensor.btc*
      - sensor.eth*
      - sensor.ada*
      - sensor.link*
      - sensor.crypto*
      - sensor.weather*
      - sensor.afvalwijzer*
      - sensor.*to_home*
      - sensor.distance*
      - sensor.hp*
      - sensor.disk*
      - sensor.lights_on*
      - sensor.memory*
      - sensor.moon*
      - sensor.moto*
      - sensor.*walikerplein*
      - sensor.*siriusstraat*
      - sensor.otto* # Otto lawn mower
      - sensor.*luminance*
      - sensor.pihole*
      - sensor.shellydimmer*
      - sensor.shellyplug*
      - sensor.192_168_* # Glances sensors
      - sensor.stolte* # Zaptec sensors
      - binary_sensor.434090544249000057* # Wasdroger binary sensors
      - sensor.434090544249000057 # Wasdroger sensors
      - sensor.homeconnect_status # Bosch Home Connect
      - sensor.logger* # Huawei data logger
      - sensor.meter* # Huawei meter
      - sensor.plum* # Plum ECOnet heat pump
      - binary_sensor.plum*
      - sensor.system* # Homeassistant hardware monitor
      - sensor.air_quality # Homeassistant air quality meter
      - sensor.alarm_control_panels # Homeassistant counter of alarm panels
      - sensor.areas # Homeassistant counter of areas
      - sensor.automations # Homeassistant counter of automations
    entities:
      - sun.sun

I even tried forcing the entity to be recorded by adding it as follows:

include:
  entity_globs:
    - sensor.battery_1*

But to no avail :frowning:

Your text shows battery_1 (underbar), your entity forced shows battery-1 (minus)

Thanks, you’re right and I corrected it. But still, it should not fail. Even with that include.

Since the proof the pudding is in the eating, I restarted with the corrected include entry. Same result:


Why does it keep telling it is not being recorded, while I explicitly stated it to be.

You’re restarting right? HA doesn’t support YAML reload for the recorder integration.

The reason is because the Statistics tab shows entities whose history is maintained in a special database table commonly referred to as “long-term statistics”. This table’s data is excluded from Recorder’s automatic purge cycles (purge_keep_days).

For an entity to be enrolled in long-term statistics, it must have a state_class option (not all integrations support it).

Which integration is responsible for creating sensor.battery_1_charge_discharge_power?

For example, if it’s a Template Sensor, the Template integration supports the use of state_class.

If it was created by an integration that doesn’t support the state_class option, you can try adding it the sensor using Manual Customization.

That did the trick. I reloaded only and never restarted.

1 Like