The following API calls are available for the MQTT Engine Module and can be executed within any of the available Ignition scopes.

There are sample API scripts available for each API call.

Configuration changes made through scripting do not have the same validation as when made through the UI. 

For example, deleting a Sets configuring that is being referenced by a Servers configuration will result in the UI showing an Internal Error. Follow the instructions here to recover the configuration.


APIs

Sample Scripts


Cirrus Link provides these scripts as examples only, they are not supported or guaranteed to meet any particular functionality. Cirrus Link cannot provide any assistance to modify these scripts to meet a particular need.


# Cirrus Link provides these scripts as examples only, they are not supported or guaranteed to meet any particular functionality. Cirrus Link cannot provide any assistance to modify these scripts to meet a particular need.

# Create new server set
serverProps = {}
serverProps["Name"] = "Server Set 1"
serverProps["Description"] = ""
serverProps["PrimaryHostEnabled"] = True
serverProps["PrimaryHostId"] = "MyPrimaryHost"
system.cirruslink.engine.createConfig("Sets", serverProps)

# Find server set Id
savedSets = system.cirruslink.engine.readConfig("Sets")
for config in savedSets:
	if config ["Name"] == "Server Set 1":
		serverSetId = config["id"]
 
# Create new server
serverProps = {}
serverProps["Name"] = "My Server"
serverProps["Enabled"] = True
serverProps["Url"] = "tcp://192.0.2.1:1883"
serverProps["ServerSetId"] = serverSetId
serverProps["Username"] = "MyUserName"
serverProps["Password"] = "MyPassword"
system.cirruslink.engine.createConfig("Servers", serverProps)

# Find server Id
savedServers = system.cirruslink.engine.readConfig("Servers")
for config in savedServers:
	if config ["Name"] == "My Server":
		serverId = config["id"] # Read server configuration

# Update server properties using MergeOverwrite
serverProps = {}
serverProps["KeepAlive"] = "60"
serverProps["ServerSetId"] = serverSetId
system.cirruslink.engine.updateConfig("Servers", serverId, "MergeOverwrite", serverProps)

# Delete server
system.cirruslink.engine.deleteConfig("Servers", serverId)

# Read alarms
system.cirruslink.engine.readAlarms()
# Example list returned for 4 alarms
[{59ff123d-62af-4272-83c8-cbc444891982={"id":"59ff123d-62af-4272-83c8-cbc444891982","name":"Alarm4","alarmSource":"prot:MQTT:/src:Ignition-pi5:/prov:edge:/tag:Edge Nodes/G1/E1/D1/tag1:/alm:Alarm4","priority":"Critical","activeTime":1731373561034,"groupId":"G1","edgeNodeId":"E1","deviceId":"D1","state":"ActiveUnacked","ackedBy":null}, fa076e0f-bc37-4ce0-a7a3-709d2e2389b2={"id":"fa076e0f-bc37-4ce0-a7a3-709d2e2389b2","name":"Alarm1","alarmSource":"prot:MQTT:/src:Ignition-pi5:/prov:edge:/tag:Edge Nodes/G1/E1/D1/tag1:/alm:Alarm1","priority":"Low","activeTime":1731373531034,"groupId":"G1","edgeNodeId":"E1","deviceId":"D1","state":"ActiveUnacked","ackedBy":null}, 2ac2c263-b552-49fc-a969-98313ca107b6={"id":"2ac2c263-b552-49fc-a969-98313ca107b6","name":"Alarm2","alarmSource":"prot:MQTT:/src:Ignition-pi5:/prov:edge:/tag:Edge Nodes/G1/E1/D1/tag1:/alm:Alarm2","priority":"Medium","activeTime":1731373541033,"groupId":"G1","edgeNodeId":"E1","deviceId":"D1","state":"ActiveUnacked","ackedBy":null}, 74a19264-8672-4e5b-ab9b-420c6aae7877={"id":"74a19264-8672-4e5b-ab9b-420c6aae7877","name":"Alarm3","alarmSource":"prot:MQTT:/src:Ignition-pi5:/prov:edge:/tag:Edge Nodes/G1/E1/D1/tag1:/alm:Alarm3","priority":"High","activeTime":1731373551034,"groupId":"G1","edgeNodeId":"E1","deviceId":"D1","state":"ActiveUnacked","ackedBy":null}}]

# Clear alarm
system.cirruslink.engine.clearAlarm("59ff123d-62af-4272-83c8-cbc444891982")