Only execute on condition state change - Ignored


#1

1) Give a description of the problem
I have written a piston to compare 2 x humidity sensors. But had problem with with the timeout continually triggering when the temperature changed.
So I have changed the task to “Only execute on condition state change” However even though the condition changes the task never runs.
I’ve tried various conditions and triggers, with the same result of the taks never running.
I’ve also read some similar posts, but noone wems to have solved the issue?

2) What is the expected behaviour?
Fan will run if difference is greater than 15%. If the difference between the 2 x humidity sensors reduces to below a 15% difference a 20 minutes over run on the fan will commence and then turn off.

3) What is happening/not happening?
Expression in While statement ignored as condition state never changes.

4) Post a Green Snapshot of the pistonimage

5) Attach logs after turning logging level to Full
25/08/2019, 11:50:40 +27ms
+1ms ╔Received event [Shower Humidity Sensor].humidity = 95 with a delay of 107ms
+84ms ║RunTime Analysis CS > 21ms > PS > 34ms > PE > 28ms > CE
+86ms ║Runtime (38145 bytes) successfully initialized in 34ms (v0.3.10f.20190822) (84ms)
+87ms ║╔Execution stage started
+90ms ║║Skipping execution for statement #26 because condition state did not change
+91ms ║╚Execution stage complete. (4ms)
+93ms ╚Event processed successfully (92ms)


#3

Place the condition state change requirement in the ‘with’ not the ‘while’… it does nothing at the head of the piston like in your example.


#4

Also, if by using ‘while’ you were hoping to keep the fan on while the humidity is too high, you’ve got things a bit wrong… while is a repetitive loop, and is not compatible with a trigger (rises above), it should instead be used with a condition (is above).

Try:

IF humidity IS greater than X
   THEN
      turn on fan
   ELSE
      turn off fan

No need for a set 20 minute wait, the fan will cut off when humidity drops below the desired threshold.


#5

Thank you, that makes more sense, I was deliberately trying to use triggers, to follow best practice, but can see why they would not work in this case.
Also the 20 min delay, is as I find the humidity increases very quickly when the extractor goes off, so the delay is to force it down and avoid the fan switching on and off about a dozen times
I might experiment with a higher humidity to turn on the fan on and a lower humidity to turn it off.


#6

I think this is the key. I usually leave a “window” that does neither command.

  • Widening the gap effectively extends the “time” before the next toggle.
  • Tightening the gap effectively makes the piston respond “snappier”…

#7

This also works for other types of readings, such as LUX levels. I’ve even extended this method a bit for my “Gloomy Lights” piston. In addition to a Low LUX threshold to turn lights on and a High LUX Threshold to turn lights off (with an appropriate LUX space in between), I’ve also added a timer for each threshold - with more time fo the higher LUX threshold, so that lights aren’t turning off and on immediately as LUX levels fluctuate. I want the lights to stay on until the lux levels rise significantly and stay there.

So for turning on lights due to going below the low LUX threshold, I have:

While turning off lights due to going above the High LUX threshold, I have:

So, I agree that having a gap between low/high settings is a great idea.