1

I created a smartREST template for measurement via "device management -> smartREST templates". I send the reading via MQTT:

s/uc/mytemplateID
777,123,stringValue

The message arrives because I can see it through the API:

{  
   "time":"2018-07-03T15:36:13.237+01:00",
   "id":"47638",
   "self":"https://myDomain.mydomain/measurement/measurements/47638",
   "source":{  
      "id":"20018",
      "self":"https://myDomain.mydomain/inventory/managedObjects/20018"
   },
   "type":"myType",
   "myStrValue":"stringValue",
   "myNumberValue":123
}

But I can not see it as a data point. I also can not see it under: "device management -> All devices -> myDevice -> Measurements" If the cause is that the incoming message does not have the expected format, then the question is, how can I use MQTT to send custom measurments with the expected format?

Thank you

c8yUser
  • 13
  • 5

1 Answers1

3

To be able to use Cumulocity standard features on your measurements, they must adhere to a certain standard. Transform your template to create measurements like this:

{ 
   "time":"2018-07-03T15:36:13.237+01:00",
   "id":"47638",
   "self":"https://myDomain.mydomain/measurement/measurements/47638",
   "source":{  
      "id":"20018",
      "self":"https://myDomain.mydomain/inventory/managedObjects/20018"
   },
   "type":"myType",
   "myFragment":{
      "mySeries":{
         "value":123,
         "unit":"aUnit"
      },
      "myOtherSeries":{
         "value":321,
         "unit":"anotherUnit"
      }
   }
}

Note that measurement values are always numeric, using string based values here may cause unwanted behavior again.

If you want to communicate string based status variables sending events or alarms is usually a better approach.

The template configuration to send such measurements should look like this: enter image description here

l2p
  • 420
  • 3
  • 9
  • many thanks for the answer. You wrote: "*Transform your template to create measurements like this* ..." that's exactly my question: how? How can I transform the template to create this measurements? I'm using MQTT – c8yUser Jul 04 '18 at 07:40
  • When configuring custom fields in your template you enter JSONPath keys that can address nested properties in your measurement. I have added an example to my answer. – l2p Jul 04 '18 at 09:57
  • Could you also share the format which needed for sending Event or Alarms – Ayush Jul 04 '18 at 12:01
  • @Ayush: Apparently "event" has no format request. I also used events with smartREST template and I can receive them as "event". – c8yUser Jul 04 '18 at 14:17