Back to Index

Definition: msg_value — Allowed: read-only variable inside onmqtt; Not allowed: assignment.

Helper numeric value inside onmqtt. Mapping: true/on -> 1, false/off -> 0, numeric payload -> parsed number (int/float).

If parsing fails (for example malformed text), msg_value keeps the previous valid value.

Example

onmqtt("plc/sp") {
  if (msg_is_number) {
    setpoint = msg_value;
    save(setpoint);
  }
}