Skip to main content

Control the Broker Over MQTT

Instead of editing files and restarting, you publish a command string to a system topic and the broker applies the change immediately: users, LoT entities, Routes, projects, secrets, and more.
Like a remote control for the broker. You send a message to a reserved topic; the broker answers on a matching output topic. No SSH and no restart.

When to use broker commands

  • Deploy or remove Actions, Models, Routes, and Rules without downtime
  • Run an Action on demand, or inspect what is loaded
  • Manage users, groups, environment variables, and secrets
  • Load LoT notebook projects and check their status
  • Drive the same verbs from Coreflux HUB Command Console or any MQTT client
On a cluster, send write commands (add/remove/load) to the leader. Read-only and license commands still run on the node you are connected to.
Subscribe first, then publish. Replies are always JSON on a single output topic.

Quick Start

Subscribe to $SYS/Coreflux/Command/Output, then publish the command. Use QoS 1 on both the command and the output subscription.
The broker replies with a JSON envelope. success is true when the Action was registered:

How Commands Work

Authorization uses the MQTT session username of the publishing client. Do not send -requestUser in the payload.
Replies always go to $SYS/Coreflux/Command/Output. Do not subscribe to $SYS/Coreflux/CommandResponse. Custom reply routing (-bt) and $SYS/Coreflux/Cloud/Command are not supported.

Response Envelope

Every reply on $SYS/Coreflux/Command/Output is one JSON object. List and query payloads live in data. data is always present: {} when there is nothing structured to return, or [] for an empty list.

How to parse a reply

  1. Parse the payload as JSON (always a single object).
  2. Read success, command, and optional requestId from the root.
  3. Read structured results from data.
  4. Read human text from message and failures from errors[].

Error objects

Parse failure example:

Global failures

Permission denied (command accepted at MQTT, then blocked by RBAC):
Unknown command:
If the session lacks CommandCall, the publish to $SYS/Coreflux/Command can be rejected before any Output message. Handle both MQTT-level denial and JSON success: false. See RBAC with LoT Rules.

Command Index

Most verbs also accept a dashed alias (-addRoute / --add-route). The table lists the MQTT form you publish. -updateData refreshes broker $SYS statistics and does not publish a reply on $SYS/Coreflux/Command/Output.

User Management

Create a user, then assign groups for USER IN GROUP in LoT Rules. Group commands require user-management permission on the authenticated MQTT session. See RBAC with LoT Rules.
-listUserGroups returns { username, groups, count } in data. Permission flags for -changeUserSettings include AllowedUserManagement, AllowedSystemConfiguration, and AllowedLogManagement.

Rules

Rules define access control. See Rules Overview, Rules Syntax, and RBAC. Lower priority number wins. -addRule accepts priorities from 100 to 1 000 000 only; custom ACL rules require Growth or Enterprise.
Rules are LoT code and can also be deployed from a LoT Notebook by running the cell that contains the definition.
Locked built-in system rules cannot be removed. Seed catch-alls (AllowPublishTopic / AllowSubscribeTopic / AllowConnect) may be removed to switch that operation toward default-deny — except Connect, where removing AllowConnect without a replacement leaves CONNECT ungated. See RBAC.
-restoreRules puts AllowPublishTopic, AllowSubscribeTopic, and AllowConnect back to their shipped ALLOW definitions. Missing seeds are re-added; overrides of those names are reset; locked built-ins and your other custom rules are left alone. Requires root or AllowedSystemConfiguration. No arguments.
-removeAllProjectRules removes permission rules owned by the active project. Built-in rules and operator-authored custom rules stay in place.

Models

-removeAllModels removes every Model on the broker.

Actions

Run an Action on demand

-runAction runs an Action immediately, regardless of its trigger.
Success means the command dispatched the Action. For this form, a failure inside the Action body is not in the command reply — watch $SYS/Coreflux/Actions/<name>/Trace (if tracing is on) or $SYS/Coreflux/Actions/<name>/Error. data.traceId identifies this execution. Callable Actions (those that declare INPUT) accept a JSON object of parameters:
The broker rejects a payload on a non-callable Action, invalid JSON, or a non-object JSON value. Topic-triggered Actions (ON TOPIC / ON CHANGE) accept trigger context instead of INPUT bindings when the JSON object contains a topic key. The Action runs synchronously; data includes status, published, durationMs, error, and traceId. You do not need to arm -actionTrace for this form.
The topic value must match the Action’s trigger pattern (including wildcards). This topic form does not apply to callables — their JSON object is always INPUT bindings, even if it contains a topic key. See Callable ACTIONs for INPUT / CALL ACTION.

Action tracing

Traces publish to $SYS/Coreflux/Actions/<name>/Trace. Arming auto-expires; data.expiresUtc tells you when. A { "topic": … } -runAction arms tracing for that one call and disarms afterward, unless a live -actionTrace session was already on.

Routes

-listRoutes places entries in data (name, type, connection, health). Unmonitored routes report "Unknown" for connection and health. -checkRouteConnection tests the named Route. Details such as routeType and connectionTime are in data. What “connected” means depends on the Route type — see the Route page (for example OPC UA Client or Modbus TCP Server). -routeCode returns template LoT for that Route type in data. -listTemplates lists available templates. -routeCertificates manages PKI for Routes that support certificate stores (OPC UA client and server). The argument is cert64: plus base64 of a minified JSON request (stores, list, inspect, trust, delete, export, import). Operation details are in data. See OPC UA Client — Certificate Management.
-discoverAIProviders probes configured LLM providers for reachability and models. API keys and host URLs come from secrets and environment variables (OPENAI_API_KEY, MISTRAL_API_KEY, ANTHROPIC_API_KEY, OLLAMA_HOST). An optional JSON object can override those values for the probe. Results are also published retained on $SYS/Coreflux/AI/Providers.

Diagnostics

-lotDiagnostic takes an entity kind (model, action, route, or rule) and the entity name.

Environment Variables and Secrets

See Environment Variables & Secrets for storage, substitution in LoT, and security notes.
-listEnv returns name/value pairs in data. -listSecrets returns names only — secret values never appear in command output.

Python Integration

Python scripts must start with # Script Name: YourScriptName. That name is what you pass to CALL PYTHON from a LoT Action.

Panels and Themes

Deploy dashboards written as DEFINE PANEL. -addPanel and -addVisu are the same command. See Defining Panels.
-updateVisuState takes DRAFT, PUBLISHED, or ARCHIVED. -addVisuFile lot64:<base64> deploys every DEFINE PANEL block from a .lot file encoded as base64. Theme commands: -addTheme (full DEFINE THEME body), -removeTheme, -listThemes, -removeAllThemes. -listPanels and -listThemes also publish catalog data on $SYS/Coreflux/VoT/Panels/ and $SYS/Coreflux/VoT/Themes/.

Projects

A project is a folder of .lotnb files under the broker data path. See Project organization.
-loadProject and -unloadProject remove only entities the broker attributes to that project. Actions, Models, Routes, Python scripts, and panels you added with -addAction (and similar) while no project was active stay running.
Names may contain spaces or hyphens (-loadProject Traceability System or -loadProject "Traceability System"). / is not allowed. -listProjects returns name, active, git metadata, and related fields in data. -loadProject returns { project, entities, counts } in data. counts.actions lists user-defined Actions only (not Route-internal event Actions). Built-in permission rules are omitted. Per-entity failures appear in warnings[]; success can still be true when the load finished with partial errors. The last loaded project is remembered across restarts unless you pass --project at startup. See Startup Options. -unloadProject tears down owned runtime entities and returns the broker to standalone mode. The folder stays on disk. -removeProject also deletes the folder. -getProject exports a zip (base64) on $SYS/Coreflux/Projects/<name>/download. -projectManifest returns hashes of stored files and declared entities so clients can compare a working copy without downloading the zip. The same JSON is published retained on $SYS/Coreflux/Projects/{name}/manifest.

License

-showInstanceKey returns the instance key in message. -installLicense takes the license file text (the same content you would read from a .license file), which is the usual path from HUB and other UIs.

Audit

-auditQuery takes a date (YYYY-MM-DD). Add -auditFilter field=value in the same payload to narrow results. -decryptAudit decrypts that day’s log; pair with -auditExport <path> to write JSON to a file. Decryption requires the audit key configured on the broker (COREFLUX_AUDIT_KEY).

Trace Logging

Capture broker log lines and republish matches to an MQTT topic.

Command Authorization

Not every user can run every command. Management gates such as CommandCall and per-entity creation flags are defined in LoT Rules. See Rules overview and RBAC.
Configure access control before any untrusted client can publish to $SYS/Coreflux/Command.

Next Steps

System ($SYS) Topics

Subscribe to command output, entity code, and broker telemetry.

Command Console

Run the same commands from Coreflux HUB without a separate MQTT client.
Last modified on August 28, 2026