Statistic Card


The Statistic card allows you to display a statistical value for an entity.

Statistics are gathered every 5 minutes for sensors that support it. It will either keep the min, max and mean of a sensors value for a specific period, or the sum for a metered entity.

If your sensor doesn’t work with statistics, check this.

Screenshot of the statistic card for a temperature sensor Screenshot of the statistic card for a temperature sensor.

To add the Statistic card to your user interface, click the menu (three dots at the top right of the screen) and then Edit Dashboard. Click the “Add Card” button in the bottom right corner and select Statistic from the card picker. All options for this card can be configured via the user interface, but if you want more options for the period, you will have to define them in yaml.

Configuration Variables

type string Required

statistic

entity string Required

A entity ID of a sensor with statistics, or an external statistic id

stat_type string Required

The statistics types to render. min, max, mean, change

name string (Optional, default: Entity name.)

Name of entity.

icon string (Optional)

Overwrites icon.

unit string (Optional)

Unit of measurement given to data.

Default:

Unit of measurement given by entity.

period map Required

The period to use for the calculation. See below.

theme string (Optional)

Override the used theme for this card with any loaded theme. For more information about themes, see the frontend documentation.

footer map (Optional)

Footer widget to render. See footer documentation.

Example

Alternatively, the card can be configured using YAML:

type: statistic
entity: sensor.energy_consumption
period:
  calendar:
    period: month
stat_type: change

Options For Period

Periods can be configured in 3 different ways:

Calendar

Use a fixed period with an offset from the current period.

Configuration Variables

period string Required

The period to use. day, week, month, year

offset integer (Optional)

The offset of the current period, so 0 means the current period, -1 is the previous period.

Example, the change of the energy consumption during last month:

type: statistic
entity: sensor.energy_consumption
period:
  calendar:
    period: month
    offset: -1
stat_type: change

Fixed period

Specify a fixed period, the start and end are optional.

Configuration Variables

start string (Optional)

The start of the period

end string (Optional)

The end of the period

Example, the change in 2022:

type: statistic
entity: sensor.energy_consumption
period:
  fixed_period:
    start: 2022-01-01
    end: 2022-12-31
stat_type: change

Example, all time change, without a start or end:

type: statistic
entity: sensor.energy_consumption
period:
  fixed_period:
stat_type: change

Rolling Window

Configuration Variables

duration map Required

The duration of the period

offset map (Optional)

The offset of the current time, 0 means the current period, -1 is the previous period.

Example, a period of 1 hour, 10 minutes and 5 seconds ending 2 hours, 20 minutes and 10 seconds before now:

type: statistic
entity: sensor.energy_consumption
period:
  rolling_window:
    duration:
      hours: 1
      minutes: 10
      seconds: 5
    offset:
      hours: -2
      minutes: -20
      seconds: -10
stat_type: change