Problem with rule under OH3

Hi =), I try to define a simple rule under OH3 with the main UI…The syntax is the following:
When I turn on the “Küchendimmer” above a value of 80, it should turn on my “Arbeitsplattenlicht” and “Dunstabzugshaube” Items…The rule reacts, but as soon as I define the “only if item state > 80” the rule never runs…Here is the code of main-ui:

triggers:
  - id: "1"
    configuration:
      itemName: DimmerKuechenlicht
    type: core.ItemStateUpdateTrigger
conditions:
  - inputs: {}
    id: "4"
    configuration:
      itemName: DimmerKuechenlicht
      state: "80"
      operator: ">"
    type: core.ItemStateCondition
actions:
  - inputs: {}
    id: "2"
    configuration:
      itemName: Arbeitsplattenlicht_Switch
      command: ON
    type: core.ItemCommandAction
  - inputs: {}
    id: "3"
    configuration:
      itemName: Dunstabzugshaube
      command: ON
    type: core.ItemCommandAction

That is the Rule known working under “old” syntax:

rule "Kuechenbeleuchtung Regel"
when
    Item Dimmer_Kuechenlicht_Esstischlicht received update
then
    if (Dimmer_Kuechenlicht_Esstischlicht.state > 80) {
    Dunstabzugshaube.sendCommand(ON)
    Schalter_Arbeitsplattenlicht_Kueche.sendCommand(ON)
    }
    else {
    Dunstabzugshaube.sendCommand(OFF) 
    Schalter_Arbeitsplattenlicht_Kueche.sendCommand(OFF)
    }
end

I know the new rule will turn on AND off, but such a syntax is not possible under main-ui…
I just want to understand, why the rule is not working on the “new” main-ui syntax, or what I’m doing wrong here…

Platform Info: OpenHab Docker 3.0, hypriot OS latest, Rpi 4

runtimeInfo:
  version: 3.0.0
  buildString: Release Build
locale: de_AT
systemInfo:
  configFolder: /openhab/conf
  userdataFolder: /openhab/userdata
  logFolder: /openhab/userdata/logs
  javaVersion: 11.0.9
  javaVendor: Azul Systems, Inc.
  javaVendorVersion: Zulu11.43+88-CA
  osName: Linux
  osVersion: 5.4.79-v7l+
  osArchitecture: arm
  availableProcessors: 4
  freeMemory: 39943952
  totalMemory: 304283648
bindings:
  - amazonechocontrol
  - astro
  - bluetooth
  - chromecast
  - gardena
  - harmonyhub
  - ipcamera
  - jablotron
  - kodi
  - mail
  - ntp
  - openweathermap
  - orvibo
  - samsungtv
  - smartthings
  - telegram
  - unifi
  - unifiedremote
  - upnpcontrol
  - zwave
clientInfo:
  device:
    ios: false
    android: false
    androidChrome: false
    desktop: true
    iphone: false
    ipod: false
    ipad: false
    edge: false
    ie: false
    firefox: false
    macos: false
    windows: true
    cordova: false
    phonegap: false
    electron: false
    nwjs: false
    webView: false
    webview: false
    standalone: false
    os: windows
    pixelRatio: 1.25
    prefersColorScheme: dark
  isSecureContext: true
  locationbarVisible: true
  menubarVisible: true
  navigator:
    cookieEnabled: true
    deviceMemory: 8
    hardwareConcurrency: 8
    language: de-DE
    languages:
      - de-DE
      - de
      - en-US
      - en
    onLine: true
    platform: Win32
  screen:
    width: 1536
    height: 864
    colorDepth: 24
  support:
    touch: false
    pointerEvents: true
    observer: true
    passiveListener: true
    gestures: false
    intersectionObserver: true
  themeOptions:
    dark: dark
    filled: true
    pageTransitionAnimation: default
    bars: light
    homeNavbar: default
    homeBackground: default
    expandableCardAnimation: default
  userAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,
    like Gecko) Chrome/87.0.4280.141 Safari/537.36
timestamp: 2021-01-16T18:45:13.317Z

Try this instead:

val dimmerValue = Dimmer_Kuechenlicht_Esstischlicht.state as Number
if (dimmerValue > 80)

The old rule works…the new one doesn’t…

Sorry, that was not clear to me. Then try this:

operator: >

So without the quotes.

When I delete the quotes and save, the operator disappeares after reload in the main UI design…and it’s not working…

Strange. What happens if you enter the operator via the design tab?

I build the rule in whole with the design-tab…it automatically adds the quotes

Even more strange. Is there anything in the logs? Does the value of “DimmerKuechenlicht” really change to a value above 80? Perhaps try it with “core.ItemStateChangeTrigger” instead (just in case).

No warn or error…I tested the rule Trigger by deleting the “only if” condition…the rule turns on then…so the rule-trigger should work…I also tested with stateChange… nothing happened…

Do you have a dimmer and can reproduce? Maybe it is an issue…

Just for testing I created a similar rule with Main UI
I can confirm that it does not work.

The rule works if it looks like:

and it stops working if I add a condition

textual:

triggers:
  - id: "1"
    configuration:
      itemName: DeckenleuchteTisch_Helligkeit
    type: core.ItemStateChangeTrigger
conditions:
  - id: "3"
    configuration:
      itemName: DeckenleuchteTisch_Helligkeit
      operator: ">"
      state: "80"
    type: core.ItemStateCondition
actions:
  - inputs: {}
    id: "2"
    configuration:
      itemName: FlurDeckenleuchte_Helligkeit
      command: ON
    type: core.ItemCommandAction

I would call it a bug since there is no obvious reason why this should not work…

1 Like

Great thanks for testing! Maybe we should open an issue?

My personal workaround would be:

Created a rule with Blockly:

textual:

var dimmerValue;


dimmerValue = itemRegistry.getItem('DeckenleuchteTisch_Helligkeit').getState();
if (dimmerValue > 80) {
  events.sendCommand('FlurDeckenleuchte_Helligkeit', 'ON');
}

This works perfectly.

In regards of opening an bug: maybe, especially issues with an operator will probably occur as well in other cases and the Main UI offer those operators.

But I don’t have a Github account yet…

Thanks :slight_smile: also the “old” Syntax works for me… @rlkoshak can you assign someone who can help with rules and this probable bug? Issues with the OpenHab 3 Rule-engine · Issue #2124 · openhab/openhab-core · GitHub

I don’t assign anyone to do anything. This is an open source project. Literally everything that gets coded, documented, or fixed is done because someone volunteers to do it. Every question that is answered in the forum is answered because someone volunteers to answer it.

No one assigns anyone anything to do.

The issue is filed and it will be fixed when and if someone with the skill, time, and willingness volunteer to do the work and submits a PR.

Sorry I didn’t mean it that way…just wanted to help solve it…I know that @rlkoshak have an extremely good thread about rules in 2.5 OpenHab where you explained everything extremely good…that’s why I marked you… sorry…I know that this is an opensource project and I really appreciate the work all of you have done to make such a cool software! So I’m really sorry if I offended you or someone else somehow…

1 Like

There was no offense taken. I just don’t want people to have the wrong impression about how this get done around here.

1 Like

@Gufti I have another workaround…you can choose “execute a given script” as a then action, and insert your old dsl-rule…is confirmed working.

Meanwhile I built some scripts with blockly and execute them via “given script”. Works as well.

1 Like