Skip to content

Badges ​

A badge is a small pill that shows one more value on a card: another entity, an attribute, or a text of your own. It takes its own colour from the entity's kind, can draw a ring, a bar or a sparkline, and takes its own taps.

Where badges sit ​

badges lists the badges in order. Each one is an entity id, or an object with the badge keys. On a poster they are a column in the top right corner, floating over the picture. On a tile they sit at the end of the first row, beside the name and centred on the icon (on a vertical tile, in a row above the icon); the name gives way, the badges always show in full.

Edit

The same badges, written the same way, go in more places:

On a tile and a poster a badge is an outline pill by default. In a header it is plain and small, so it reads as part of the title line. The heading card has its own defaults for all its badges (badge_style, badge_size). A badge's own style and size always win.

What a badge shows ​

A badge's pill holds, in this order, its icon, its name, its value, a visual and a switch. Most badges need only the first and the value.

The icon ​

icon is the badge's icon place:

  • an icon's name (mdi:…, or a template);
  • { type: image }: the entity's picture, or src for another (an image URL, a template or an entity);
  • { type: dot }: a dot in the badge's colour;
  • { ring: true }: a ring of the value around the icon or the picture, from min to max; { ring: sensor.phone_battery } or { ring: { entity, attribute, min, max, color } } rings another entity's value;
  • false: no icon.

show_name: true writes the name before the value. show_value: false shows the icon alone.

The visual after the value ​

visual draws something small after the value:

  • bar: the value as a short bar, from min to max;
  • sparkline: the history of the last 24 hours;
  • trend: how much the value changed over the last hour.

{ type: sparkline, hours: 6 } gives a sparkline or a trend its own window; hours: today starts at midnight.

Format and staleness ​

format writes the value another way: power switches between W, kW and MW, duration writes a time span (1h 12m), clock writes it as a clock (1:12:00), and relative writes a date as its time from now (in 38 minutes). A timer's badge counts its time left down by itself, as a clock; duration and clock count down to a date too (a timestamp sensor), every second. stale_after greys a badge whose entity has not reported for that long and adds how long ago it did. It takes minutes, or a number with s, min, h or d.

Edit

Colour, rules and style ​

The entity's kind ​

A badge takes its entity's kind, but only its colours: a battery red when it runs low, carbon dioxide by its bands, a light in its own colour, a thermostat warm while it heats. A kind that calls for attention makes the badge pulse, such as a jammed lock or hazardous air. The value stays the value; the kind's words belong to the card's status. The kind's thresholds read the entity's state: a badge showing an attribute or a value of its own takes only the kind's colour.

kind names a kind for an entity the card cannot tell, such as kind: battery on a sensor without a device class. kind: none leaves the kind out; Home Assistant's own state colour stays.

Rules ​

rules work as on the card itself: the first rule that matches its state, above or below wins, on the badge's value or on an attribute the rule names (a thermostat's hvac_action beside its temperature). A rule sets the badge's color and icon, and value writes a text in place of the value. It can also change the pill (style) and make it pulse (pulse: true). The badge's own color and icon are defaults: a matching rule's win. A badge with rules takes none of its kind's.

Styles and sizes ​

style sets the pill: outline (Home Assistant's badge), soft (a tint of the badge's colour, its text in the colour), filled (the badge's colour), plain (only the icon and the value) or tag (an outline and text in the badge's colour). size sets its height: s, m or l.

Edit

Switches, taps and visibility ​

control: toggle puts a switch at the end of a badge: a round button with the power icon, grey while off and filled in the badge's colour while on. It is the one control a badge holds; the badge itself keeps its own tap.

A badge takes its own taps. tap_action, hold_action and double_tap_action act on the badge's entity, as described in Actions & hover. Without them a badge takes the card's actions on its own entity: more-info by default.

visibility shows a badge only while its conditions hold, written as in Visibility. A hidden badge takes no room.

Edit

Badges reading the card's own entity ​

On a tile and a poster, a badge without entity reads the card's entity. attribute shows one of its attributes, with its unit. A badge with neither shows the card's value again, for example in a ring. On a card without an entity, a badge needs an entity or a value.

Edit

The status badge ​

A card's status (Heating, Low, Locked …) can be a badge too. On a poster it always is: the first badge in the corner, before yours. On a tile the status sits on the line after the value; status_badge: true makes it the first badge instead. Either way it looks like the card: a tag in the card's colour, without an icon or a name. A rule's style and pulse apply to it.

status sets its text (a text or a template), and status: false drops it.

Edit

The tile's icon badge ​

A tile's icon carries a small badge of its own, as on Home Assistant's tile: what a thermostat or a humidifier is doing (in its colour), a person's zone, an orange mark when the entity is unavailable. It takes no room. icon: { badge: false } turns it off, and icon: { badge: { icon, color } } sets one of your own; both take a template, and an icon that renders empty shows nothing. A rule can set it too while it matches.

Edit

Reference ​

Badge keys ​

A badge is an entity id, or an object with these keys. Every key is optional.

KeyDefaultDescription
entitythe card's (tile, poster)The entity it shows. In a header, a badge needs an entity or a value.
attribute–One of the entity's attributes in place of its state.
valuethe entity's stateA text or a template of your own.
namethe entity's nameThe name, shown with show_name: true. A text, or its parts as Home Assistant composes it: [{ type: entity }].
unitthe entity's unitThe unit after the value.
decimalsthe entity'sDecimal places of the value.
prefix, suffix–Text before and after the value.
min, maxthe entity's, else 0 / 100The range of a ring and a bar.
show_namefalseWrite the name before the value.
show_valuetruefalse: the icon alone.
iconthe entity's iconAn icon's name, { type: icon | image | dot, name, ring, src }, or false. ring is true or another entity (see Look).
visual–After the value: bar, sparkline or trend; { type, hours } for another window (hours a number or today).
colorthe kind'sThe badge's colour; a matching rule's wins. A template is allowed.
kindthe entity'sThe kind whose colours it takes; none for none.
rulesthe kind'sstate, above or below, and an optional attribute, setting color, icon, value (a text in place of the value), style and pulse. First match wins.
stylesee belowoutline, soft, filled, plain or tag.
sizesee belows, m or l (24, 30 or 36 px high).
formatautoauto (a timer: its time left as a clock), power (W / kW / MW), duration, clock or relative.
stale_after–Grey, with its age, when the entity has not reported for this long: minutes, or 90s, 30min, 2h, 1d.
control–toggle: a switch at the badge's end, a round power button.
tap_action …the card'stap_action, hold_action, double_tap_action, on the badge's own entity.
hoverthe card'sShow Home Assistant's hover and press layers on the badge.
visibility–Conditions; a hidden badge takes no room.

Defaults by place ​

Wherestylesize
Poster, tileoutlines
Headers: tile group, weather, power flow, energy flowplains
Heading cardbadge_style (outline)badge_size (m)
The status badge (poster, tile)tags

Card options ​

KeyCardDefaultDescription
badgesall above–The badges, in order (on a poster and a tile after the status badge).
statustile, posterthe kind'sThe status: a text, a template, or false.
status_badgetilefalsetrue: the status as the first badge, in place of on the line. A poster's status is always a badge.
icon.badgetileautoThe badge on the icon: auto (Home Assistant's), false, or { icon, color }. A rule may set it too.

Old badge keys (visual: ring, show_icon, a rule's label …) give an error naming the key to use; see Moving to 3.0.

Released under the MIT License.