Skip to content

MQTT Broker Commands

The Coreflux MQTT broker provides a rich set of commands that can be used to manage assets, users, rules, models, actions, and more. These commands can be published to the $SYS/Coreflux/Command topic to interact with the broker.

This page documents all available commands, their parameters, and usage examples.

Command Format

Commands are sent to the broker via MQTT messages published to the $SYS/Coreflux/Command topic. The general format is:

-commandName [parameters]

For example:

-addUser admin password

Asset Management Commands

Command Description Format Since Version
-install Installs an asset -install assetName 1.2.0
-install-with-token Installs an asset using an authentication token -install-with-token assetName token 1.2.0
-uninstall Uninstalls an asset -uninstall assetId 1.2.0
-uninstall-with-token Uninstalls an asset using an authentication token -uninstall-with-token token assetId 1.2.0
-uninstall-multiple Uninstalls multiple assets -uninstall-multiple all bearerToken 1.4.2
-run Starts an asset -run assetId 1.2.0
-stop Stops an asset -stop assetId 1.2.0
-asset-default-config Resets asset configuration to default -asset-default-config assetId 1.2.0
-asset-help Shows help for a specific asset -asset-help assetId 1.2.0
-asset-schema Shows the configuration schema for an asset -asset-schema assetId 1.5.3
-asset-config-save Saves a new configuration for an asset -asset-config-save assetId configJson 1.2.0
-asset-config-load Loads the configuration for an asset -asset-config-load assetId 1.2.0
-asset-policy-set Sets the restart policy for an asset -asset-policy-set assetId policyValue 1.2.0
-asset-name-set Changes the name of an asset -asset-name-set assetId newName 1.2.0

Examples

Installing an Asset

-install moduleName

Starting an Asset

-run assetId

Stopping an Asset

-stop assetId

Saving Asset Configuration

-asset-config-save assetId {"param1": "value1", "param2": 123}

User Management Commands

Command Description Format Since Version
-addUser Adds a new user -addUser username password 1.2.0
-removeUser Removes a user -removeUser username 1.2.0
-changeUserPassword Changes a user's password -changeUserPassword username newPassword 1.2.0
-changeUserSettings Changes settings for a user -changeUserSettings username settingsJson 1.2.0

Examples

Adding a User

-addUser operator password123

Changing User Password

-changeUserPassword operator newPassword456

Changing User Settings

-changeUserSettings operator {"AllowedUserManagement": true, "AllowedSystemConfiguration": false}

System Commands

Command Description Format Since Version
-updateData Updates data and refreshes system state -updateData 1.2.0
-add-trace-log Adds a trace log point -add-trace-log level=Debug,expires=3600,messageContains=error 1.4.1
-list-trace-logs Lists all active trace points -list-trace-logs 1.4.1
-remove-trace-log Removes a specific trace point -remove-trace-log topicName 1.4.1
-remove-all-trace-logs Removes all active trace log points -remove-all-trace-logs 1.4.1
-system-restore Restores system from a backup -system-restore backupJson 1.7.0 (to be released)
-system-backup Creates a system backup -system-backup 1.7.0 (to be released)

Trace Logging Commands

Trace logging commands allow you to capture and monitor specific log events in the Coreflux system.

Adding a Trace Log Point

-add-trace-log level=Information,expires=3600,messageContains=5a7e2146-8b4d-42fa-9b6c-6835f38af8bd

This command creates a trace point that will: - Capture logs at the Information level or higher - Automatically expire after 3600 seconds (1 hour) - Only capture logs containing the asset's GUID

Note: Asset IDs in Coreflux are GUIDs (Globally Unique Identifiers) that are automatically assigned when an asset is installed. These GUIDs appear in log messages related to the asset, making them useful for filtering logs.

Available log levels (in ascending order of severity): - Debug - Information - Warning - Error - Fatal

The expires parameter is specified in seconds and determines how long the trace point will remain active.

Listing Trace Log Points

-list-trace-logs

Returns a list of all active trace points, including their topics, log levels, formats, and expiration times.

Removing a Specific Trace Log Point

-remove-trace-log $SYS/Coreflux/Log/Traces/5a7e2146-8b4d-42fa-9b6c-6835f38af8bd

Removes the trace point for the specified topic. The topic name typically includes the asset's GUID or other identifier that was used when creating the trace log point.

Removing All Trace Log Points

-remove-all-trace-logs

Removes all active trace points.

LOT (Language of Things) Commands

LOT commands are used to manage rules, models, actions, and routes within the Coreflux broker.

Rules

Command Description Format Since Version
-addRule Adds a new permission rule -addRule ruleDefinition 1.4.1
-removeRule Removes a permission rule -removeRule ruleName 1.4.1

Examples

Adding a Rule
-addRule DEFINE RULE AllowUserCreation WITH PRIORITY 1 FOR UserManagementCreation
    IF USER HAS AllowedUserManagement OR USER IS "root" THEN
        ALLOW
    ELSE
        DENY
Removing a Rule
-removeRule AllowUserCreation

Models

Command Description Format Since Version
-addModel Adds a new model -addModel modelDefinition 1.4.8
-removeModel Removes a model -removeModel modelName 1.4.8
-removeAllModels Removes all models -removeAllModels 1.4.8

Examples

Adding a Model
-addModel DEFINE MODEL TemperatureModel WITH TOPIC "processed/temperature"
    ADD "celsius" WITH TOPIC "raw/temperature" AS TRIGGER
    ADD "fahrenheit" WITH (celsius * 9/5 + 32)
    ADD "status" WITH IF celsius > 25 THEN "hot" ELSE "cool"
Removing a Model
-removeModel TemperatureModel

Actions

Command Description Format Since Version
-addAction Adds a new action -addAction actionDefinition 1.50
-removeAction Removes an action -removeAction actionName 1.50
-removeAllActions Removes all actions -removeAllActions 1.50
-runAction Runs a specific action -runAction actionName 1.50

Examples

Adding an Action
-addAction DEFINE ACTION SystemHeartbeat
ON EVERY 60 SECONDS DO
    PUBLISH TOPIC "system/status" WITH "alive"
Removing an Action
-removeAction SystemHeartbeat
Running an Action Manually
-runAction SystemHeartbeat

Routes

Command Description Format Since Version
-addRoute Adds a new route -addRoute routeDefinition 1.5.5
-removeRoute Removes a route -removeRoute routeName 1.5.5
-removeAllRoutes Removes all routes -removeAllRoutes 1.5.5

Examples

Adding a Route
-addRoute DEFINE ROUTE CloudBridge WITH TYPE MQTT_BRIDGE
    ADD SOURCE_CONFIG
        WITH BROKER SELF
    ADD DESTINATION_CONFIG
        WITH BROKER_ADDRESS "cloud.example.com"
        WITH BROKER_PORT 8883
        WITH CLIENT_ID "edge-device-1"
    ADD MAPPING temperature
        WITH SOURCE_TOPIC "sensors/+/temperature"
        WITH DESTINATION_TOPIC "devices/edge-1/+/temp"
        WITH DIRECTION "out"
Removing a Route
-removeRoute CloudBridge

Diagnostics

Command Description Format Since Version
-lotDiagnostic Changes the LOT diagnostic settings -lotDiagnostic level 1.6.0

Examples

Adding a Rule
-addRule DEFINE RULE AllowUserCreation WITH PRIORITY 1 FOR UserManagementCreation
    IF USER HAS AllowedUserManagement OR USER IS "root" THEN
        ALLOW
    ELSE
        DENY
Removing a Rule
-removeRule AllowUserCreation

Command Line Usage

These commands can also be used with the Coreflux CLI tool using the same syntax but with additional options:

coreflux-cli -addUser operator password123 -requestUser admin

Additional CLI options:

Option Description Example
-bt, --base-topic Sets the MQTT base topic --base-topic custom/topic
-requestUser, --request-user Specifies the requesting user --request-user admin
-h, --help Displays help information --help
-l, --list Lists all assets --list

Command Authorization

Commands are subject to authorization rules defined in the broker. Not all users may have permission to execute all commands. See the Rules documentation for information on setting up access control.

System Topics for Monitoring

In addition to command topics, the Coreflux broker provides several system topics that can be used to monitor the current state of the broker and its components:

System Topic Description
$SYS/Coreflux/Config Contains the broker configuration settings
$SYS/Coreflux/Config/users Contains the list of user accounts (accessible if the user has permission)
$SYS/Coreflux/Rules Provides the list of all defined rules in the broker
$SYS/Coreflux/Actions Contains the list of all defined actions
$SYS/Coreflux/Routes Provides the list of all defined routes
$SYS/Coreflux/Models Contains the list of all defined models
$SYS/Coreflux/Assets/# Provides status and information about installed connectors
$SYS/Coreflux/Logs/# Contains system logs and diagnostics
$SYS/Coreflux/Status/# Provides broker status information

By subscribing to these topics, you can monitor the current state of the broker, track changes to configurations, and maintain awareness of your IoT environment's components.