[Solved] Device State Node throttle and blocking?

I am having an issue with one of my workflows and I think it may be due to either device state throttling or writing/reading an attribute too quickly.

“Device Send State is limited to 30 calls in a 15-second window (per device) - on average, 2 calls per second. This matches the limiting that occurs when sending messages over MQTT”.

Essentially, I have a workflow parsing a Google sheet that contains 100 lines of data. As each line is processed, I am updating / creating 3 attributes on the same device. So I am essentially updating the device state 300 separate times within a single workflow run. This spreadsheet could grow another few hundred lines.

My questions are the following:

  1. How can I determine if and when the “Device State” workflow node hits this throttling limit?
  2. Is the “Device State” workflow node blocking? Ie does it wait until the data is saved to the device before moving to the next node?

In regards to number two above, my problem could also be that I am writing to an attribute and then reading it again in the next loop iteration too quickly so that my read contains “stale” data since the previous write hasn’t finished yet.

Thanks!

I doubt you’re hitting the limit within the workflow, since we’re a little more lenient when state is reported with a workflow vs. an actual device connection.

Device state is not read-after-write, which means there’s no guarantee that the most recent state will be immediately available in a data query.

Loops can easily cause the workflow to timeout, especially if you’re looping over 100 items and each item is reporting state and doing a data query. I would likely guess this is the issue. Timeouts will be reported to the Debug Panel, so if you leave the workflow editor open, you might be able to catch this error.

The Device State node does accept an array of states, which could solve your problem. You can use the loop (or function node) to build up an array on the payload and then report all of them in a single request. Your array would look something like this:

[
  { "time" : millisecondsSinceEpoch, "data" : { "attribute1" : "value", "attribute2" : "value" }},
  { "time" : millisecondsSinceEpoch, "data" : { "attribute1" : "value", "attribute2" : "value" }},
  { "time" : millisecondsSinceEpoch, "data" : { "attribute1" : "value", "attribute2" : "value" }}
]

Thanks for the clarification!

I will try storing everything on the payload and then saving all at once.