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
| Parameter | Type | Description |
|---|---|---|
type | String | Configuration type to create. Valid options are General and Tables. |
props | Dictionary | Properties for the new configuration record. |
Supported Properties
General Configuration
| Property | Type |
|---|---|
Id | Long |
Enabled | Boolean |
Datasource | String |
PartitionPeriod | String |
Table Configuration
| Property | Type |
|---|---|
Id | Long |
TableName | String |
Enabled | Boolean |
RecordType | String |
GroupId | String |
EdgeNodeId | String |
DeviceId | String |
FilteredProperties | String |
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
| Parameter | Type | Description |
|---|---|---|
type | String | Configuration type to read. Valid options are General and Tables. |
Returns
Returns a list of dictionaries representing the requested configuration records.
General Configuration Properties
| Property | Type |
|---|---|
Id | Long |
Enabled | Boolean |
Datasource | String |
PartitionPeriod | String |
Table Configuration Properties
| Property | Type |
|---|---|
Id | Long |
TableName | String |
Enabled | Boolean |
RecordType | String |
GroupId | String |
EdgeNodeId | String |
DeviceId | String |
FilteredProperties | String |
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
| Parameter | Type | Description |
|---|---|---|
type | String | Configuration type to update. Valid options are General and Tables. |
id | Long | ID of the configuration record to update. |
collisionPolicy | String | Update behavior. Valid options are MergeOverwrite and Overwrite. |
props | Dictionary | Properties to update on the configuration record. |
Collision Policies
| Policy | Description |
|---|---|
MergeOverwrite | Replaces only the properties included in the request while preserving all other values. |
Overwrite | Replaces all properties in the record with the values supplied in the request. |
Supported Properties
General Configuration
| Property | Type |
|---|---|
Id | Long |
Enabled | Boolean |
Datasource | String |
PartitionPeriod | String |
Table Configuration
| Property | Type |
|---|---|
Id | Long |
TableName | String |
Enabled | Boolean |
RecordType | String |
GroupId | String |
EdgeNodeId | String |
DeviceId | String |
FilteredProperties | String |
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
| Parameter | Type | Description |
|---|---|---|
type | String | Configuration type to delete. Valid options are General and Tables. |
id | Long | ID of the configuration record to delete. |
Returns
Returns a Boolean value:
Trueif the configuration record was successfully deleted.Falseif the configuration record was not deleted.
Added in MQTT Recorder 4.0.16.
Example
success = system.cirruslink.recorder.deleteConfig(
"Tables",
1
)
print success