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: stateAutomatic formatting can be switched off for individual columns.
yaml
columns:
- name: Min.
data: min_temp
suffix: " °C"
no_auto_format: truePrefix, 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: rightFormat helper
fmt uses built-in formatters.
| Format | Purpose |
|---|---|
number | Convert value to number |
duration | Show seconds as time duration |
duration_h | show longer duration with days |
icon | Show MDI icon |
full_datetime | Convert date string to timestamp |
hours_passed | past hours since date |
hours_mins_passed | past hours and minutes |
time_passed | past time with rough readability |
yaml
columns:
- name: Batterie
data: state
fmt: number
suffix: "%"
align: rightModify
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.
