Time in Device state node

If I use a JSON template as data method and have it defined as something below, will it use the included time and ignore the shown options? I see no way of telling it to use the time value from the JSON template.

image

[
  {
    "time": "2016-06-13T04:00:00.000Z",
    "data": {
      "attr1": "value1a",
      "attr2": "value2a"
      
    }
  },
  {
    "time": "2016-06-13T05:00:00.000Z",
    "data": {
      "attr1": "value1b",
      "attr2": "value2b",
    }
  }
]

Hey Lars,

Could you tell me more about what your use case is for this? I think understanding more about what you are trying to do in Losant will help me in giving you a more accurate response.

As for understanding those three options better, we have this documented in the Device: State Node docs. Specifically:

This is the time at which the workflow run began (corresponding to the time property in the original trigger’s payload).

So, if you have a payload that looks like:

{
  "applicationId": "",
  "applicationName": "Heath's Testing Application",
  "data": {
    "devices": [
      {
        "data": {
          "attr1": "value1a",
          "attr2": "value2a"
        },
        "time": "2016-06-13T04:00:00.000Z"
      },
      {
        "data": {
          "attr1": "value1b",
          "attr2": "value2b"
        },
        "time": "2016-06-13T05:00:00.000Z"
      }
    ]
  },
  "flowId": "61a7ad157c09b4b404b60fa3",
  "flowName": "get devices ",
  "flowVersion": "develop",
  "globals": {
  },
  "relayId": "222222222222bbbbbbbbbbbb",
  "relayType": "apiToken|experienceUser|flow|public|user",
  "time": "2021-12-01T18:37:19.013Z",
  "triggerId": "61a7ad157c09b4b404b60fa3-53DAB1oui4QNVNNIUTLiY",
  "triggerType": "virtualButton"
}

The option you have selected will use the root time (i.e. "time": "2021-12-01T18:37:19.013Z").

Again, more information about your use case will really help me give you a better, more accurate answer.

Heath

@Lars_Andersson,

After some internal discussion, I have some more information for you.

When defining your state report as a JSON template or a payload path, the Device: State Node accepts a number of different formats for the state data.

The option you may be looking for is the last option explained in State Object Formats.

Using this form, you can send multiple state reports with different timestamps at once.

If the time option is on the full device state object, the time option set in the node configuration will be ignored.

This may be a better answer to your original question. Please let me know if it is, or if you need any more clarification.

Thank you,
Heath

In a Device State node, I have defined the JSON Template shown below.
It appears to be working with “Use the time of the current payload” setting.

[

  {

  "time":"{{data.stateResult.result.temp_avg.time}}",

  "data":{

      "{{current.record.value.station}}_temp_avg" : "{{data.stateResult.result.temp_avg.value}}" 

      }

  },

{

"time":"{{data.stateResult.result.pressure_avg.time}}",

"data" :{  

    "{{current.record.value.station}}_pressure_avg" : "{{data.stateResult.result.pressure_avg.value}}"

     }

  }

]