Back to Index

Definition: onmqtt("key") { ... } — Allowed: string literal key (use "*" for wildcard); Not allowed: non-string key.

Registers a block that runs when Script_OnMqtt() is called. The block fires when the inbound MQTT key matches the declared string (use "*" to match all). To reach the interpreter, the incoming MQTT key must include the _script suffix (for example light1_script).

Payload helper variables inside handlers: msg_is_on, msg_is_off, msg_is_number, msg_value. If no key matches, no onmqtt block is executed. Use next; for early exit of the current run.

Example

onmqtt("command1_script") {
  if (msg_is_number) {
    out(1) = (msg_value != 0);
  }
}