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