Configuring the Platform through the API
The Export MQTT Service can be used to publish data into SmartWorks IoT using the MQTT credentials and topic for each thing (see the Credentials panel of the Thing in the AnythingDB).
The Edge API is currently not synced with the Cloud API. You need to create a Thing in the AnythingDB on the Cloud first, before creating the twin at the Edge using the API client. The thingId generated on the Cloud side needs to be used when creating the Thing at the Edge.
Things
The following example can be used if the Virtual Meter driver has been installed.
Replace :thingId
with the actual thingId created on the Cloud.
A Virtual Meter can be created by POSTing to:
POST /things
{
"@context": [ "https://www.w3.org/2019/wot/td/v1",
{
"swx": "https://swx.altairone.com/schemas"
}
],
"@type": [
"swx:Meter", "swx:Virtual"
],
"id": "/things/:thingId", "title": "My Virtual Meter", "properties": { "UD_DTYPE_KWH_ODM": { "title": "UD_DTYPE_KWH_ODM",
"description": "",
"type": "number", "readOnly": true
},
"UD_DTYPE_KW_AVG": {
"title": "UD_DTYPE_KW_AVG",
"description": "",
"type": "number",
"minimum": 5,
"maximum": 30,
"readOnly": true
},
"dataUsagePollSecs": {
"title": "Data Usage Poll Secs",
"description": "",
"type": "integer",
"readOnly": false
}
}
}
Any property that is not readOnly (like dataUsagePollSecs in this example) can be “set” afterwards but using the endpoint:
PUT /things/{thingID}/properties/{property}
{
"{property}": {value}
}
Configure the Edge Compute Platform System for Publishing
To configure the Edge Compute Platform system for publishing, first add a message template (optional), then a client for the MQTT broker, and then a publisher using the client and template.