You are reading the development docs (2026.12.1-dev.1): features here may not be released yet.
Skip to content

Data Sources ​

A data source follows one entity in your browser, keeps its recent values, and runs them through processors that smooth, convert or otherwise work on them. Cards show the results in templates as {ds:name} and plot them as chart series.

  • Declare data sources under data_sources on any LCARdS card. Each key is a name you choose, and the name is how templates and charts find it.
  • Names are shared by the whole dashboard: the first card to create a name sets it up, and a later card using the same name gets that data source, settings and all. Give each data source its own name.
  • Data sources are created when the dashboard loads, preload some history, then follow live changes. They keep a limited number of recent points (see window_seconds), so for long spans of plain history, plot the entity on a chart instead.

Try it

A card editor's Main Engineering > Data Sources tab creates and edits data sources without YAML, with a preview of each processor (In the card editor). The Processor Reference has a live lab for every processor.

How a Data Source Works ​

Each change of the entity goes into a rolling buffer of recent values, then through the processing pipeline, and each processor keeps its own result. Templates and charts read the raw value or any processor's result.

Basic Usage ​

Name a data source under data_sources, give it an entity, and read it in a template with {ds:name}. Without a format the value shows as Home Assistant shows numbers, with the entity's unit; with one, such as :.1f, you write your own unit.

yaml
type: custom:lcards-button
preset: lozenge
data_sources:
  room_temp:
    entity: sensor.demo_temperature
    history:
      hours: 6
text:
  default:
    color: var(--lcars-black)
  native:
    content: "{ds:room_temp}" # Home Assistant's number format, with the unit
    position: top-left
  precise:
    content: "{ds:room_temp:.1f} °C" # your precision, your unit
    position: bottom-left
grid_options:
  rows: 2

Configuration Options ​

A data source needs only an entity; the other keys set how much it keeps, how often it updates cards, and how much history it preloads. The defaults suit most cards.

  • History is preloaded when the card loads: every recorded change over history.hours, or Home Assistant's hourly statistics when the recorder has none (for the entity state, not an attribute).
  • The buffer holds a number of points, not a span of time: a sensor that reports once a minute keeps ten hours of values in the default 600 points, and a preload longer than that keeps only its newest points.
  • A change after a quiet spell reaches cards at once. Rapid changes are merged before cards hear of them: at most one update every min_emit_ms, sent coalesce_ms after the last change of a burst, and never held back longer than max_delay_ms. The merged update carries the newest value; the buffer and the processors still see every change.

Top-Level Fields ​

Every key a data source takes, besides its processors. Processors are under Processors.

yaml
type: custom:lcards-button
preset: lozenge
data_sources:
  house_power:
    entity: sensor.demo_power # required: the entity to follow
    window_seconds: 120 # keep about 1,200 points
    min_emit_ms: 500 # update cards at most twice a second
    history:
      hours: 24
    processing:
      # each processor keeps its result under its own name
      kilowatts:
        type: scale
        input_range: [0, 1000]
        output_range: [0, 1]
      smoothed:
        type: smooth
        input_source: kilowatts # works on the kilowatts result
        method: exponential
        alpha: 0.3
text:
  default:
    color: var(--lcars-black)
  power:
    content: "{ds:house_power.smoothed:.2f} kW"
    position: top-left
grid_options:
  rows: 2
More about the fields
  • Older names: older configs may use camelCase (windowSeconds, minEmitMs, coalesceMs, maxDelayMs, emitOnSameValue) and history.preload for history.enabled. They still work, and the editor marks them as old names. If both spellings are set, the snake_case one wins.
  • States that are not numbers: the states on, true, active and open count as 1, and off, false, inactive and closed as 0. Other words need enum_mapping; without it they are skipped, as are unavailable and unknown.
  • Home Assistant's code editor: it reads unquoted on, off, yes and no as true or false, so quote them as enum_mapping keys: "off": 0.
KeyTypeDefaultDescription
entitystringrequiredThe entity to follow
attributestringthe stateAn attribute to follow instead of the state. state means the state
enum_mappingobject-Numbers for states that are not numbers, such as heat: 2 and cool: 1
window_secondsnumber / string60How many points the buffer keeps: about 10 per second of window, at least 60 and at most 1,000 (60 keeps 600). Also takes a duration such as "5m"
min_emit_msnumber100The least time between updates sent to cards, ms (at least 10)
coalesce_msnumber40% of min_emit_ms, at least 20How long to wait after the last of several rapid changes before sending the merged update, ms (at least 20)
max_delay_msnumber3 x coalesce_msThe longest an update may be held back while gathering, ms (at least min_emit_ms)
emit_on_same_valuebooleantrueSend an update even when the value didn't change
history.enabledbooleantruePreload history when the card loads
history.hoursnumber6Hours of history to preload, 1 to 168
history.daysnumber-Days of history to preload, 1 to 7, instead of hours. hours wins when both are set
processingobject-Named processors: see Processors

Processors ​

A processor works on the data source's values and keeps its result under its own name; input_source chains it after another processor. Without input_source a processor reads the raw value.

  • Read a processor's result in a template with {ds:name.processor}, and plot it with a chart series' buffer.
  • A processor's result has no unit: give it a format and your own unit, such as {ds:temp.fahrenheit:.0f} °F.
  • The Processor Reference covers every option, with a live lab for each processor.
yaml
type: custom:lcards-button
preset: lozenge
data_sources:
  room_temp_f:
    entity: sensor.demo_temperature
    processing:
      # Celsius to Fahrenheit
      fahrenheit:
        type: convert_unit
        from: c
        to: f
      # then smooth the converted value
      smooth_f:
        type: smooth
        input_source: fahrenheit
        method: exponential
        alpha: 0.2
text:
  default:
    color: var(--lcars-black)
  raw:
    content: "{ds:room_temp_f:.1f} °C"
    position: top-left
  converted:
    content: "{ds:room_temp_f.smooth_f:.1f} °F"
    position: bottom-left
grid_options:
  rows: 2
ProcessorPurposeMain settings
convert_unitConvert between unitsfrom, to (such as c and f)
scaleMap from one range to anotherinput_range, output_range, curve
smoothSmooth noisy valuesmethod (exponential, moving_average, gaussian), alpha, window
roundRound to decimal placesprecision, method
expressionA JavaScript expression of your ownexpression (uses value, sources, Math), sources
clampKeep within a minimum and maximummin, max
rateRate of change per unit of timeunit (per_second, per_minute, per_hour), smoothing
trendIncreasing, decreasing or stablesamples, threshold
deltaDifference from the previous valueabsolute
durationTime spent meeting a conditioncondition, reset_on
statisticsMin, max, mean and more over a windowwindow, stats
thresholdTwo outputs either side of a thresholdthreshold, above, below, hysteresis
KeyTypeDefaultDescription
typestringrequiredThe processor, from the list above
input_sourcestringthe raw valueThe name of another processor in this data source whose result this one works on
enabledbooleantruefalse passes values through unchanged

In the card editor ​

A card editor's Data Sources tab (under Main Engineering) creates and edits data sources without YAML. In the data source dialog, the Processing tab shows:

  • A preview: the processors run over the entity's own recent history (the span set under Timing & History, the way the data source preloads it), charted against the raw values. It updates as you edit; the selected processor's line is drawn heavier.
  • The pipeline: each processor under its input, numbered in the order they run. Errors such as a missing input or a loop show above it.
  • The selected processor's settings, edited in place: its name (renaming updates the processors that use it), its input (the raw value or another processor), and the type's options. Edit as YAML switches to its YAML.

The preview runs the same processor code as the dashboard. Live-only behaviour, such as a duration ticking between state changes, isn't shown.

Accessing Values in Templates ​

{ds:name} (or {datasource:name}) shows a data source's value in any text that takes templates. The rule: no format, and Home Assistant formats it with the unit; with a format, you control the output. The Templates page lists every format.

yaml
# No format: Home Assistant's number format, with the entity's unit
"{ds:temp}"                            # → "21.4 °C"

# With a format: the number only, no unit
"{ds:temp:.1f}"                        # → "21.4"
"{ds:temp:.0f}"                        # → "21"
"{ds:temp:.1f} °C"                     # → "21.4 °C" (your own unit)

# A processor's result: a dot and its name, with either prefix
"{ds:temp.fahrenheit:.0f} °F"          # → "71 °F"
"{datasource:temp.fahrenheit:.0f} °F"  # the same
More about values in templates
  • Data sources from other cards: a card updates when the data sources in its own data_sources change. To show one another card defines, declare it in this card's data_sources too, with the same name.
  • One statistic: a statistics processor holds several values; pick one with another dot. For a processor named stats: {ds:temp.stats.max:.1f}.

Data Sources in Charts ​

A chart series can plot a data source's values, or one of its processors' results with buffer. See the Chart card for the series keys.

yaml
type: custom:lcards-chart
chart_type: line
data_sources:
  chart_temp:
    entity: sensor.demo_temperature
    processing:
      smoothed:
        type: smooth
        method: exponential
        alpha: 0.3
sources:
  - datasource: chart_temp
    name: Raw
  - datasource: chart_temp
    buffer: smoothed
    name: Smoothed

Released under the MIT License. | About