Rule Code Syntax

Hi,

I try to get a notification in OH3 bei creating a rule. It works when I use this code(-snippet):

configuration:
  itemName: Waschmaschine_WaschmaschineVerbrauchAktuell
  state: >6

In this case I gat a message when the item power consumption is higher than 6 W. But when I try this:

configuration:
  itemName: Waschmaschine_WaschmaschineVerbrauchAktuell
  state: <6

I get no notification. Why?

Actually, the first example is not working the way you expect either and only appears to be working because of a quirk of yaml formatting.

In a rule trigger condition there is no test for anything but =. This is a fundamental aspect of how OH works. OH rules trigger on events. In this case an event is just the change of an item to another state. The rule can trigger is the item changes to any state or to a specific state, but there’s no numerical or string or otherwise comparison.

To achieve what you want to do, you have to simple have the rule trigger when the item state changes and then run your < or > test elsewhere in the rule. If your rule activates a script, then you can add a line to the script to check for < or > at the top of the script. Otherwise, you can use the UI to add a condition for the rule to run where you can add the comparison you want.