MQTT
Basic properties and requirements
MQTT versions 3.1.0 a and 3.1.1 are supported
Any device must be registered in the Mervis cloud. Connection parameters are provided upon the registration (DeviceID, user name and password)
possibility of a dynamic variable set (devices can specify what variables they publish)
only built-in types are supported (bool, integers, floating point numbers, string)
no commands/set point yet
support for secured channel. A device can use secure or non-secure connection
General behavior of the clients
Connect
Publish/Subscribe
Registration of available variables
Informs the subscribers of available variables
Publish message with “At least once delivery”
Topic: deviceId/TagConfiguration
Combination of the collection ID and Tag must be unique for every device!
Payload: UTF-8 JSON document
/FormatId: (string), message ID
/ApiVersion(int), version of
API
/Complete (bool), must be true now
/Collections (Array of collection elements)
/Id (int), ID of the collection
/CollectionName (string)
/SampleRate (int), collection sample rate in ms
/PublishInterval (int), collection publish interval in ms
/TagData (Array of variable descriptions)
/Tag (string), ID of the variable
/Unit (string), unit of the variable
/ValueType (string), ST type; only simple types are supported
Example
{
"FormatId": "TagConfiguration",
"ApiVersion": 1,
"Complete": true,
"Collections": [{
"Id": 1,
"CollectionName": "Building 1",
"SampleRate": 60000,
"PublishInterval": 60000,
"TagData": [{
"Tag": "Temperature1",
"Unit": "ºC",
"ValueType": "real"
},
{
"Tag": "Humidity",
"Unit": "%",
"ValueType": "word"
}]
},
{
"Id": 2,
"CollectionName": "Building 2",
"SampleRate": 120000,
"PublishInterval": 240000,
"TagData": [{
"Tag": "Water flow",
"Unit": "m3/h",
"ValueType": "byte"
},
{
"Tag": "Current phase L1",
"Unit": "A",
"ValueType": "lreal"
}]
}]
}
Variable values
Publishes values of variables
Publish message with “At least once delivery”
Topic: deviceId/TagValues
Payload: UTF-8 JSON document
/FormatId: (string), message ID
/ApiVersion(int), version of
API
/CollectionId (int), identification of the collection
/TagData (Array of value items)
/Time (datetime), timestamp in ISO format (YYYY-MM-DDTHH:MM:SSZ), ideal is a UTC form
/Values (Collection of Tag and value tuples)
Example
{
"FormatId": "TagValues",
"ApiVersion": 1,
"CollectionId": 1,
"TagData": [{
"Time": "2018-03-27T17:19:23.720+02:00",
"Values": {
"Temperature1": 15.52,
"Humidity": 21
}
}]
}
Variable values
Publishes values of variables
Publish message with “At least once delivery”
Topic: $deviceId/mervis/values or $deviceId/mervis/values/*
Payload: UTF-8 JSON document
Example
{
"d" : {
"name:MyHomeTemperature, type:generic_sint64, unit:°C" : [ 0 ],
"number C" : [ 0 ],
"Bit" : [ false ],
"My array" : [ 0, 10, 20 ]
},
"ts" : "2020-08-27T07:10:24.360316"
}
Command registration
Our supported types
“generic_bool”
“generic_sint8”
“generic_uint8”
“generic_sint16”
“generic_uint16”
“generic_sint32”
“generic_uint32”
“generic_sint64”
“generic_uint64”
“generic_float32”
“generic_float64”
“generic_string”
“generic_datetime”
Create a subcribe topic for executing command