Threshold with duration

workflow
#1

Hi,
How can I create a workflow which will trigger an action when the device readings have crossed a threshold for X min.
For example the freezer temperature is above -20 c for more than 10 min?

1 Like
#2

Hi @Roi_Aranyi,

You will want to make use of a Timer Node and a Conditional Node. The Timer Node will trigger after a set amount of time, and the Conditional Node will give you a boolean that sends you right or left for true and false. So you will go right (true) if the freezer has been above -20 degrees, and perform some actions afterwards for handling the lower temperature (email notification, text notification, alert). The On Change Node may also provide some of what you are looking for, or you could do a timestamp comparison of the last recorded value to check for those 10 minutes (details found here).

There is also a feature request here that could benefit, so be sure to vote!

Let me know how else I can help,
Julia

1 Like
#3

Thanks Julia,
Will this solution ensure the temp was above -20 the all time or is just sampled in two different time points?

#4

Hi @Roi_Aranyi,

The solution I provided above is ideal for two time points in some use cases, but another engineer pointed out to me a better solution for your use case. It was recommended that you use the Storage: Set Value Node to store the current time if the temperature of the freezer goes above -20 degrees. Then, when your Device State workflow is triggered, you can compare the time of current workflow to the time you have just stored in workflow storage by subtracting one from the other in a Conditional Node. Then, if the time is over 10 minutes, you will be able to send a notification or perform an action from the workflow.

Let me know if an example would make this clearer!
Thanks,
Julia

1 Like
#5

Thanks again Julia,
I think I understand the general idea, just one question:
In the solution you’ve mentioned would each reading above the threshold will get the Set Value Node to keep current time?
How do I keep the Set Value Node from overriding the time of the first time the temp crossed the threshold?

#6

Hi @Roi_Aranyi,

You do not have to override the time for every cross of the threshold, but you are able to if your use case calls for it. I have built out an example workflow we can walk through:

The workflow below will store the time if the temperature is above -20, and will send a text alert if the temperature stays above -20 for longer than 10 minutes.

This workflow receives mock temperature values from my Virtual Button:

Then I get my stored value which I have named tempTime and put that value on the payload at data.lastTemp. If it is null, I will know that the temperature has been at the correct levels, but if it is not null, it will hold the time at which the temperature was too high.

Then I check my current temperature reading:

If it is below -20, it goes left, and my stored tempTime value is reset to null.

If it is too hot (above -20), the path goes right to a conditional that will check if tempTime has a stored value.

If it does have a stored value, we go left to another conditional that compares the current time and the stored time, and if more than 10 minutes have passed since the temperature was above -20, I will receive a text notification:

If my stored tempTime value is null, the workflow goes right and sets my storage value to the current time:

If it does have a stored value, we go left to another conditional that compares the current time and the stored time:

Then, when 10 minutes have gone by and my temperature is still too high, I receive a text notifying me that I should check it out!

Let me know how else I can help,
Julia

1 Like
#7

Perfect.
Thank you :slight_smile:

1 Like