Different retention times with Recorder?

Hi,
I’ve seen people asking this question in 2019, 2020 and 2021, but I hope things have progressed since then.

I’d like to keep different retention times for different entities, for example:

  • some entities have retention time of 1 day
  • some (limited number) entities have retention time of 6 months
  • the rest should keep the default of 10 days.

Is it possible to do this with the recorder?

Thanks

1 Like

No.

You can vote for this here: Recorder Retention Period By Entity

1 Like

Thanks – will send the vote. :frowning: Unfortunately, sometimes it makes sense to keep some data much longer than others in order to analyze performance of systems (I talk about controlling central heating, etc).

Sure.
Most people needing detailed analysis use InfluxDB + Grafana for this.
Most HA users are happy with long-term statistics (aggregated data that never expires), nowadays.

Most HA users are happy with long-term statistics (aggregated data that never expires), nowadays.

The long-term statistics is also a challenge, e.g. the apexcharts do not display this long term data. It would actually work for me if I could simply integrate it into the existing UI. Any ideas how to do it?

I’m pretty sure they do as I triggered their addition :wink:

Unfortunately, if I add the ‘statistics’ section, there is nothing displayed and the current value of the series shows as N/A (code and screenshots before and after below)

type: custom:apexcharts-card
graph_span: 10d
hours_12: false
yaxis:
  - min: 0
    max: ~1800.0
    decimals: 0
    apex_config:
      tickAmount: 9
show:
  last_updated: true
header:
  show: true
  title: Olje v cisterni
  show_states: true
  colorize_states: true
  floating: false
now:
  show: true
  color: red
  label: now
series:
  - entity: sensor.volumen_olja_v_cisterni
    name: Volumen olja v cisterni
    type: line
    stroke_width: 1
    color: black
    float_precision: 0
    statistics:
      period: hour
    show:
      legend_value: false
      extremas: true

image
image

Then maybe your sensor does not meet the requirements for long-term statistics to be generated for it.

See:

It does have the long term statistics if I go deeper into the HA native graphs…

Maybe try

    statistics:
      type: mean
      period: hour

works for me

Thanks, but just tried it → same result…

Can you post the yaml config to see if you are doing something else differently?

apexcharts_card_templates:
  grafana:
    apex_config:
      chart:
        background: '#141619'
        height: 400px
        toolbar:
          show: true
          tools:
            zoom: true
            zoomin: true
            zoomout: true
            pan: true
            reset: true
        zoom:
          enabled: true
    color_list:
      - orange
      - '#64a45c'
      - '#ab80c3'
      - '#2e65ba'
      - '#d3bd27'
      - '#a71728'
    graph_span: 7d
    header:
      show: true
      show_states: false
    all_series_config:
      stroke_width: 2
      float_precision: 1
      type: line
      extend_to: end
views:
  - title: Home
    type: custom:grid-layout
    layout:
      grid-template-columns: 50% 50%
      grid-template-rows: auto
    cards:
      - type: custom:history-explorer-card
        cardName: historycard-54968857
        showCurrentValues: true
        graphs:
          - type: line
            entities:
              - entity: sensor.temperature_humidity_sensor_49e0_temperature_2
        uiLayout:
          toolbar: top
          selector: hide
        view_layout:
          grid-column-start: span 2
      - type: custom:apexcharts-card
        config_templates: grafana
        graph_span: 30d
        header:
          title: Températures
        series:
          - entity: sensor.temperature_humidity_sensor_49e0_temperature_2
            statistics:
              type: mean
              period: hour
        view_layout:
          grid-column-start: span 2

Thanks … at first glance I see no (impacting) difference but let me go in detail through.

Ok, @koying, you were right way up in one of the the first posts. The state class of the entity was set to “total” instead of “measurement”. If the device class is “volume” then the state class cannot be set to “measurement” (it must be “total” or “total increasing”).

Once I removed the device class value (I simply left it empty), I set the state class to “measurement” and now the statistics in apexcharts works…

Oh, well… Why the device class “volume” cannot be of state class “measurement” I have not idea. The unit is still in litres so it shows properly and it seems to work now.

Thanks for your help.