Expressions in editors
Which names you can type depends on the editor. Simple expression, Lua, JavaScript, and JSONPath each use their own syntax. Fields with {{ }} run a simple expression inside the braces.
How to write it
| Where | Example |
|---|---|
| Simple expression or Lua or JavaScript | env.my_key |
| JSONPath | $.env.my_key |
Fields that fill in {{ }} |
{{ env.my_key }} |
The ENV variables editor does not fill anything in. Values are stored as you type them.
Names by editor
| Editor | value |
raw |
transformed |
ctx |
env |
source_value / source_raw |
|---|---|---|---|---|---|---|
| Simple expression on a source or data piece | yes | yes | — | yes | yes | yes |
| Simple expression in tap actions | yes | yes | yes | yes | yes | yes |
| Lua on a source or data piece | yes | yes | — | yes | yes | yes |
| Lua in tap actions | yes | yes | yes | yes | yes | yes |
| JavaScript on a source or data piece | yes | yes | — | yes | yes | sourceValue / sourceRaw |
| JavaScript in tap actions | yes | yes | yes | yes | yes | sourceValue / sourceRaw |
| JSONPath on a source or data piece | $.value… |
$.raw… |
— | $.ctx… |
$.env.my_key |
— |
| JSONPath in tap actions | $.value… |
$.raw… |
$.transformed… |
$.ctx… |
$.env.my_key |
— |
Data source fields with {{ }} |
this source | last incoming data | — | MQTT/WS/Timer/Default value: no. HTTP actions: yes |
yes | yes |
Tap action fields with {{ }} |
yes | yes | yes | yes | yes | yes |
| Data destination, sent from a tap | the Text to send after its {{ }} are filled in (or the current value when it is empty) |
yes | yes | yes | yes | yes |
| MQTT or WebSocket connection, and its On connected actions | only after On prepare: its result | — | — | only after On prepare | yes | — |
| Component inspector properties | this component | — | — | yes | yes | yes |
| Data piece Background color, Border, and Visible | this data piece | — | — | yes | yes | yes |
raw in a transformer (Simple expression, Lua, JavaScript, or JSONPath) is the data at the start of that chain, not the tap snapshot.
In JSONPath on a transformer, $ holds the same names: data is under $.value…, the start of the chain under $.raw…, extras under $.ctx…. Start the path with $.env to read a variable.
vars — the runtime store that scripts fill — works everywhere env works: vars.my_key, $.vars.my_key, or {{ vars.my_key }}. On a custom screen, transformers, tap actions, and component fields also get params — the values passed when the screen opened (params.room, $.params.room, {{ params.room }}). See Runtime vars.
On a data piece or component transformer or tap (not a data source, HTTP list, or inspector field with {{ }}), Simple expression and JSONPath can read comp / components. Lua and JavaScript can change them. See Lua and JavaScript. They can also read the Data setting as comp.userData.
Fields that fill in {{ }}
| Where | Fields |
|---|---|
| Data source | Default value (all types); MQTT Topic filters (subscribe); WebSocket Rooms and Message events. HTTP actions URL, headers, parameters, and body (those also see ctx, including ctx.transport from the previous HTTP request in the same list) |
| Tap actions | HTTP request URL, headers, Query parameters, and Body; MQTT send topics and Payload; WebSocket send events and Payload; Trigger data destination Text to send; Open URL; Apply value; User input: Text; User input: Range |
| Data destination | HTTP actions URL, headers, parameters, and body (same names as the list, including ctx); MQTT topics, content type, and user properties; WebSocket events |
| Component | Inspector properties except ID, source, Inherited, transformers, and tap actions — including Text size, Text color, Font, Bold, and Italic on text components. Items on Radio / Menu / Segmented button: one per line, comma-separated, a JSON array, or {{ }} |
| Data piece | Background color; Border switch, color, and width; Visible |
| MQTT connection | Host, credentials, Last will (LWT), and similar text fields. After On prepare, they can also use that list's result ({{ value }}) and its {{ ctx… }}. On connected action fields fill in when each action sends, with the same result |
| WebSocket connection | URL, headers, and Query parameters. After On prepare, they can also use that list's result ({{ value }}) and its {{ ctx… }}. On connected action fields fill in when each action sends, with the same result |
Leave a send field empty to send the current value, including a file or image. A file or image cannot be mixed with other text. URLs, headers, topics, and events are text only.
If an expression cannot be evaluated, that MQTT/WebSocket subscribe, tick, or connect is skipped (MQTT and WebSocket keep the last successful subscribe). An empty or invalid HTTP action URL, or an expression that can't be evaluated there, stops the rest of that HTTP list. A tap send other than HTTP stops. A component property or a data piece background color, border, or Visible keeps the last valid value. See Tap actions and ENV variables.