Skip to main content

Overview

Every Action needs a trigger—the event that starts its execution. Choosing the right trigger type determines how your automation responds to real-world conditions.
Think of triggers like different ways to start your car. A time-based trigger is like an auto-start that warms up your car every morning at 7 AM. A topic-based trigger is like pushing the start button when you get in. A callable action is like asking someone else to start it for you.

When to Use Each Type

Trigger TypeUse WhenExample
Time-Based (ON EVERY)You need regular intervals regardless of dataHeartbeats, polling, scheduled reports
Topic-Based (ON TOPIC)You need to react when data arrivesSensor processing, command handling
Callable (no trigger)You need reusable logic invoked by other actionsUtility functions, shared calculations

In This Page

  • Time-Based Triggers — Execute on a schedule with ON EVERY
  • Topic-Based Triggers — React to MQTT messages with ON TOPIC
  • Callable Actions — Invoke manually or from other actions

Time-Based Triggers

Use ON EVERY to execute actions at regular intervals:
DEFINE ACTION PeriodicHeartbeat
ON EVERY 5 SECONDS DO
    PUBLISH TOPIC "system/heartbeat" WITH "alive"

Supported Time Units

UnitSingularPluralExample
SecondSECONDSECONDSON EVERY 30 SECONDS
MinuteMINUTEMINUTESON EVERY 5 MINUTES
HourHOURHOURSON EVERY 1 HOUR
DayDAYDAYSON EVERY 1 DAY
WeekWEEKWEEKSON EVERY 1 WEEK
Singular and plural forms are interchangeable: 1 SECOND works the same as 1 SECONDS.

Time-Based Examples

Publish a status signal every 5 seconds for monitoring:
DEFINE ACTION SystemHeartbeat
ON EVERY 5 SECONDS DO
    PUBLISH TOPIC "system/status" WITH "online"
    PUBLISH TOPIC "system/timestamp" WITH TIMESTAMP "UTC"
Maintain a counter that persists between executions:
DEFINE ACTION IncrementCounter
ON EVERY 10 SECONDS DO
    IF GET TOPIC "counter/value" == EMPTY THEN
        PUBLISH TOPIC "counter/value" WITH 0
    ELSE
        PUBLISH TOPIC "counter/value" WITH (GET TOPIC "counter/value" + 1)

Topic-Based Triggers

Use ON TOPIC to execute actions when MQTT messages arrive:
DEFINE ACTION ProcessMessage
ON TOPIC "input/data" DO
    PUBLISH TOPIC "output/data" WITH PAYLOAD

Wildcard Patterns

LoT supports MQTT wildcards for flexible topic matching:
The + wildcard matches exactly one topic level:
DEFINE ACTION SensorRouter
ON TOPIC "sensors/+/temperature" DO
    // POSITION 1="sensors", POSITION 2=wildcard (sensor_id), POSITION 3="temperature"
    SET "sensor_id" WITH TOPIC POSITION 2
    PUBLISH TOPIC "processed/" + {sensor_id} + "/temp" WITH PAYLOAD
Matches: sensors/room1/temperature, sensors/room2/temperature
Does NOT match: sensors/building1/floor2/temperature (too many levels)

Callable Actions

Actions without an event trigger are callable—they execute only when explicitly invoked by other actions or via system commands.

Basic Callable Action

DEFINE ACTION CacheUpdater
DO
    KEEP TOPIC "cache/latest" WITH (GET TOPIC "data/current")
    PUBLISH TOPIC "cache/updated" WITH TIMESTAMP "UTC"

Callable Action with Parameters

Callable actions can accept input parameters and return values:
DEFINE ACTION CalculateAverage
INPUT value1 AS DOUBLE
INPUT value2 AS DOUBLE
DO
    SET "sum" WITH ({value1} + {value2})
    SET "avg" WITH ({sum} / 2)
RETURN
    OUTPUT avg

Invoking Callable Actions

Use CALL ACTION to invoke from within another action. This is the primary way to reuse logic across your automation:
DEFINE ACTION ProcessSensorPair
ON TOPIC "sensors/pair/data" DO
    SET "temp1" WITH (GET JSON "sensor1" IN PAYLOAD AS DOUBLE)
    SET "temp2" WITH (GET JSON "sensor2" IN PAYLOAD AS DOUBLE)
    
    CALL ACTION CalculateAverage
        WITH value1 = {temp1}, value2 = {temp2}
        RETURN result
    
    PUBLISH TOPIC "sensors/average" WITH {result}

Comparing Trigger Types

AspectTime-BasedTopic-BasedCallable
TriggerClock intervalMQTT messageManual command
FrequencyPredictableEvent-drivenOn-demand
Payload AccessNoYes (PAYLOAD)Via parameters
Best ForMonitoring, reportingData processingReusable utilities

Next Steps