Skip to main content

API Reference with Python Scripting

Overview​

MQTT Recorder provides scripting functions that allow you to create, read, update, and delete Recorder configuration settings programmatically.

These functions can be executed from any Ignition Scripting Scope and can be used to manage MQTT Recorder configuration and table definitions without manually configuring them through the Gateway Web UI.

The available functions are:

  • createConfig() — Creates a new configuration record.
  • readConfig() — Retrieves existing configuration records.
  • updateConfig() — Modifies an existing configuration record.
  • deleteConfig() — Deletes a configuration record.

Note: Configuration changes made through scripting do not have the same validation as changes made through the Web UI. For example, deleting a Tables configuration that is referenced by another configuration can result in an Internal Error in the Web UI.

createConfig()​

Creates a new MQTT Recorder configuration record.

Syntax​

system.cirruslink.recorder.createConfig(type, props)

Parameters​

ParameterTypeDescription
typeStringConfiguration type to create. Valid options are General and Tables.
propsDictionaryProperties for the new configuration record.

Supported Properties​

General Configuration​

PropertyType
IdLong
EnabledBoolean
DatasourceString
PartitionPeriodString

Table Configuration​

PropertyType
IdLong
TableNameString
EnabledBoolean
RecordTypeString
GroupIdString
EdgeNodeIdString
DeviceIdString
FilteredPropertiesString

Returns​

Returns a dictionary representing the newly created configuration record after it has been written to the database.

Added in MQTT Recorder 4.0.16.

Example​

props = {
"TableName": "rs_Event",
"RecordType": "Event",
"Enabled": True
}

system.cirruslink.recorder.createConfig(
"Tables",
props
)

readConfig()​

Retrieves MQTT Recorder configuration records.

Syntax​

system.cirruslink.recorder.readConfig(type)

Parameters​

ParameterTypeDescription
typeStringConfiguration type to read. Valid options are General and Tables.

Returns​

Returns a list of dictionaries representing the requested configuration records.

General Configuration Properties​

PropertyType
IdLong
EnabledBoolean
DatasourceString
PartitionPeriodString

Table Configuration Properties​

PropertyType
IdLong
TableNameString
EnabledBoolean
RecordTypeString
GroupIdString
EdgeNodeIdString
DeviceIdString
FilteredPropertiesString

Example​

tables = system.cirruslink.recorder.readConfig("Tables")

for table in tables:
print table["TableName"]

updateConfig()​

Updates an existing MQTT Recorder configuration record.

Syntax​

system.cirruslink.recorder.updateConfig(
type,
id,
collisionPolicy,
props
)

Parameters​

ParameterTypeDescription
typeStringConfiguration type to update. Valid options are General and Tables.
idLongID of the configuration record to update.
collisionPolicyStringUpdate behavior. Valid options are MergeOverwrite and Overwrite.
propsDictionaryProperties to update on the configuration record.

Collision Policies​

PolicyDescription
MergeOverwriteReplaces only the properties included in the request while preserving all other values.
OverwriteReplaces all properties in the record with the values supplied in the request.

Supported Properties​

General Configuration​

PropertyType
IdLong
EnabledBoolean
DatasourceString
PartitionPeriodString

Table Configuration​

PropertyType
IdLong
TableNameString
EnabledBoolean
RecordTypeString
GroupIdString
EdgeNodeIdString
DeviceIdString
FilteredPropertiesString

Returns​

Returns a dictionary representing the updated configuration record after it has been written to the database.

Added in MQTT Recorder 4.0.16.

Example​

props = {
"RecordType": "Alarm"
}

system.cirruslink.recorder.updateConfig(
"Tables",
1,
"MergeOverwrite",
props
)

deleteConfig()​

Deletes an MQTT Recorder configuration record.

Syntax​

system.cirruslink.recorder.deleteConfig(type, id)

Parameters​

ParameterTypeDescription
typeStringConfiguration type to delete. Valid options are General and Tables.
idLongID of the configuration record to delete.

Returns​

Returns a Boolean value:

  • True if the configuration record was successfully deleted.
  • False if the configuration record was not deleted.

Added in MQTT Recorder 4.0.16.

Example​

success = system.cirruslink.recorder.deleteConfig(
"Tables",
1
)

print success