Skip to content

PAYLOAD Entity

Feature Since Version Notes
PAYLOAD >v1.5.1 Represents incoming message content

The PAYLOAD entity represents the content of the message that triggered an event, typically within an ACTION defined with ON TOPIC.

Usage

PAYLOAD is commonly used:

  1. With PUBLISH TOPIC: To forward or use the incoming data.
  2. In Expressions: As part of calculations or conditional logic.

Examples

1. Echoing Payload:

DEFINE ACTION EchoPayload
ON TOPIC "input/echo" DO
    PUBLISH TOPIC "output/echo" WITH PAYLOAD

2. Using Payload in Calculation:

DEFINE ACTION ProcessSensorData
ON TOPIC "sensors/raw" DO
    // Assumes payload is numeric
    PUBLISH TOPIC "sensors/processed" WITH (PAYLOAD * 1.8 + 32) // Example: C to F

3. Using Payload in Conditional Logic:

DEFINE ACTION CheckStatus
ON TOPIC "device/status_report" DO
    IF PAYLOAD == "ERROR" THEN
        PUBLISH TOPIC "alerts/device" WITH "Device reported an error!"
    ENDIF

Related Documentation