Data and Cells
What the cells show: generated values in decorative mode, or the rows you write in data mode. How the cells look is on Styling and Animation.
Decorative mode
A decorative grid fills itself with generated values: digits, decimals, letters or hex codes. Use it for LCARS texture: a panel of numbers, a background behind other cards.
- The grid size comes from the CSS Grid templates in
grid:repeat(5, auto)rows andrepeat(8, 1fr)columns give a 5 by 8 grid. Without templates the grid is 8 rows by 12 columns. - With
refresh_intervalthe values change on a timer; a smallrefresh_cellschanges only a few cells each time, which looks like data trickling in. columnsgives one column, by position, a format of its own.
# hex values, a few changing every 1.5 seconds; the first two columns are digits
type: custom:lcards-data-grid
data_mode: decorative
format: hex
refresh_interval: 1500
refresh_cells: 0.15
grid:
grid-template-rows: repeat(5, auto)
grid-template-columns: repeat(8, 1fr)
gap: 0px
columns:
- format: digit
- format: digit
style:
font_size: 20px
color: var(--lcars-orange)
highlight_changes:
preset: pulse
duration: 400More about decorative mode
- Card picker: values don't change (and the cascade doesn't run) in the card picker preview, so the picker stays calm. The card editor's preview does animate.
- Refreshing few cells: each refresh changes at least one cell, so
refresh_cells: 0with arefresh_intervalstill changes one cell at a time. - Grid size:
repeat(auto-fill, ...)and other track lists without a fixed count fall back to 8 rows or 12 columns. - Highlighting: with highlight_changes the cells that changed animate briefly, as in the example.
| Key | Type | Default | Description |
|---|---|---|---|
format | string | mixed | digit (0042), float (42.17), alpha (AB), hex (A3F1), or mixed (any of the four, picked per cell) |
refresh_interval | number | 0 | New values every this many milliseconds. 0 keeps them fixed |
refresh_cells | number | 1 | How much of the grid changes on each refresh, 0 to 1: 1 is every cell, 0.2 a fifth of them |
columns[].format | string | format | A different format for one column, by position |
grid.grid-template-rows | string | repeat(8, auto) | The number of rows (and their heights): see Grid layout |
grid.grid-template-columns | string | repeat(12, 1fr) | The number of columns (and their widths) |
rows
In data mode you write the grid row by row: each row is a list of cells, and the card works out what each cell is. A row can also be written as an object with values, to give it options.
- Rows can have different lengths; the grid is as wide as the longest row, and shorter rows end in empty cells.
header: truemakes a row a header row;stylestyles the whole row (see Style layers).
type: custom:lcards-data-grid
data_mode: data
rows:
# a row with options
- values: [Room, Temperature, Humidity]
header: true
# plain rows
- [Living room, sensor.living_room_temperature, sensor.living_room_humidity]
- [Outside, sensor.outdoor_temperature, sensor.outdoor_humidity]
grid:
grid-template-columns: 1fr 1fr 1fr
style:
font_size: 18pxMore about rows
- No rows: a data grid with an empty
rowslist shows "Data mode needs at least one row". Withoutdata_mode, an emptyrowsmakes a decorative grid. - Other shapes: an entry that is neither a list nor an object with
valuesbecomes an empty row.
| Key | Type | Default | Description |
|---|---|---|---|
rows | list | - | The rows, top to bottom. Each is a list of cells, or an object with the keys below |
rows[].values | list | required | The row's cells, left to right |
rows[].header | boolean | false | A header row: header defaults plus header_style |
rows[].style | object | - | Style for every cell in this row: the style keys |
What a cell can be
A cell shows text, an entity's state, a template or a data source value, and the card works out which from what you write. Cells update by themselves when their entity, template or data source changes.
- Put templates in quotes in YAML:
"{{ ... }}". An entity id or plain text needs no quotes. - A JavaScript template does not know which entities it reads, so list them in
triggers_updatefor it to update.
| You write | The cell shows |
|---|---|
Living room | The text as written |
sensor.living_room_temperature | The entity's state, formatted by Home Assistant with its unit (21.4 °C, Open, On) |
"{{ states('sensor.x') }} W" | A Home Assistant template (Jinja2), rendered by Home Assistant |
"{datasource:net_tx:.1f} MB/s" | A value from an LCARdS data source. With a format (:.1f) you get the number only; without one, the value with its unit |
"[[[ return states['sensor.x'].state ]]]" | A JavaScript template |
type: custom:lcards-data-grid
data_mode: data
rows:
# text, then an entity state
- [Inside, sensor.living_room_temperature]
# text, then a Home Assistant template
- [Comfort, "{{ 'WARM' if states('sensor.living_room_temperature') | float > 22 else 'OK' }}"]
- [Battery, "{{ states('sensor.phone_battery') | int }}%"]
grid:
grid-template-columns: 1fr 1fr
style:
font_size: 20pxMore about cell values
- Entity ids: a cell is read as an entity id when it is all lower case: a domain, a dot and an object id (
sensor.cpu_temp). Anything else is text. - Missing entities: an entity Home Assistant doesn't know shows
-. - Braces mean a template: any text with
{or[[[in it is treated as a template, so a literal brace in plain text is read as one too. - Numbers: a number cell shows as written.
- JavaScript templates: in a cell object with an
entity,entityin a JavaScript template is that entity; otherwise it is the card's own. Read other entities throughstates['sensor.x'](orhass.states).
Cell objects
Write a cell as an object to show an attribute, style one cell, or give it an entity for colours and actions. Plain cells and cell objects mix freely in a row.
- Without
value, the cell shows itsentity's state, or theattributeof it. - With a template or text in
value,entityis the context: the entity that conditional colours and tap actions follow, and the one{entity.state},{entity.name}and{entity.attributes.NAME}in the value read.
type: custom:lcards-data-grid
data_mode: data
rows:
# an attribute of an entity
- - Outside
- entity: weather.home
attribute: temperature
# one cell styled on its own
- - Battery
- value: sensor.phone_battery
style:
color: var(--lcars-yellow)
grid:
grid-template-columns: 1fr 1fr
style:
font_size: 20px| Key | Type | Default | Description |
|---|---|---|---|
value | string / number | - | What the cell shows: text, an entity id or a template |
entity | string | the value, when that is an entity id | Show this entity's state when value is empty, and use it for conditional colours and actions |
attribute | string | - | Show this attribute of entity instead of its state |
style | object | - | Style for this cell only: see Style layers |
tap_action | action | - | What tapping the cell does: see Tap actions |
hold_action | action | - | What holding the cell does |
double_tap_action | action | - | What double-tapping the cell does |
Rows from Home Assistant
A row with a target repeats once for every entity a Home Assistant label, area, device or floor includes, so the grid lists what you label in Home Assistant. Write the row once with {entity...} tokens; each copy reads its own entity.
targetis Home Assistant's target object:label_id,area_id,device_id,floor_id,entity_id, each one id or a list. A label counts on the entity, its device or its area.- In the row's
values,{entity}alone is the entity's state, formatted like an entity cell. In a template,{entity.state},{entity.name}(its name) and{entity.attributes.NAME}read that row's entity. - The copies take the row's place, so header rows above and rows below stay where they are.
styleapplies to every copy. sortorders the copies:name(default),state(numbers low to high, then text) ornone.max_itemskeeps the first ones.- The rows follow Home Assistant: a label added or removed adds or removes a row, and a state change moves a row when
sort: state.
type: custom:lcards-data-grid
data_mode: data
rows:
- values: [System, Level]
header: true
# one row for each entity with the label
- target:
label_id: lcards_test_engine
values:
- "{entity.name}"
- "{entity}"
sort: state
grid:
grid-template-columns: 2fr 1fr
style:
font_size: 18pxMore about rows from Home Assistant
- Which entities: hidden entities and configuration or diagnostic entities are left out unless named in
entity_id, as in Home Assistant's own sections. - No entities: a target that includes nothing adds no rows; the rest of the grid still shows.
- Cell objects: a cell object in the row gets the row's entity unless it names its own, so
{ attribute: battery_level }shows each entity's battery level. - Colours and taps: each copy's cells carry its entity, so conditional colours and
cell_tap_action(such asmore-info) follow it.
| Key | Type | Default | Description |
|---|---|---|---|
rows[].target | object | - | Home Assistant's target: label_id, area_id, device_id, floor_id, entity_id (each an id or a list). The row repeats per entity |
rows[].values | list | required | The cells of each copy; {entity} and {entity.*} read the copy's entity |
rows[].sort | string | name | name, state or none |
rows[].max_items | number | - | At most this many copies |
rows[].style | object | - | Style for every cell of every copy |
Data sources
A data source can smooth, scale or convert a sensor before the grid shows it. Define it under data_sources and use it in a cell by name: {datasource:name}.
- With a format such as
:.0fthe cell gets the number only, so add the unit yourself; without a format it gets the value with its unit, as Home Assistant shows it. - See Data Sources for the processing options and Templates for every format.
type: custom:lcards-data-grid
data_mode: data
data_sources:
power:
entity: sensor.kitchen_power
rows:
- [Kitchen, "{datasource:power:.0f} W"]
grid:
grid-template-columns: 1fr 1fr
style:
font_size: 20px| Key | Type | Default | Description |
|---|---|---|---|
data_sources | object | - | Named data sources: see Data Sources |
Header rows
A header row labels the grid or a group of rows: bold, uppercase and smaller, with a divider line, in the theme's header colours. Write the row as an object with values and header: true.
- Any number of rows can be headers, so a long table can have one per group.
- Change their look for the whole grid with
header_style(Styling), or for one row with that row'sstyle.
type: custom:lcards-data-grid
data_mode: data
rows:
- values: [Deck, Section, Status]
header: true
- [Deck 1, Bridge, Nominal]
- [Deck 5, Sickbay, Nominal]
- values: [Engineering]
header: true
- [Deck 12, Warp core, Online]
grid:
grid-template-columns: 1fr 1fr 1fr
style:
font_size: 18px
header_style:
color: var(--lcars-orange)| Key | Type | Default | Description |
|---|---|---|---|
rows[].header | boolean | false | Make this row a header row |
header_style | object | header defaults | Style for every header row: see Header rows |
Conditional colours
A cell's color or background can change with the state of the cell's entity, using the same state map as other LCARdS cards. Use it to turn a reading yellow or red past a limit.
- The cell's entity is its
entity, or thevaluewhen that is an entity id. For a template cell, addentity:to say which entity the colours follow; cells without an entity usedefault. - State maps work on row, column and grid-wide styles too; they resolve against each cell's own entity. See Colours for every colour format.
- A running cascade animates the text colour of every cell, so text-colour state maps only show when there is no cascade. Background state maps always show.
type: custom:lcards-data-grid
data_mode: data
rows:
- values: [Load, Watts]
header: true
- - Kitchen
- value: sensor.kitchen_power
style:
color:
default: var(--lcars-green)
above:300: var(--lcars-yellow)
above:1000: var(--lcars-red)
- - Phone battery
- value: sensor.phone_battery
style:
background:
default: transparent
below:30: var(--lcars-red)
at_least:80: var(--lcards-green-darkest)
grid:
grid-template-columns: 1fr 1fr
style:
font_size: 20px| State key | Matches when the entity state |
|---|---|
on, off, open, heat, ... | is exactly that state |
above:N, below:N, at_least:N, at_most:N | is a number past N (the closest match wins) |
between:A:B | is a number from A to B; between_exclusive:A:B leaves out A and B |
zero, non_zero | is 0, or any other number |
active, inactive, unavailable | is on/off style active, inactive, or unavailable/unknown |
default | none of the above |
More about conditional colours
- Order: an exact state wins, then
zero, then the number ranges, thennon_zero, thenactive/inactive/unavailable, thendefault. - Closest match: among
aboveandat_leastkeys the highest threshold that matches wins, amongbelowandat_mostthe lowest, and amongbetweenkeys the narrowest.
Tap actions
Cells do nothing when tapped unless you ask: cell_tap_action for every entity cell, or actions on one cell object. The most common choice is more-info, which opens the entity's dialog.
tap_action,hold_actionordouble_tap_actionon a cell object are for that cell only; a cell's owntap_actionreplacescell_tap_actionfor it.- Actions use the cell's entity by default, and take every standard action. Cells with an action show a pointer cursor.
- Cell actions work in data mode only; decorative cells have none.
type: custom:lcards-data-grid
data_mode: data
# every entity cell opens its dialog
cell_tap_action:
action: more-info
rows:
- [Inside, sensor.living_room_temperature]
# this cell toggles its light instead
- - Kitchen light
- value: light.kitchen
tap_action:
action: toggle
grid:
grid-template-columns: 1fr 1fr
style:
font_size: 20pxMore about tap actions
- Own actions win: a cell's own
tap_actionreplacescell_tap_action; a cell with only ahold_actionordouble_tap_actionstill taps withcell_tap_action. - Text cells:
cell_tap_actionapplies to cells with an entity, including a text cell object that setsentity. - Tap animations: a tap anywhere on the grid also fires the card's
on_tapanimations, with the tap point.
| Key | Type | Default | Description |
|---|---|---|---|
cell_tap_action | action | - | What tapping any entity cell does, unless the cell has its own tap_action |
tap_action | action | - | On a cell object: what tapping that cell does |
hold_action | action | - | On a cell object: what holding that cell does |
double_tap_action | action | - | On a cell object: what double-tapping that cell does |
In the Configuration Studio
The Studio's Grid Structure tab shows your rows as a spreadsheet you can edit.
- Click a cell to choose Entity (with an optional attribute) or Text or template, and to set the cell's style, conditional colours and actions.
- Click a row or column header to insert, move or delete it, set its style, or mark a row as a header.
- Add Row and Add Column grow the grid. Custom column widths such as
100px 1fr 80pxare kept when you add, move or remove columns. - Saving keeps your YAML short: rows without options stay plain lists, and cells without options stay plain values.