Record data back in time

Hi,
I am getting compressed data from a device. As an example it will give me each hour the temperature data every 20min.
How can I attach this data to Losant?
I would like to reconcile the data by updating attributes in the past.
Am I clear?
Thanks for your feedback

Assuming you’re using our MQTT broker to report state, you can actually report multiple states at different timestamps in one request.

A typical, single, “right now” state report’s payload looks like the following:

{
  "data": {
    "temp": 60
  }
}

But in addition to that,

  1. You may optionally include a time property alongside the data property to pass a custom time for the state report. This can be in a number of formats.
  2. You may pass multiple state reports by formatting them as an array of objects.

So, in your case, the payload you send may look like the following:

[
  {
    "time": "2018-04-10T12:00:00",
    "data": {
      "temp": 60
    }
  },
  {
    "time": "2018-04-10T12:20:00",
    "data": {
      "temp": 62
    }
  },
  {
    "time": "2018-04-10T12:40:00",
    "data": {
      "temp": 63
    }
  }
]

Hey Dylan
I am using Webhook with sigfox.
Basically I get data compressed over 2 frames one after another
c90002540cbf00eb00eb00eb
and then
c91000eb00ea00
The way it works is that it means that the temperature info is as followed:
t0=bf00
t0-20min=eb00
t0-40min=eb00
t0-60min= eb00
t0-80min=eb00
t0-100min=ea00
How can I enter this as timeseries data for the device under the attribute temperature?
Thanks - is it clearer?

This should be doable. Can you provide a few more details about how the data is packed?

What are the units of t0? How is the data encoded?

What are the temperature units and how is that data encoded?

It looks like it’s probably encoded as hex. With only two bytes to represent time, I’m not sure what those units could be.

Hi Brandon

T0 would be the timestamp of the message.

The data is encodes in little endian:

eb00 --> hex2dec(0x00eb)/10=19,5C

Time is not encoded. We know the time because the interval is the same 20min.

Basically the device sends 6 temp value every 2hs = 1 temp value every 20min

Francois Oudot

Sales engineer

+33 6 71 76 36 66

Hey guys,
So I moved forward and now I have an array as you described22%20PM
Now to update the device state, what should I do? Should I create 3 Device State or is there a fastest method as you seem to describe with MQTT?
Thanks for your feedback.

Very nice! Converting your raw data into a JSON object was definitely the hardest part, which it looks like you’ve successfully accomplished.

You can actually pass the temp array, as is, to the Device State Node to record all of those as separate state messages.

To do this, change the Input Method to Payload Path and set the path’s value to newdata.temp (the path may be different, your screenshot cuts off the top part). The Payload Path option can accept an array of multiple state messages. Since you have the time field set, that will be used as the timestamp for each of those messages.

Hey Brandon,
I can’t make it work… The time difference does not work. Does it accept Epoch time?

Here are the 2 things I tried unsuccesfully:

1/ With the payload path as described
Payload is:
28%20PM
Device state is:
08%20PM
–> Does not work

2/ By putting several device state
Payload is the same
The 3 device states are configured as follow:
16%20PM
–> Does not work when using the time at the specified payload path but does work if I put one of the above options “use the time of the current payload” or “use the current time”

What am I missing here?
Thanks for your feedback.

It looks like your timestamp is seconds since epoch, is that correct?

The time field accepts a few different formats, so you’ll have to make sure your time is in one of those units.

A good way to debug this would be to open your application overview page in another tab or window while the workflow is reporting state. If the time is not accepted, an error message will be placed in the application communication log.