Rule to disable rule - or alternative solution


(Christoph) #1

Hello together,

i have been experimenting with OpenHAB for some weeks… And now a rule question occured I found no solution for so far.

The problem: I want to get a message when my laundry is done. Since I do not have a “smart” washing machine I tried to solve it with a smart plug (TP Link HS110) monitoring energy consumption. Besides the rule should turn off the plug when laundry is finished.

I created the rule:

rule “React on Leistung (Waschen_Power) change/update”
when
Item Waschen_Power changed
then
val wpwr = Waschen_Power.state as Number
val pwrthreshold = 4
if (wpwr <= pwrthreshold){
sendTelegram(“cmhomebot”,“OpenHAB Info - Wäsche ist fertig”)
sendCommand(Waschen_Switch, OFF)
}
end

This works as expected.

BUT:

The rule also triggers when I fill in a new laundry - of course no power consumption in that case until I start the machine. The smart plug has a manual switch which I want to use starting the machine again.

The idea was to create something like this:

rule “React on Waschen (Waschen_Switch) change/update”
when
Item Waschen_Switch changed from OFF to ON
then
// something to disable the rule above for 10 minutes
end

Could somebody provide me an idea how to solve this - maybe an alternative approach instead of my idea?

Thanks.


(Vincent Regaud) #2

Please use the code fences when posting code:

Install the expire binding

Set-up at new item:

Switch Washen_Timer { expire="10m, OFF }

Then your rules:

rule “React on Waschen (Waschen_Switch) change/update”
when
Item Waschen_Switch changed from OFF to ON
then
    // something to disable the rule above for 10 minutes
    Washen_Timer.sendCommand(ON)
end

rule “React on Leistung (Waschen_Power) change/update”
when
    Item Waschen_Power changed
then
    if (Washen_Timer.state == OFF) {
        val wpwr = Waschen_Power.state as Number
        val pwrthreshold = 4
        if (wpwr <= pwrthreshold){
            sendTelegram(“cmhomebot”,“OpenHAB Info - Wäsche ist fertig”)
            sendCommand(Waschen_Switch, OFF)
        }
    }
end

The Timer item with get update to OFF 10 minutes after receiving the command ON


(Christoph) #3

Wow.

Didn’t expect that it would be as simple as that.

Thanks.


(Vincent Regaud) #4

Please like and mark as solved. Thanks