User Tools

Site Tools


user:mqtt_message_formats

MQTT Message Formats

Zibawa contains an interpreter to transform a MQTT message into data to be stored in a database and then viewed as a graph. In order to do this the message data must be sent in a format which is recognizable to the interpreter.

Message Format

JSON format

The best message format to use is JSON. The Zibawa interpreter will decode any JSON message, and load the contents into the database.

For example {“value”:5} or {“value”:5.7, “status”:“OK”}

Numeric Format

A message containing a float number will be loaded with a key of “value”

String Format

A message which cannot be read as JSON will be loaded as text.

eg. {bad JSON, value 5} will be loaded as an entire string. This is probably not very useful, but is default behaviour to help in debugging.

Keywords

Certain keywords must be avoided as JSON keys, because they are used by Zibawa or the underlying databases. See list of keywords to avoid in Zibawa

timestamp

The Zibawa interpreter will look for a field in a JSON message called “timestamp”. If it can succesfully parse the timestamp, then this value will be used to timestamp the data.

If no timestamp is found, or if the parsing is unsuccesful (date formats can be tricky) then Zibawa will add a timestamp on arrival.

numeric values

numeric values can be a added using the following format

  • “value”:10
  • “value”:“10”
  • “value”:“15,004”
  • “someOtherValue”: 10

would all be valid numeric values. The use of quotes is recommended but not necessary. the choice of the index key (in this case “value”) is not important, so long as a reserved key (such as “timestamp”) is not used.

non-numeric values

string values can be added to the data using the following format

  • “city”:“Barcelona”
  • “status”:“on”
  • “colour”: “green”

are all valid non-numeric values

mixing of numeric and non-numeric values

It is not possible to mix numeric and non numeric values in the same index. Once an index has been defined as numeric (by sending data containing a given format) then any data sent using a non numeric value will cause the entire message to be discarded.

Hooks

Zibawa provides the possibility to enrich your data with data stored in a database against a “hook”. Typically applications of this are barcodes or RFID tags. For further information see Using Zibawa with RFID or BarCodes

user/mqtt_message_formats.txt · Last modified: 2017/07/25 11:28 by matt