OH3 NGRE rule triggered by measuremt - does it work?

Dear all,

I want to create a rule which notifies me if a certain value drops below a limit value.

To achieve this I created the following:

or textual:

triggers:
  - id: "1"
    configuration:
      itemName: Waschen_Power
      state: <=4
    type: core.ItemStateChangeTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      itemName: VWashTimer
      command: ON
    type: core.ItemCommandAction

But it seems that this does not work. Does the rule trigger support the <= operator?

Alternatively it could look like:

textual:

triggers:
  - id: "1"
    configuration:
      itemName: Waschen_Power
    type: core.ItemStateUpdateTrigger
conditions:
  - id: "3"
    configuration:
      itemName: Waschen_Power
      operator: <=
      state: "4"
    type: core.ItemStateCondition
actions:
  - inputs: {}
    id: "2"
    configuration:
      itemName: VWashTimer
      command: ON
    type: core.ItemCommandAction

But it seems that this also does not work. Any idea?

Thanks
Christoph

It certainly did not in OH2.
Your second rule looks reasonable, though.

Your first attempt will not work. You can’t do math or comparisons in the rule triggers.

Your second attempt is going to be the way to implement this. I’ve not actually tried to do a comparison to a number state but the " " give me pause. Does it work if you remove the quotes around 4?

The second attempt seems to work, even with the "" .
The issue seems to be the trigger. In this case it could happen that the trigger item is not updated for a longer time even if the value is below 4.
Let’s assume the value remains at 3.5 for 1 hour, the rule is not triggered. On the other hand it can happen that it is constantly triggered since the item value is below 4 but varies…

Just to explain what I want to do:
I put a plug with energy measurement at my washing mashine. I want to get notified if the washing program is finished. I figured out that if the energy consumption is 4 Watts or lower it’s finished.

In OH 2 I had a “text based” rule:

rule "React on Leistung (Waschen_Power) change/update"
when
    Item Waschen_Power changed
then
    if (Waschen_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)
            sendTelegram("cmhomebot","OpenHAB Info - Stromzufuhr für Wäsche abgeschaltet ")
        }
    }
end

which worked perfectly. I now try to achieve the same with the UI based config of OH3.

Meanwhile I tried the following:

textual:

triggers:
  - id: "1"
    configuration:
      itemName: Waschen_Power
    type: core.ItemStateUpdateTrigger
conditions:
  - inputs: {}
    id: "4"
    configuration:
      itemName: Waschen_Power
      state: "4"
      operator: <=
    type: core.ItemStateCondition
  - inputs: {}
    id: "5"
    configuration:
      itemName: VWashTimer
      state: OFF
      operator: =
    type: core.ItemStateCondition
  - inputs: {}
    id: "6"
    configuration:
      itemName: WaschenSchalter
      state: ON
      operator: =
    type: core.ItemStateCondition
actions:
  - inputs: {}
    id: "2"
    configuration:
      itemName: WaschenSchalter
      command: OFF
    type: core.ItemCommandAction
  - inputs: {}
    id: "3"
    configuration:
      message: Wäsche ist fertig
      icon: washingmachine
    type: notification.SendExtendedBroadcastNotification

The two additional conditions should achive:

  • the virtual switch with the timer should prevent an immediate power off turning on the machine. I need some time to fill the clothes in…
  • the second condition should prevent further notifications once the machine is poweered off…

Let’s see how it works… Maybe too complicated thoughts at my side… :slight_smile: