Analog value stays within specified range for a time period

I would like to execute an action after an analog value stays within a range (such as less than 550 and greater than 450) for 5 minutes. The rule is canceled if the analog value goes outside the range during the 5 minutes.

Thanks

I would create a cancelable delay for 5 minutes then cancel it each time an out of range value was received.

1 Like

Would something like this work?

I would modify your trigger events creating two triggers:

PowerLevel > 400
PowerLevel < 600

Reasoning:
Remember these are triggers. You can look at < as operating the same as "becomes less than" So the rule will only run when one of the two thresholds are crossed in the indicated direction.

With your Trigger I would be concerned the rule would be continuously running. If like many analog signals it bounce around a lot, each time it moved (changed) you rule would run.

John

1 Like

Thanks John, I will make this change

So I understand how this waste CPU power. But would it also restart the 5 minute delay every time the analog value changes when between 400 and 600?

No .... but

I may not have a full grasp on your goal.

Lets assume your action is to turn on a process if the inputs are within 400 to 600 but wait 5 minutes to be sure.

I don't see what should happen if the process is running and the inputs leave the 400 to 600 range. Ignoring this for a moment lets look at he first part.

I see your concern, my suggestion did not cover all cases. You would need 4 triggers. Then use the conditions to "stear" what happens.

Trigger = PowerLevel > 400 Condition performs -> reset delay then start process
Trigger = PowerLevel < 600 Condition performs -> reset delay then start process
Trigger = PowerLevel < 400 Condition performs do not initiate process ( or maybe turn it off)
Trigger = PowerLevel > 600 Condition performs do not initiate process ( or maybe turn it off)

At this point I would draw a flow chart I'm not that good enough at this to keep it all in my head at once. A number of times I've made a flow chart only to look back on it and find there was a significant simplification possible. I use LucidChart.com very easy and free if you only do one or two not so big charts at a time.

I did some experimenting and since the ranges >400 and <600 overlap, having two separate triggers did not make a difference. Any time the value changed the rule would get triggered again. So I went back to one "changed" trigger.

My goal, is if the value stays between 400 and 600 for a continuous 5 minutes to turn off the device. The logic is correctly working that way. So even though it keeps getting trigger every time the analog value changes slightly, the timer does not reset. It keeps counting towards five minutes as long as the value stays between 400 and 600. If the value goes outside of 400-600 during the 5 minutes then the delayed action never occurs.

Thanks for the help

2 Likes