I have a machine running that applies grease to train track. It applies once per train that passes it. One cycle = one application. Data from controller is just a counter that only resets when the controller is restarted. I want to display a bar graph that shows how many cycles it ran on that day. Is there a way to achieve this without resetting the machine once a day?
Hi @Lyndon_Walker !
There are a few different ways to accomplish this. From a high level, my recommendation is to create a workflow that utilizes:
-
A Timer Trigger set to run daily (at 00:00 for example). -
Storage Get / Set Nodes to maintain workflow storage values that can be used to compare the most recently reported value with the previously reported value.
-
A Device: Update Node that updates a new attribute value, which can then be referenced in your dashboard block.
Give me a bit and I’ll return to this thread with an example workflow.
I’ve attached a workflow file that will hopefully help get you started. You’ll definitely want to tweak it to fit for your use:
set-daily-count-develop.flow (4.2 KB)
Here’s an explanation of the nodes used:
-
Device: State Trigger - Activates any time the selected device sends a device state report containing any attribute other than the
newCountattribute that we’ll be defining downstream. For this example, let’s say the “total cycles since boot” attribute is calledtotalCountand is available on the initial payload atdata.totalCount. -
Storage: Get Value Node) - We’re using workflow storage to store the previously reported
totalCountvalue, from the previous execution of this workflow. Let’s call thislastTotalCountand place it on the payload asworking.lastTotalCount. -
Math Node - Here I used
max( ( {{ data.totalCount }} - {{ working.lastTotalCount }} ), 1 ). This determines the difference betweendata.totalCountandworking.lastTotalCount. The result is stored asworking.newCount.- This example uses the
maxfunction to ensure the result is always at least1, that way if the machine is reset and thetotalCountattribute goes back to, say,0or1, you never have a resulting value of less than1when subtracting the previously reportedlastTotalCountvalue. Of course, you’ll want to adjust this logic to your use-case.
- This example uses the
-
Device: Update Node - Creates a new attribute on the device called
newCount, if the attribute doesn’t already exist on the device. -
Device: State Node Output Node - Sets the
newCountattribute value on the device from{{working.newCount}}. -
Storage: Set Value Node - Now that we’re done referencing the old
working.lastTotalCountvalue from workflow storage, we’re going to update it to the newly reported value we received on the payload atdata.totalCount.
Now you have a newCount attribute on the device. In a Bar Chart (or other time series dashboard block), you can set the Aggregation to Sum, which will add up all of the newCount values reported within the selected Duration (e.g. 24 hours):
Hopefully this is helpful! If you have any other questions, please don’t hesitate to ask.

