Rules are not always executed

  • Platform information:
    • Hardware: Raspberry Pi 5
    • Java Runtime Environment: 17.0.14 (undefined)
    • openHAB version: 4.3.4

I have 19 rules running in Openhab and at the moment I have the problem that sometimes these rules are not executed… Where can I have a look why the rules are not executed?

For example I have a Aquara button.
The press of the button is recognized all the time: buttonevent triggered 1002
But: my script is sometimes executed… sometimes its not…

The only warnings I get in the logs are:

WARN	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	Binding has not been supplied with a FFmpeg Input URL, so some features will not work.
09:38:41.666	ERROR	com.github.hypfvieh.DbusHelper	Critical error while reading DBUS response (maybe no bluetoothd daemon running?)

Why my IpCamera is not found: its off at the moment… and bluetooth is not used - so I see no problem here.

I have some rules that are goint through loops some hours.
For example:
When the voltage sensor of my wall plug changes and its over a amount of Amps: I go through a cycle of loops in the program and wait till for some time its under a certain amount of power.
So I can say: shut off the power of the wall plug and tell me over instagram that my cloth washing mashine is ready.

Or: when the 3D printer is ready: Wait till the bed is under 40°C and then tell me that the printer is ready.

While this time the rules are in a loop.
Is this a problem?

Here is what I want to execute (only a example):

configuration: {}
triggers:
  - id: "1"
    configuration:
      itemName: Aqara_Taster_1_Schaltflache
    type: core.ItemStateChangeTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      blockSource: <xml
        xmlns="https://developers.google.com/blockly/xml"><variables><variable
        id="n[YIloP6[oCCWH${ebRR">Button</variable></variables><block
        type="variables_set" id="U;2KOux;/m|{TTqX0]/=" x="317" y="240"><field
        name="VAR" id="n[YIloP6[oCCWH${ebRR">Button</field><value
        name="VALUE"><block type="oh_getitem_state"
        id="Z#6,A3r1M;vRn^%v(G4j"><value name="itemName"><shadow type="oh_item"
        id="dMb_C@23y!yjgZ[4nPbl"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow><block type="oh_item"
        id="d7Ns/oR?P/y_8kod[g:h"><mutation
        itemName="Aqara_Taster_1_Schaltflache"
        itemLabel="Schaltfläche"></mutation><field
        name="itemName">Aqara_Taster_1_Schaltflache</field></block></value></block></value><next><block
        type="controls_if" id="#8Q^}hZ5i#!~5qZc$dRg"><value name="IF0"><block
        type="logic_compare" id="ugQJ8V29])0Bhe?icU9t"><field
        name="OP">EQ</field><value name="A"><block type="variables_get"
        id="=?6V@8njIX^v9Sq+:#Vr"><field name="VAR"
        id="n[YIloP6[oCCWH${ebRR">Button</field></block></value><value
        name="B"><block type="text" id="arAD0ly3`:p#i=uW4Wd="><field
        name="TEXT">1002</field></block></value></block></value><statement
        name="DO0"><block type="telegram_message"
        id="lJ}Dxb6a3(co|(Dej$dg"><value name="MESSAGE"><shadow type="text"
        id="admyhcqHmg%S]N;lMpU("><field name="TEXT">What's
        up?</field></shadow><block type="text" id="[,0My_J@AOM({2/{,EWZ"><field
        name="TEXT">Single Click</field></block></value><value
        name="BOT"><shadow type="oh_thing" id="P9F`z[S2QeGnsphA9}-c"><field
        name="thingUid">MyThing</field></shadow><block type="oh_thing"
        id="r)Oe|aY[6TLZvG-QtT#f"><field
        name="thingUid">telegram:telegramBot:e87958c821</field></block></value><next><block
        type="oh_event" id="tO)AC~6(ij;nyCZ`u]Xv"><field
        name="eventType">sendCommand</field><value name="value"><shadow
        type="text" id="eE-p9ad2OlHpNqe|$Ypt"><field
        name="TEXT">value</field></shadow><block type="text"
        id="E~jn_X@*7FEU7TS($51;"><field
        name="TEXT">ON</field></block></value><value name="itemName"><shadow
        type="oh_item" id="qg2/Hlxu`j/Xu/|/8MY^"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow><block type="oh_item"
        id="5If^*rlQC+?:uN`goO25"><mutation
        itemName="Zigbee_Steckdose_7_Betrieb"
        itemLabel="Betrieb"></mutation><field
        name="itemName">Zigbee_Steckdose_7_Betrieb</field></block></value></block></next></block></statement><next><block
        type="controls_if" id="d+pt|EQ3yscFhI?a/Gu."><value name="IF0"><block
        type="logic_compare" id="){gP-*vQXD9wS2^ay:(A"><field
        name="OP">EQ</field><value name="A"><block type="variables_get"
        id="q!b_ZAXy5/}1WYt1kEz_"><field name="VAR"
        id="n[YIloP6[oCCWH${ebRR">Button</field></block></value><value
        name="B"><block type="text" id="Dlh=lnBrBJT=?BnDu$zs"><field
        name="TEXT">1004</field></block></value></block></value><statement
        name="DO0"><block type="telegram_message"
        id="_ssx_t3+k-$nKt#LQbf0"><value name="MESSAGE"><shadow type="text"
        id="admyhcqHmg%S]N;lMpU("><field name="TEXT">What's
        up?</field></shadow><block type="text" id="2)rglFPm]mz(j1$b7;Ee"><field
        name="TEXT">Double Click</field></block></value><value
        name="BOT"><shadow type="oh_thing" id="P9F`z[S2QeGnsphA9}-c"><field
        name="thingUid">MyThing</field></shadow><block type="oh_thing"
        id="Wxr.SrB@8pla*gpSF9?H"><field
        name="thingUid">telegram:telegramBot:e87958c821</field></block></value><next><block
        type="oh_event" id="u%C.ea[VMu^WP5rf5qVM"><field
        name="eventType">sendCommand</field><value name="value"><shadow
        type="text" id="eE-p9ad2OlHpNqe|$Ypt"><field
        name="TEXT">value</field></shadow><block type="text"
        id="qiF3`[Eq;%m0z@@dU%c="><field
        name="TEXT">OFF</field></block></value><value name="itemName"><shadow
        type="oh_item" id="qg2/Hlxu`j/Xu/|/8MY^"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow><block type="oh_item"
        id="9P~v#dn*u21/2sM?ww(8"><mutation
        itemName="Zigbee_Steckdose_7_Betrieb"
        itemLabel="Betrieb"></mutation><field
        name="itemName">Zigbee_Steckdose_7_Betrieb</field></block></value></block></next></block></statement><next><block
        type="controls_if" id="M!*mCf(iGI@Ywv7QzWB#"><value name="IF0"><block
        type="logic_operation" id="}HBg4:tdNd``0BS=b-D)"><field
        name="OP">OR</field><value name="A"><block type="logic_compare"
        id=":rhg*7aI:?eWhULYbC.t"><field name="OP">EQ</field><value
        name="A"><block type="variables_get" id="~9Jv)8u?Y$4t:yGZTL~("><field
        name="VAR"
        id="n[YIloP6[oCCWH${ebRR">Button</field></block></value><value
        name="B"><block type="text" id="mB6Up3Sf,x^,z2Oz6eO!"><field
        name="TEXT">1001</field></block></value></block></value><value
        name="B"><block type="logic_compare" id="4WfW5eND9Ar_EoF4vJMu"><field
        name="OP">EQ</field><value name="A"><block type="variables_get"
        id="^ujCukJU+__9igs~n16d"><field name="VAR"
        id="n[YIloP6[oCCWH${ebRR">Button</field></block></value><value
        name="B"><block type="text" id="dB8wM$fgj2c/V+RF2Ac!"><field
        name="TEXT">1003</field></block></value></block></value></block></value><statement
        name="DO0"><block type="telegram_message"
        id="@TYcE,ee2SWmUTBQSZf4"><value name="MESSAGE"><shadow type="text"
        id="admyhcqHmg%S]N;lMpU("><field name="TEXT">What's
        up?</field></shadow><block type="text" id="_LAO8?;~$n8fJOM)qOjb"><field
        name="TEXT">Long Click</field></block></value><value name="BOT"><shadow
        type="oh_thing" id="P9F`z[S2QeGnsphA9}-c"><field
        name="thingUid">MyThing</field></shadow><block type="oh_thing"
        id="x/c$S6o_f{vqGA/i[3jP"><field
        name="thingUid">telegram:telegramBot:e87958c821</field></block></value><next><block
        type="oh_event" id="Ugs5Ix#H(nVqtwYd`yfS"><field
        name="eventType">sendCommand</field><value name="value"><shadow
        type="text" id="eE-p9ad2OlHpNqe|$Ypt"><field
        name="TEXT">value</field></shadow><block type="text"
        id="R@jN$5Vo8#my[B0rVz-O"><field
        name="TEXT">ON</field></block></value><value name="itemName"><shadow
        type="oh_item" id="qg2/Hlxu`j/Xu/|/8MY^"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow><block type="oh_item"
        id="zOWPEuYB^2%}0]_q]p[T"><mutation
        itemName="Zigbee_Steckdose_7_Betrieb"
        itemLabel="Betrieb"></mutation><field
        name="itemName">Zigbee_Steckdose_7_Betrieb</field></block></value></block></next></block></statement></block></next></block></next></block></next></block></xml>
      type: application/javascript
      script: >
        var Button;


        var things = Java.type('org.openhab.core.model.script.actions.Things');



        Button = items.getItem('Aqara_Taster_1_Schaltflache').state;

        if (Button == '1002') {
          things.getActions('telegram', 'telegram:telegramBot:e87958c821').sendTelegram('Single Click');
          items.getItem('Zigbee_Steckdose_7_Betrieb').sendCommand('ON');
        }

        if (Button == '1004') {
          things.getActions('telegram', 'telegram:telegramBot:e87958c821').sendTelegram('Double Click');
          items.getItem('Zigbee_Steckdose_7_Betrieb').sendCommand('OFF');
        }

        if (Button == '1001' || Button == '1003') {
          things.getActions('telegram', 'telegram:telegramBot:e87958c821').sendTelegram('Long Click');
          items.getItem('Zigbee_Steckdose_7_Betrieb').sendCommand('ON');
        }
    type: script.ScriptAction

Dependng on how you implement this, if you are using a busy wait loop instead of a timer you could be starving out this rule. As long as the rule is sitting there looping in a while loop, that rule cannot be triggered again until the loop exits and the rule completes.

But any triggers that occured while the rule was furiously looping and doing nothing get queued up and run in sequence. You could render a rule unusable for quite some time or even indefinitely.

Busy waits are generally a really bad idea.

Your rule is triggered on changes to the state of Aqara_Tester_1_Schaltflache. If you push the button but the Item doesn’t change state, the rule isn’t going to trigger. You either need to use a received command trigger or an updated trigger, depending on what the event is that happens when you press the button.

But other rules should be started then?

I know - thats okay…
But sometimes it happens that nothing happens - even when I do change state by pressing something else…
So I press one time, two times - nothing happens…
No message via Telegram, no “ON” or OFF at the power button… nothing…
Some times later I do the same and it works…

So the question is: why does that happen? What hangs here at Openhab and how can I find out?

Hi,
Use the triggered value (in the protocol) with the block contextual_info_triggered_event

Button = event.event;
//siehe ZigBee-Modell-Seite, wenn Doppelschalter : single_left, single_right, single_both, double_left, double_right, double_both, triple_left, triple_right, triple_both, hold_left, hold_right, hold_both
if (Button == 'single_left') {
....
}

Yes, assuming OH 3.0 or later.

For this specific rule are you certain it’s not running? If the “Button” isn’t 1001, 1002, 1003, 1004 the rule does nothing at all. We really don’t know if this rule isn’t doing anything because none of the if statements match or if it’s not triggering at all.

Maybe it’s telegram that’s stalling or not responding.

You can change the logging level of openhab.event.RuleStatusInfoEvent to INFO and when your rule starts running and returns to IDLE will be added to events.log. That will definitively show you that the rule is being triggered or not.

For the rest of the rules, :person_shrugging: We know nothing about them.

In general though, rules do not just stop working for no reason. This specific rule has a lot about it which could make it appear to not be working:

  • only triggers on changes
  • uses the state of the triggering Item instead of the event (as @Tschetan points out) meaning the Item may have returned to NULL by the time the rule runs
  • the state of the Item is not one of the four tested for values
  • telegram may be blocking keeping the rule from exiting