Dishwasher rule

I can’t make this rule work. During the cycle, the dishwasher stops and absorbs 1 watt for a few seconds, then restarts. This tricks the rule and jumps to MODE_FINISHED.
How can I set the rule so that if it remains at 1 watt less than 5 seconds it remains in MODE_ACTIVE and beyond 5 seconds it goes to MODE_FINISHED?

val Number MODE_OFF      = 0
val Number MODE_STANDBY  = 1
val Number MODE_ACTIVE   = 2
val Number MODE_FINISHED = 3

rule "lavastoviglie"


	Item lavastoviglie_Power changed
    if (lavastoviglie_Power.state < 1) lavastoviglie_OpState.postUpdate(MODE_OFF)
    else if (lavastoviglie_Power.state > 3) lavastoviglie_OpState.postUpdate(MODE_ACTIVE)
    else if (lavastoviglie_Power.state <= 1) {	 
        if (lavastoviglie_OpState.state == MODE_OFF) lavastoviglie_OpState.postUpdate(MODE_STANDBY)
        else if (lavastoviglie_OpState.state == MODE_ACTIVE) {

Use a timer or the expire binding to wait 10 seconds and recheck? 10 seconds would work if your estimate is a little low.

Search the forum for “flapping” or “debounce” and you will find lots of examples of what Bruce suggested. One example is in Generic Presence Detection.

1 Like

Or use persistence to verify that the Item has met your condition for longer than 5s. There are lots of examples in the forum for dishwasher rules and for deboucing states. Here is a popular tutorial…

thank you all for your help, I solved it with the persistence method

1 Like