Resolution Logic for Time Series Node

Hello Losant Team,

I built a workflow with a Time Series Node and the following settings:

  • custom time range
  • range end/duration defined by payload values
  • Aggregation - None

With such settings, Losant automatically puts resolution property to 1 minute and does not allow me to change this setting.

This setup works good for ranges less than a few days, but for a range of a few months 1 minute resolution seems to be small. In other words, it takes a while for such volume of data to be transferred to the front-end.

Is there a way automatically change resolution setting depending on duration value on the fly?

Hi @Alexander_Kondrov,

The reason this is blocked out is due to your Aggregation being set to none. It is not necessarily locking at 1 minute, it is returning every state reported in your selected time range, as the data is not being aggregated. If you toggle Aggregation to something other than “None,” the Resolution should become configurable; would an aggregation of something other than “none” work in your use case? :smile:

Thanks!
Julia

1 Like

Hi Julia,

Thank you for the prompt reply.
It does work and doesn’t at the same time. So, far I’ve changed the aggregation setting from None and divided flow to three different ranges (bigger time range - > bigger resolution). It looks a bit bulky. It would be nice to have a resolution settable by a payload value as well in the future.

image

Another question came up in addition. Is there a way to use Switch Node for value ranges. I.e. define path depending on X<1; 1<X<2; X>=2 ?

Hi @Alexander_Kondrov,

Yes, I see what you mean, it is a bit bulky! You might benefit from using the Losant API Node in place of the Data: Time Series Node. You can use the Data: Time Series Query resource, which allows for a more advanced configuration.

This means you can configure the options in a JSON Template, so you would be able to pull a value from your payload for the resolution. The query would look like so:

{
  "end": 0,
  "duration": {{data.duration}}, /// these are my payload values
  "resolution": {{data.resolution}},
  "aggregation": "MEAN",
  "attributes": [
    "voltage"
  ],
  "deviceTags": [
    {
      "key": "floor",
      "value": "8"
    }
  ]
}

For the Switch node question, I had never actually tried this myself, and since my first couple ideas didn’t work out so well, I think this would be an excellent feature request and have put it into our system. The solution that did eventually work was a Function Node and a Switch, and it should help to decrease your number of nodes. I set up my workflow like so:

The value is stored on my payload at data.x, and I do my conditionals in my Function Node, putting a string value on the payload for the case that is true:

if(payload.data.x<=1){
  payload.data.result="less than one"; // Creating and setting result on the payload
}
else if(payload.data.x>=2){
  payload.data.result="greater than two";
}
else{
  payload.data.result="between one and two";
}

Over in my switch statement, I use my new data.result value to determine which path to take:

I decided to take the Function Node route as it will make things easier if your conditionals were to grow in number, or become more complicated. I have created a feature request for expression based switching, and will update you in the future should that become available.

Let me know how else I can help!
Julia

1 Like

Julia,

Thank you for your reply. I will consider using Losant API Node for a configurable resolution setting, I need to learn more about it first from Losant docs, though.

Regarding Function + Switch approach, I was thinking about it as well, but it would complicate later debugging maintenance. Therefore, I will wait until this is implemented as a standard feature.

1 Like