[SOLVED] MQTT - can I please have "count" back?

Dear Ubidots-team,

I understand, that the reply-message is pretty long already for the MQTT-protocol.

I am using an Arduino MKR1000 and the todays relpy-message is (anyway) already exceeding the standard length of 128 bytes

but, it would be great, if I could have the “count” keyword/value back, which my application is used to from the bad, old “HTTP/GET”-days.

MQTT: {“timestamp”: 1467703753479, “context”: {}, “value”: 1.0, “id”: “xxxxxxxxxxxxxxxxxxxxxxxx”}
HTTP: {“count”: 8886, “next”: “http://things.ubidots.com/api/v1.6/variables/xxxxxxxxxxxxxxxxxxxxxxxx/values?page=2&page_size=1”, “previous”: null, “results”: [{“url”: “http://things.ubidots.com/api/v1.6/values/xxxxxxxxxxxxxxxxxxxxxxxx”, “value”: 1.0, “timestamp”: 1467383665858, “context”: {}, “created_at”: “2016-07-01T14:34:25.858”}]}

It would be great, if the MQTT and the HTTP/GET would be similar, wouldn’t it?

Dear Arduino-collegues, what do you think?
Which keyword make sense with MQTT?

from my side it would be:
“timestamp”:
“context”:
“value”
“count”:
“id” - by the way, what is it for … “id the unique id of the value”?
created_at: ?

Best regards
Juergen

Hi Juergen!

Is your use case subscribing to the last value? if so, there’s a special topic for this:

/v1.6/devices/{LABEL_DATA_SOURCE}/{LABEL_VARIABLE}/lv

“lv” at the end means it will only return the last value. (s. http://ubidots.com/docs/api/index.html#subscribe-to-a-variable).

Hope this helps.

Btw the “id” is indeed the id of the value. I know it’s useless in 99% of the cases, but it’s been there since the beginning cuz we wanted to adhere to REST best practices of having a unique ID per object.

Hi Agustin,

I think I understand the concept of subscribing to “last value” := “/lv”.
This is a really pretty nice, to allow easy handling/parsing on embedded devices like the Arduino.

However, this was not fully what I wanted to ask.

i am looking for the more verbose response and it turned out, that
using MQTT the there is NO “count” keyword/value returned (as it used to be with HTTP/GET).

And I am wondering, if it woud be possible to add it (again) to the return string.

Got it, well the GET returns a count as the default behaviour of the HTTP protocol. So we’re not sending any count ourselves; it is part of the HTTP protocol. As a reference, here’s what we return in the payload in both APIs:

REST API response:

[
   {
       "url": "http://things.ubidots.com/api/v1.6/values/573644685753c902de57d125", 
       "value": 6.0, 
       "timestamp": 1463174248257,
        "context": {},
        "created_at": "2016-05-13T21:17:28.257"
   }
]

The MQTT API Response is a simplified version of the above:

{
    "timestamp": 1467903014503, 
    "context": {}, 
    "value": 6.0, 
    "id": "577e6c2676254217693ab619"
}

So we’re not thinking about adding a count to the MQTT response payload for now, in order to keep the JSON response consistent with the REST API.