Skip to content

Style State Duration

tempus2016 edited this page Nov 21, 2026 · 2 revisions

Time in each state (vNEXT+)

How long each entity spent in each state, per hour, day, week or month, as stacked columns: hours of heating a day, time the dishwasher ran, days someone was away. It reads states the way the state timeline does and groups them the way the column chart does.

Good for

A thermostat's hvac_action (heating, idle, off), a switch or a plug, a person's home and away, a washing machine's programme: anything whose states are words.

Example

type: custom:chartdeck-card
style: state_duration
title: Heating per day
entities:
  - entity: climate.hall
    attribute: hvac_action

To use this style, set style: state_duration (or pick Time in each state under History charts in the editor's Style section). The chart options are in the editor's Chart section.

Sensible defaults

  • Period: the last 7 days when period isn't set, as on the column chart.
  • Grouping (group_by: auto) picks a size for the span, as the column chart does: hours up to two days, days up to two months, then weeks, then months. Today is grouped by hour, a week or a month by day, and a year by month.
  • The value axis runs to the longest group: 24 hours a day (25 on the day the clocks go back), or 60 minutes an hour, with a line every 6 hours or 15 minutes.
  • Colours are the state timeline's: the theme's colour for the state where it has one, else a built-in one. Quiet states (off, idle, away and the like) are grey, each a little fainter than the one under it, with a thin line between slices so they stay apart.
  • Stack order: the busiest active state at the bottom, quiet states on top.
  • Unavailable and unknown are gaps, not slices. Today counts up to now.

Options

group_by: day            # auto (default), hour, day, week or month
stack: normal            # normal (default): hours, or minutes by hour; percent: share of the time recorded
states: [heating, idle]  # optional: which states to show, bottom first
labels: true             # the time on each slice with room for it (default false)
state_colors:            # your own colour for any state: palette name or CSS colour
  idle: green
  • stack: percent scales each column to 100 % of the time that was recorded, so a part-day today still reaches the top.
  • states shows only those states, in that order from the bottom. Other states are left out.
  • labels: true writes the time on each slice tall and wide enough for it.
  • state_colors wins over every other colour, as on the state timeline.
  • With several entities, each has its own column in every group.
  • Per entity, attribute reads one of its attributes instead of the state, such as a thermostat's hvac_action.
  • A sensor whose states are numbers is a measurement rather than states, and the chart says "Readings, not states: a line chart suits this one". With nothing recorded it says "No states recorded in this period."
  • States are only in the recorder's history, which long-term statistics don't keep, so source must be history.
  • A per-entity when hides the time its condition didn't hold.

Hovering or touching a column shows each entity's time in each state for that group. Tapping a column opens the entity's more-info dialog.

In the editor: the period options, Group readings by (with Automatic) and Stack, States to show, bottom first (empty: every state), Show values on the columns, the axes and layout options, and a State colours list where you add a state and its colour.

Everything else

The period, calendar spans and previous and next buttons are the same as on the line chart. See Line.

Layout: one chart for the whole card. Every shared option is described on the Options page.

Previous: Duration curve · All styles

Clone this wiki locally