Skip to content

Formatting ​

Automatic formatting ​

With auto_format: true, the card uses home assistant formatting such as unit and precision.

yaml
type: custom:flex-table-card
title: Temperatur
entities:
  include: sensor.outdoor_sensor_air_temperature
auto_format: true
columns:
  - name: Temperatur
    data: state

Automatic formatting can be switched off for individual columns.

yaml
columns:
  - name: Min.
    data: min_temp
    suffix: " °C"
    no_auto_format: true

Prefix, suffix and alignment ​

yaml
type: custom:flex-table-card
title: Verbrauch
entities:
  include: sensor.*_energy*
sort_by: power-
columns:
  - name: Name
    data: name
  - name: Leistung
    id: power
    data: power_consumption
    modify: parseFloat(x)
    suffix: " W"
    align: right
  - name: Energie
    data: state
    modify: parseFloat(x).toFixed(1)
    suffix: " kWh"
    align: right

Format helper ​

fmt uses built-in formatters.

FormatPurpose
numberConvert value to number
durationShow seconds as time duration
duration_hshow longer duration with days
iconShow MDI icon
full_datetimeConvert date string to timestamp
hours_passedpast hours since date
hours_mins_passedpast hours and minutes
time_passedpast time with rough readability
yaml
columns:
  - name: Batterie
    data: state
    fmt: number
    suffix: "%"
    align: right

Modify ​

modify is JavaScript and gets the read cell value as x.

yaml
columns:
  - name: Richtung
    data: sendungsinfo.sendungsrichtung
    modify: x == "ANKOMMEND" ? "zu mir" : "von mir"

safety

modify executes JavaScript. Only use it with data whose source you trust.