Long term statistics 'max' value not available?

Hi,

I’m trying to create a (long term statistics ) chart that shows my daily ‘water-usage’. I’ve configured the template sensor the following way :

template:
    - name: "water_usage"
      unit_of_measurement: L
      device_class: aqi
      state_class: total_increasing
      state: >
        {{ states ('counter.watermeter_liters') }}

I expect the long term statistics to capture : Min, Max, Mean, Sum values of the specific sensor.
But when configuring the long term statistics chart, only the ‘sum’ value is available, while I need the ‘max’ value.
What am I doing wrong here, why is there no max value available? And what are the possibilities to achieve this instead?

( i’ve used device class aqi, since there is no device class for volumetric(water) entities unfortunately… )

I’m trying to do the exact same thing and got confused as well.

I’ve been using the custom:mini-graph-card with group-by feature to achieve this for a while, but this is slow to display with large data sets, not so easy to set up, and limited in time by the history length.

I was hoping the long term statistics was intended to solve this, but I can’t figure out how the state_class: total_increasing is expected to be used.

1 Like

There is a workaround for this:

Create helper of the utility meter type that daily resets. Then use this utility meter in the statistics card with the ‘hidden’ stat type: ‘state’ (you can only configure it in yaml).

This is the statistics graph card yamI use for this use case:

chart_type: bar
period: day
days_to_show: 30
type: statistics-graph
entities:
  - sensor.waterverbruik_per_dag
title: Water verbruik
stat_types:
  - state

1 Like

A max value in long-term statistics doesn’t make any sense for a constantly increasing value, as it would be the same as the state/sum.
So that is why max/min/avg are not in the statistics table for this entity.

I also found the statistics-card very unsatisfying.
Maybe you are better of with the apex-charts integration.

You can find some inspiration here: