Workflow storage per device?

I’m a bit confused about Workflow Storage and whether values are stored on a per-device basis or just globally. I can’t seem to find any explicit mention of this in the documentation.

Can the same key value pairs be used for multiple devices that fire the same workflow logic? Eg. let’s say I’m running a counter (with a Key named “counter”) but I have many devices and I’m using one workflow where I d like to track separate counters for each device. Are they many “counters” or is there only one for all the devices.



Hi @paul_wareham,

If your workflow is an application workflow, you will have one counter for the entire workflow. Thus, all of the counts for each device that runs through the workflow will add to the counter. It is one storage value that is associated with the workflow itself and is not tied to individual devices.

You could make use of device tags for the counters, but there are some limitations involved when displaying tags as they do not live update like device state. You could get around that by keeping the counter in a device tag, then report the tag value once a day as device state so you can display each day’s uptime (if that is still your use case :smile:). Otherwise, you could use Workflow Storage values with device IDs (counter[DEVICE_ID]) to keep them in storage.

I did assume here that you are using an Application Workflow, so if you are in an Edge Workflow, let me know! The behavior is a bit different :smile:


Hi @JuliaKempf

Yes they are Application Workflows.

It strikes me that using Workflow Storage with deviceId’s would be the most straightforward. But how can we get the deviceId into the Key name, just template it from the payload and keep one Counter key for each deviceId?

Hi @paul_wareham,

I just tested counter.{{data.deviceId}} in the storage nodes and it turned out pretty clean! My device ID is on the payload at data.deviceId:

I agree, I think it is probably the most straightforward way for your use case.

Let me know how else I can help :smile:

1 Like

@JuliaKempf great thanks!

I understand there is also a storage limit of 16 kB? I’m wondering if that will start to add up over many devices (hundreds)?

Hi @paul_wareham,

Workflows allow for a maximum of 16,384 storage keys at one time, so you should be peachy even having hundreds of devices. :smiley: