Script Filter
Node ID: scriptFilter · Role: Filter · Realtime config: yes
Description
Programmable filter using Rhai scripts. Receives sensor data, runs a user-defined script, and emits the result. Scripts can transform, filter, or convert data between types at runtime.
Inputs / Outputs
- Inputs:
Any - Outputs:
Any
Config aliases
ScriptFilter, scriptFilter
Properties
The following fields are exposed in the node’s Properties panel in the UI. Types map to UI widgets (e.g. string → text input, number → numeric, boolean → toggle, select → dropdown, json → JSON editor).
| Key | Label | Type | Default | Description / Notes |
|---|---|---|---|---|
script | Script | code | `fn process(data) { | |
| data | ||||
| }` | Rhai script body. Entry point is fn process(data), which receives the incoming sample and returns the value to emit. | |||
inputCount | Input Ports | number | 1 | Number of input ports exposed on the node. |
outputCount | Output Ports | number | 1 | Number of output ports exposed on the node. |
Example node definition
A full node definition in config.json looks like the block below. Paste it under the sinks key of your config, keyed by the node’s instance name (any identifier; it doesn’t have to match the node ID).
{
"sinks": {
"scriptFilter": {
"dataEndpoint": "inproc://scriptFilter_data",
"inputEndpoints": [],
"settings": {
"inputCount": 1,
"outputCount": 1,
"script": "fn process(data) {\n data\n}"
}
}
}
}
Field reference
| Field | Purpose |
|---|---|
dataEndpoint | Endpoint this node binds to publish its output. Omit to let the runtime generate one. |
inputEndpoints | List of upstream endpoints this node connects to (outEndpoint / dataEndpoint values from upstream nodes). |
inputDataFilter | Optional whitelist of data types. Messages whose type isn’t in the list are dropped at the subscriber. |
settings | All user-configurable fields — see the Properties table above. |
Connections can also be declared at the top-level
connectionsarray whensettings.explicitConnectionsistrue, as an alternative to fillinginputEndpointson each node.