Messages
Every widget understands the same three things. Learn them once, use them everywhere.
msg.payload: the value
Section titled “msg.payload: the value”Sending a message with a payload sets the widget’s value:
| Widget | Payload |
|---|---|
| stat, gauge | number (or text, for stat) |
| switch | boolean (true/false, "on", 1…) |
| slider | number |
| chart | number, appended to the series named by msg.topic. [] clears the chart |
The runtime stores the last value, so browsers that open the page later see it straight away.
A value can also reach a widget by name instead of by wire: set the widget’s tag and the runtime feeds it through this same msg.payload path. See Tags.
msg.ui: properties at runtime
Section titled “msg.ui: properties at runtime”Any property you can set in the editor can be changed from a flow:
// disable a button and relabel it while the pump is offreturn { ui: { disabled: true, label: 'Pump stopped' } };Common properties: label, disabled, visible, unit, min, max, variant.
A message may carry ui, payload or both.
Output messages
Section titled “Output messages”Input widgets emit when a user interacts:
{ "payload": 24.5, "topic": "setpoint", "_client": { "id": "c3-lq0z1" }}topic comes from the node configuration. _client.id identifies the browser that triggered the event.
Replying to one browser
Section titled “Replying to one browser”If a message sent to a widget carries _client.id, it is delivered only to that browser and is not stored.
That makes per-user feedback trivial: keep _client on the message as it flows through your logic.