Hitting the play-button in the WebUI executes the rule though the IF-clause should not be true

  • Platform information:
    • Hardware: Raspberry Pi 4 Model B Rev 1.2
    • OS: Raspbian GNU/Linux 11 (bullseye), Kernel = Linux 5.15.61-v7l+
    • Java Runtime Environment: which java platform is used and what version
    • openHAB version: 3.3.0
  • Issue of the topic: please be detailed explaining your issue

I setup the following rule:

The rule should turn off the mains-power to my TrueNAS server during the night (it pulls 6W for the HP iLO, which I want to save).

However, I only want to execute this, if the server is turned off. For this I use the IF-clause that checks that the value of item server_power_usage has dropped below 10W. This is the value reported by the smart-plug, which is switched by the item server_smartplug. If the server is running (turned on) it pulls >30W and ~6W by the iLO in the “off-state” with mains connected as shown in this screenshot (though here you do not see the iLO state):

(Getting a bit ahead of myself) I tested this rule by hitting the “Play button” at the top right (with server running) and it turned the server off, which should not have happened according to the IF-clause (and hurt me a bit).

So I have two questions:

  1. Does the play-button not consider the IF-clause? (I suspect it does …)
  2. How can I test the this rule without actually switching the server? Can I write to the logs, if the rule was executed instead of switching the server? Related to this: How can I write the value of server_power_usage that was used when executing the rule?

Thank you in advance,

The conditions of the rule are ignored when manually executing it.

You can add another trigger (e.g. a simple switch item) to manually trigger the rule

You can add any other action to the rule, e.g. sending command ON (instead of OFF) to the switch (you will see the command in the log file), turn on a lamp or anything else.
If you want to write a log message, you need to use a script action (I would recommend blockly as there log function predefined working blockly)

1 Like

No it doesn’t - your if-clause compares to “10”. The effect of that depends on the state of the Item you are comparing it to. Maybe it’s just 10, and it would work like you expect. Maybe it is 10W or 0.01kW and you’ll get a surprise.

Check the type and actual state of your conditional Item.
This is related -

1 Like

Makes sense that units matter. Thanks.
I assumed that the value I enter in the condition would be of same unit as that reported by plug (which I assume to be Watts, because that is what is being reported in the items and shown in the graphs):

So what you are saying (if I understand correctly), is that I should replace “10” with an actual unit-type of Number:Power in the argument of the IF-condition here(?):

How do I do this?

This the code of the rule. Do I need to change the type of the condition in there(?):

Just enter 10 W instead of 10 to add the unit

1 Like

I can confirm that the rule now works as expected, after modifying my rule with 10 W (instead of 10).
Thank you! :slight_smile: