OH4 Rule will not exit

After upgrading vom 3.4.4 to OH4.0.1 my Rules which switch off my chargerplugs are all the time running. The will not go anymore in the “idle” mode. In principale they work, but all of them are in “running-mode” and not more in “idle-mode”

The rule itself:

The Blockly under 3.4.4:

The Blockly under 4.0.1

I think wait is a bad idea in this example.

Think about it:

  • When the rule gets triggered, it will wait for 20 seconds before doing anything. The rule is running.
  • After that, when power is low and on, wait for another 5 seconds before switching off.
  • Power will go low when doing that, so the rule is triggered again, with another 20 seconds wait.

So total cycle is 45 seconds running.

You should try do change this to use timers instead.

Apart from that, what is the item type of Jochen_Zimmer_Steckdose_Power? If it is a Number, you should not be comparing to a string value anymore. OH 4.0.1 is more strict in its types. Also, is the item a pure Number, or a Number with a dimension, in which case you should compare against a QuantityType.

THANKS Mherwege for this fast feedback.

I have changed now the String with the Quantity Type:

BUT I’m not a developer and have now idea what you mean with “use timers instead”.
The 20 sec at the begin are need, that “everything comes up and is charging”, without it would switch off directly.

See here: Rules Blockly - Timers & Delays | openHAB

Instead of wait, use the after... block. It will not block the thread, just execute what is inside the block after the delay. wait should only be used for short delays.

Hello Mherwege,

thanks. I have now played a little bit and this is the result.

More or less it works. Can I make something more here?

You do not need to cancel the timer inside the timer block. It will automatically get removed.
If you still want to have the 10 second delay if the condition is met, you can do that with a second nested timer with a different name.

Thanks for the tipp, then I will remove “the cancel of the timer”.
The other wait before switch of the plug is not so important.
So I skipped it.

One problem less after the migration to OH4