Susi Server

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

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).

KeyLabelTypeDefaultDescription / Notes
scriptScriptcode`fn process(data) {
data
}`Rhai script body. Entry point is fn process(data), which receives the incoming sample and returns the value to emit.
inputCountInput Portsnumber1Number of input ports exposed on the node.
outputCountOutput Portsnumber1Number 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

FieldPurpose
dataEndpointEndpoint this node binds to publish its output. Omit to let the runtime generate one.
inputEndpointsList of upstream endpoints this node connects to (outEndpoint / dataEndpoint values from upstream nodes).
inputDataFilterOptional whitelist of data types. Messages whose type isn’t in the list are dropped at the subscriber.
settingsAll user-configurable fields — see the Properties table above.

Connections can also be declared at the top-level connections array when settings.explicitConnections is true, as an alternative to filling inputEndpoints on each node.

Loading documentation…