You are missing a couple of steps to getting this value to your device. Your function replaces the value of “FREQ” within the workflow, but the device must also be updated to have this value. I have replicated your workflow below so you can see the solution:
Here I have my workflow with a function that changes the value of rpm to 6 when rpm is 1. You can see in the debug log here that rpm has been changed to 6, but over on my dashboard, nothing has changed, the rpms are still at 1.
To remedy this, there are a couple of steps.
Updating State and Device: State
I begin by adding a Device State node, that will update my device’s value from 1 to 6, since I have set it to the new value. I run into a problem here: an infinite loop! In updating my device, I am also triggering the workflow again.
Now, I will add a conditional to ensure I don’t get stuck in a loop again.
, which can be seen in the debug tab, is different based on where the Device State has been updated from. Data coming from a device will read “device,” and data coming from a Device State node will be labeled “flow.”
Here are the two debug logs, the first is from the device, and the second is from the Device State node.
Now, my dashboard will reflect the correct value of 6, showing that I have successfully updated the device state from the function node.
Note: the value of FREQ will replaced on the original state report. If you’d like a new state report to be triggered by Device State, change Time to a value other than “use the time of the current payload”
Hopefully this helps!