Processor Reference
Complete reference for all 12 DataSource processor types.
Overview
Processors transform data as it flows through a DataSource. Each processor:
- Has a unique name (the key in the
processingobject) - Specifies a type (one of 12 processor types)
- Optionally uses
fromto depend on another processor - Outputs a value accessible in templates as
{datasource.processor_name}
Quick Reference
| Type | Purpose | Common Use |
|---|---|---|
convert_unit | Unit conversion | Temperature °F↔°C, power W↔kW |
scale | Map range to range | 0-100 → 0-255, normalize values |
smooth | Reduce noise | Smooth jittery sensors |
expression | Custom formula | Calculate derived values |
statistics | Min/max/mean/etc | Aggregate over time window |
rate | Rate of change | Watts → watts/hour |
trend | Direction detection | Increasing/decreasing/stable |
duration | Time tracking | Time spent above threshold |
threshold | Binary conversion | Above/below → 1/0 |
clamp | Limit to range | Keep within min/max |
round | Round precision | 2 decimals, floor, ceil |
delta | Change detection | Difference from last value |
convert_unit
Convert between measurement units.
Configuration
processor_name:
type: convert_unit
from: c # Source unit
to: f # Target unitSupported Units
Temperature:
c(Celsius),f(Fahrenheit),k(Kelvin)
Power:
w,kw,mw,gw(watts → gigawatts)
Energy:
wh,kwh,mwh(watt-hours)j,kj,mj(joules)
Distance:
mm,cm,m,km(metric)in,ft,yd,mi(imperial)
Speed:
ms(meters/second),kmh,mph
Pressure:
hpa,bar,psi,mmhg
Data:
b,kb,mb,gb,tb
Volume:
ml,l(liters),gal(gallons)
Mass:
g,kg(kilograms),lb,oz
Home Assistant:
brightness(0-255 ↔ 0-100%)percent(0-100)
Examples
# Temperature conversion
fahrenheit:
type: convert_unit
from: c
to: f
# Power to kilowatts
kilowatts:
type: convert_unit
from: w
to: kw
# Brightness to percentage
percent:
type: convert_unit
from: brightness
to: percentscale
Map input range to output range with optional curve.
Configuration
processor_name:
type: scale
from: source_processor # Optional
input_range: [0, 100]
output_range: [0, 255]
curve: linear # linear, exponential, logarithmic, sigmoidExamples
# Normalize 0-100 to 0-1
normalized:
type: scale
input_range: [0, 100]
output_range: [0, 1]
# Temperature comfort index
comfort:
type: scale
from: fahrenheit
input_range: [32, 95]
output_range: [0, 100]
# RGB brightness
rgb:
type: scale
input_range: [0, 100]
output_range: [0, 255]
curve: exponential # More natural brightness perceptionsmooth
Apply smoothing algorithms to reduce noise.
Configuration
processor_name:
type: smooth
from: source_processor # Optional
method: exponential # exponential, moving_average, gaussian
window: 10 # For moving_average (samples)
alpha: 0.3 # For exponential (0-1, lower = more smoothing)Methods
Exponential:
- Lightweight (single value state)
- Good for real-time displays
alpha: 0.1 (heavy) to 0.9 (light smoothing)
Moving Average:
- Accurate averaging
- Requires buffer of
windowsamples - Good for historical analysis
Gaussian:
- Weighted average with bell curve
- Smoothest result
- Computationally heavier
Examples
# Light exponential smoothing
smoothed:
type: smooth
method: exponential
alpha: 0.3
# 10-sample moving average
moving_avg:
type: smooth
from: converted
method: moving_average
window: 10
# Smooth temperature readings
smooth_temp:
type: smooth
from: fahrenheit
method: gaussian
window: 5expression
Evaluate custom JavaScript expressions.
Configuration
processor_name:
type: expression
from: source_processor # Optional: single source
sources: # Optional: multiple sources
- processor1
- processor2
expression: "value * 2" # JavaScript expressionContext Variables
value- Current value (iffromspecified)sources[0], sources[1]...- Array of source values (ifsourcesspecified)metadata- DataSource metadata objectstates- Full HA states objecthass- Full HASS object
Examples
# Simple calculation
doubled:
type: expression
expression: "value * 2"
# Temperature-humidity comfort formula
comfort:
type: expression
sources:
- temperature
- humidity
expression: "sources[0] - ((100 - sources[1]) * 0.5)"
# Conditional logic
status:
type: expression
from: temperature
expression: "value > 25 ? 'hot' : 'cold'"
# Complex formula
feels_like:
type: expression
sources:
- temp_f
- humidity
- wind_speed
expression: |
const t = sources[0];
const h = sources[1];
const w = sources[2];
return t + 0.33 * h - 0.7 * w - 4.0;statistics
Calculate statistical measures over a time window.
Configuration
processor_name:
type: statistics
from: source_processor # Optional
window: 24h # Time window or 'session'
stats: # Array of statistics to calculate
- min
- max
- meanAvailable Statistics
min- Minimum valuemax- Maximum valuemean- Averagemedian- Middle valuestd_dev- Standard deviationq1- 25th percentileq3- 75th percentilerange- max - mincount- Number of samples
Output
Returns object with requested stats:
{
min: 18.5,
max: 24.3,
mean: 21.2,
median: 21.0,
count: 144
}Examples
# Daily temperature statistics
daily_stats:
type: statistics
from: fahrenheit
window: 24h
stats: [min, max, mean]
# Session-wide stats
session_stats:
type: statistics
window: session
stats: [min, max, range]
# Full statistical analysis
complete_stats:
type: statistics
from: sensor_value
window: 1h
stats: [min, max, mean, median, std_dev, q1, q3]Template Access:
overlays:
- content: "Min: {temp.daily_stats.min:.1f}°F"
- content: "Max: {temp.daily_stats.max:.1f}°F"
- content: "Avg: {temp.daily_stats.mean:.1f}°F"rate
Calculate rate of change over time.
Configuration
processor_name:
type: rate
from: source_processor # Optional
unit: per_second # per_second, per_minute, per_hour
smoothing: true # Optional: apply smoothingExamples
# Power consumption rate
power_rate:
type: rate
from: kilowatts
unit: per_hour
# Data transfer rate
transfer_rate:
type: rate
from: bytes_transferred
unit: per_second
# Temperature change rate
temp_rate:
type: rate
from: celsius
unit: per_minute
smoothing: truetrend
Detect trend direction (increasing, decreasing, stable).
Configuration
processor_name:
type: trend
from: source_processor # Optional
samples: 5 # Number of samples to analyze
threshold: 0.01 # Minimum change to detect trendOutput
Returns string:
"increasing"- Value trending up"decreasing"- Value trending down"stable"- No significant change
Examples
# Temperature trend
temp_trend:
type: trend
from: celsius
samples: 10
threshold: 0.1
# Battery trend
battery_trend:
type: trend
from: battery_percent
samples: 5
threshold: 1Template Usage:
overlays:
- content: "Trend: {temp.temp_trend}" # "increasing"
- content: |
{% if temp.temp_trend == 'increasing' %}↗{% endif %}duration
Track time spent in a condition.
Configuration
processor_name:
type: duration
from: source_processor # Optional
condition: "> 20" # Condition expression
reset_on: "< 15" # Optional: reset conditionOutput
Returns object:
{
duration_ms: 3600000, // Milliseconds
duration_human: "1h 0m 0s" // Human-readable
}Examples
# Time above threshold
high_temp_duration:
type: duration
from: celsius
condition: "> 25"
reset_on: "< 20"
# Motion detection duration
motion_duration:
type: duration
condition: "== 'on'"
# Door open duration
door_open_time:
type: duration
from: door_state
condition: "== 'open'"Template Access:
overlays:
- content: "High temp for: {temp.high_temp_duration.duration_human}"threshold
Convert value to binary based on threshold.
Configuration
processor_name:
type: threshold
from: source_processor # Optional
threshold: 20
above: 1 # Value when above threshold
below: 0 # Value when below threshold
hysteresis: 2 # Optional: prevent flappingHysteresis
Prevents rapid switching near threshold:
- When rising: triggers at
threshold + hysteresis - When falling: triggers at
threshold - hysteresis
Examples
# Simple binary
is_hot:
type: threshold
from: celsius
threshold: 25
above: 1
below: 0
# With hysteresis (prevents flapping at 25°C)
comfort_alert:
type: threshold
from: temperature
threshold: 25
above: 1
below: 0
hysteresis: 2 # Triggers at 27°C up, 23°C down
# Custom values
temp_level:
type: threshold
from: fahrenheit
threshold: 75
above: "hot"
below: "comfortable"clamp
Limit value to minimum and maximum bounds.
Configuration
processor_name:
type: clamp
from: source_processor # Optional
min: 0
max: 100Examples
# Clamp percentage
percent_clamped:
type: clamp
min: 0
max: 100
# Limit temperature range
temp_limited:
type: clamp
from: celsius
min: -10
max: 40
# Prevent negative values
positive_only:
type: clamp
from: calculated
min: 0round
Round to specified precision.
Configuration
processor_name:
type: round
from: source_processor # Optional
precision: 1 # Decimal places
method: round # round, floor, ceilMethods
round- Standard rounding (0.5 → 1)floor- Always round down (0.9 → 0)ceil- Always round up (0.1 → 1)
Examples
# 1 decimal place
rounded:
type: round
precision: 1
# No decimals
whole_number:
type: round
from: temperature
precision: 0
# Always round down
floored:
type: round
from: value
precision: 0
method: floor
# Round to nearest 5
rounded_5:
type: expression
expression: "Math.round(value / 5) * 5"delta
Calculate change from previous value.
Configuration
processor_name:
type: delta
from: source_processor # Optional
absolute: false # true = absolute change, false = signedExamples
# Signed change
temp_change:
type: delta
from: celsius
absolute: false
# Absolute change
abs_change:
type: delta
from: power
absolute: true
# Detect large jumps
significant_change:
type: expression
from: temp_change
expression: "Math.abs(value) > 5"Chaining Processors
Processors can depend on each other using from:
data_sources:
temp:
entity: sensor.temperature
processing:
# 1. Convert to Fahrenheit (no dependencies)
fahrenheit:
type: convert_unit
from: c
to: f
# 2. Smooth (depends on fahrenheit)
smoothed:
type: smooth
from: fahrenheit
method: exponential
alpha: 0.3
# 3. Round (depends on smoothed)
rounded:
type: round
from: smoothed
precision: 1
# 4. Statistics (depends on smoothed, parallel with rounded)
stats:
type: statistics
from: smoothed
window: 24h
stats: [min, max, mean]Execution Order:
fahrenheit(no dependencies)smoothedandstats(both depend onfahrenheit, run in parallel)rounded(depends onsmoothed)
Performance Notes
Lightweight Processors:
convert_unit,scale,round,clamp,threshold,delta- Single-pass calculations, minimal memory
Medium Weight:
smooth(exponential)expression(simple formulas)rate,trend
Heavier Processors:
smooth(moving average, gaussian)statistics(requires window buffer)durationexpression(complex formulas)
Best Practices:
- Only create processors you actually use
- Use
update_intervalto throttle high-frequency sources - Prefer exponential smoothing over moving average for displays
- Limit statistics windows to what you need
- Avoid deeply nested processor chains (>5 levels)
Last updated: February 2026 | LCARdS v1.12+