This is an old revision of the document!


MQTT

  • 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
  • ClientID corresponds to the DeviceID
  • User name and password
  • No special requirements considering flags or keep-alive periods (some reasonable value like 60 seconds are recommended)
  • Every topic starts with the DeviceId
  • The rest of the topic depends on the required functionality

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 o /FormatId: (string), message ID o /ApiVersion(int), version of API o /CollectionId (int), identification of the collection o /TagData (Array of value items)  /Time (datetime), timestamp in ISO format, 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
	}
}]

}

  • © Energocentrum Plus, s.r.o. 2017 - 2025