mqttxively

How can I set the units in an Xively datastream via MQTT


I'm publishing the following MQTT request to the topic /v2/feeds/XXX.json, where XXX is the name of my feed.

{
  "version": "1.0.0",
  "datastreams": [
    {
      "id": "test",
      "current_value": 25,
      "unit": "Celsius",
      "unit_symbol": "°C"
    }
  ]
}

When I look at the develop page on the Xively website, I see a new channel called test has been created with the value 25, but it has no associated units.

How can I set the units for a datastream using MQTT?


Solution

  • The proper json request is:

    {
      "version": "1.0.0",
      "datastreams": [
        {
          "id": "test",
          "current_value": 25,
          "unit": {
            "symbol": "°C",
            "label": "Celsius"
          }
        }
      ]
    }