Device State Node, Loops through State and Workflow

I am currently running in to some issues using the Device State Node and a Workflow.
I am attempting to listen for all sensors of a certain type that are connected via losant (currently maybe 10-20 sensors — but evenutally there will be 100s - 1000s of sensors reporting to this workflow).
Each sensor reports in its state with 26 attributes per payload.
Several sensors will report in within a few seconds/milliseconds (because the gateways wait to push the sensor’s state until a time window has passed and then sends the message via MQTT) for all connected sensors.
I am attempting to use a loop to iterate over all the attributes to look at 4 specific alarm attributes in each payload to see if there are non-zero values in any of them.
If there are non-zero values, I want to build a message based on some other device information, look up the users who belong to the experience group connected to the gateway and then loop through the users sending a twilio message to each one.

It seems that I am not getting all the messages that I should when these sensors report state and it goes in to my first loop node.
I only get through 9 of the attributes before the next sensor starts its first run through the loop.
Any suggestions for how to handle something like this, or if its even possible at the rate?

FYI (it seems this happens even with the simplest of loops just adding in a debug node within the loop):

Hi @Leo_Bach1,

The debug messages are throttled, which is likely why you are seeing only nine attributes coming up in the log. Though the log may not display all 26 debug messages, the loop is likely still completing. You could add a Delay Node inside of the loop and configure it for about 100 milliseconds to slow it down enough to see all of the debug messages.


1 Like

Makes sense. How can I/ Is it possible to know if the workflow times out due to too much processing time within the loops (nested loops)?


Usually you will see an error in your debug log, however it was confirmed that this message could be throttled as well. The delay may help you better see the errors if they exist, and would likely be more apparent or frequent if the delay were added. You can also see the number of recent workflow errors next to your workflow name.

Let me know how else I can help!

1 Like

That helped me find my error… trying to use array methods on objects. :sweat_smile:

1 Like