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


Time-Based Triggers

LoT supports several time-based trigger forms. All of them use the ON keyword and run the action’s DO block automatically—no MQTT message is required to fire them. Together they cover recurring intervals, calendar rules (a specific weekday, Monday–Friday, or Saturday–Sunday), daily wall-clock times, and single one-shot executions.

Quick reference

Time zone: For HH:mm and HH:mm:ss in ON EVERY … AT and in daily ON TIMESTAMP, values are interpreted in the local time of the machine running the broker, then converted to UTC internally. The action is scheduled for the correct wall-clock time across daylight saving changes. The one-shot form dd-MM-yyyy HH:mm:ss is interpreted as UTC, as described below.
Structured payloads: PUBLISH TOPIC does not support inline JSON object literals. For multi-field records, define a COLLAPSED model and use PUBLISH MODEL … TO … WITH (see Publishing Models). The timed-action examples below use that pattern.

1. ON EVERY N UNIT — fixed interval

Fires repeatedly every N units of time. Common for monitoring, polling, and heartbeats.

Supported units

Singular and plural unit names are interchangeable (for example, 1 SECOND and 1 SECONDS). ON EVERY 1 DAY fires every 24 hours from the last run; for the same clock time every calendar day, use daily ON TIMESTAMP instead.

2. ON EVERY DAY AT — weekly, specific day

Fires once per week on the named weekday at the given local time. Use "HH:mm" or "HH:mm:ss"; seconds are optional.

3. ON EVERY WEEKDAY AT — Monday–Friday

Fires Monday through Friday at the same local time—one action instead of five separate daily schedules.

4. ON EVERY WEEKEND AT — Saturday and Sunday

Fires on both weekend days at the specified local time—useful for maintenance windows or weekend-only reporting.

5. ON TIMESTAMP — daily fixed time

Fires every day at the given local wall-clock time. Unlike ON EVERY 1 DAY, this tracks clock time, not elapsed time since the broker or last run started.
"HH:mm" without seconds is accepted.

6. ON TIMESTAMP — one-shot, exact date and time

Fires once at the exact instant given, then never again (the scheduler moves the next run far into the future). Format is strictly dd-MM-yyyy HH:mm:ss (day–month–year). The timestamp is treated as UTC.

Combination patterns

Real systems often split schedules across several actions—one trigger per concern.

Error handling

If a time string does not match an expected format, the broker logs an error similar to: Invalid DATE_TIME format: <value>. Expected formats:
  • dd-MM-yyyy HH:mm:ss (one-time)
  • HH:mm:ss / HH:mm (daily)
  • Weekly forms using a day name with AT and a time string
Errors are also published (retained) to: $SYS/Coreflux/Actions/<ActionName>/Error Subscribe to $SYS/Coreflux/Actions/+/Error to observe failures from any action.

At a glance — valid time triggers

More examples


Topic-Based Triggers

MQTT-driven actions use a topic trigger — the condition that tells the broker when to run the action body. Both triggers share the same topic patterns and wildcards; the difference is whether repeated identical payloads should be ignored.

ON TOPIC — react to every message

Use ON TOPIC when each publish matters: commands, alarms, counters, or any flow where duplicate payloads still need processing.
Key characteristics:
  • Any client (or route) that publishes to a matching topic runs the action.
  • Publishing the same value twice runs the action twice.
  • Wildcard + matches one topic level (same rules as MQTT wildcards).

ON CHANGE — react only when the value changes

Use ON CHANGE for telemetry, status fields, or setpoints that are published often but only need logic when the reading actually changes. This reduces CPU load, database writes, and downstream noise.
Key characteristics:
  • The first message on a given topic always runs the action (there is no previous value yet).
  • Later messages run the action only if the payload bytes are not identical to the last message on that exact topic name.
  • Example: sensors/line1/temperature and sensors/line2/temperature are tracked separately.
  • Wildcard patterns work the same as ON TOPIC; change is evaluated per real topic, not per pattern.
What counts as “changed”? Comparison is on the raw message body (bytes), not on parsed numbers or JSON. 25 and 25.0 are different payloads. {"temp":25} and {"temp": 25} (different spacing) are different payloads. If you need semantic equality (for example, treat 25 and 25.0 as the same), handle that inside an ON TOPIC action with your own logic.

Choosing between ON TOPIC and ON CHANGE

You can deploy two actions on the same topic pattern: one with ON TOPIC and one with ON CHANGE. The broker runs ON TOPIC every time and skips the ON CHANGE action when the payload is unchanged.

Side-by-side example

Two devices publish temperature every second. Only 22.523.1 should trigger heavy processing.
On value change only:
Inside the action body, PAYLOAD is the content of the message that fired the trigger, and TOPIC POSITION N is segment N of the actual topic (1-based), useful with +.

Wildcard Patterns

LoT supports MQTT wildcards for flexible topic matching:
The + wildcard matches exactly one topic level:
Matches: sensors/room1/temperature, sensors/room2/temperature
Does NOT match: sensors/building1/floor2/temperature (too many levels)

Initialization Triggers

Use ON START to execute logic exactly once when the broker starts or when the action is first deployed. This is the right place to bootstrap a Unified Namespace (UNS) structure, publish retained default configurations, and log startup events.
Key characteristics:
  • Runs exactly once per broker start — not on a schedule, not on a message
  • KEEP TOPIC publishes with the retain flag so the value is delivered to any future subscriber immediately on connection
  • Use it to set default configuration values and retained state that must survive restarts
  • There is no ON STOP equivalent — ON START is the correct place for setup logic

Callable Actions

Actions without a trigger clause (ON TOPIC, ON EVERY, ON START, and so on) are callable—they run only when another ACTION calls them with CALL ACTION. Use callables for reusable logic (conversions, validation, shared math) that several trigger-based Actions need. They accept typed INPUT parameters and can RETURN one or more OUTPUT values.
Full guide: Callable ACTIONs—reusable logic, on-demand scripts, and CALL ACTION syntax.

Comparing Trigger Types


Next Steps

Callable ACTIONs

Reusable logic, on-demand scripts, and CALL ACTION.

Operations

Learn about SET, GET, PUBLISH, and conditional logic.
Last modified on June 5, 2026