[SOLVED] 2 nearly identical rules files, just one work at a time

  • Platform information:
    • Hardware: ARM
    • OS: Linux/Debian/OpenHabianPi
    • Java Runtime Environment: openjdk version “1.8. 0_121”
    • openHAB version: openHAB 2.1.0-1 (Release Build)
    • Issue of the topic:
      I have two Aeotec Multisensor 6 and i use them at the moment like this: 1 sensor is placed in bathroom, 1 is placed in the kitchen. Evertime the temperature changes i would like to send a telegram message. THe rules i created works so far, when there is just one single rules file. For example when i have only kitchen.rules i receive a message every time the temperature changes. But when i create a copy of this file and change it to use the bathroom sensor, i changed all “kitchen” related code, then only one of the rules files seems to work. I can not say which one, because, it seems to be randomly, everytime when i do some changes, another rules file works. I hope i could describe my problem understandable.

Used Items files:
kitchen.items

// Boiler
Number Boiler_1G_Kueche_Verbrauch       "momentaner Verbrauch Boiler [%.2f W]"          <energy>                (1G_Kueche)             { channel="zwave:device:Razberry2:node2:sensor_power" }
Switch Boiler_1G_Kueche_Switch          "Boiler Küche"                                                          <faucet>                (1G_Kueche)             { channel="zwave:device:Razberry2:node2:switch_binary"}
// Sensor
Number Temperatur_1G_Kueche                     "Zimmer Temperatur [%.1f °C]"                           <temperature>   (1G_Kueche)     { channel="zwave:device:Razberry2:node4:sensor_temperature" }
Number Luftfeuchtigkeit_1G_Kueche       "Luftfeuchtigkeit [%.2f %%]"                            <humidity>              (1G_Kueche)             { channel="zwave:device:Razberry2:node4:sensor_relhumidity" }
Number Helligkeit_1G_Kueche                     "Helligkeit     [%.2f Lux]"                                             <colorlight>    (1G_Kueche)             { channel="zwave:device:Razberry2:node4:sensor_luminance" }
Switch Bewegung_1G_Kueche               "Bewegung erkannt"                              (1G_Kueche)     { channel="zwave:device:Razberry2:node4:alarm_motion" }
// Kodi
String Kodi_1G_Kueche_Notification      "Notification"                                                                                  (1G_Kueche)             { channel="kodi:kodi:kitchen:shownotification" }

bad.items

Number Temperatur_1G_Bad                "Zimmer Temperatur [%.1f °C]"   <temperature>   (1G_Bad)        { channel="zwave:device:Razberry2:node11:sensor_temperature" }
Number Luftfeuchtigkeit_1G_Bad          "Luftfeuchtigkeit [%.2f %%]" <humidity> (1G_Bad)                { channel="zwave:device:Razberry2:node11:sensor_relhumidity" }
Number Helligkeit_1G_Bad                        "Helligkeit     [%.2f Lux]" <colorlight> (1G_Bad)               { channel="zwave:device:Razberry2:node11:sensor_luminance" }
Number Boiler_1G_Bad_Verbrauch          "momentaner Verbrauch Boiler [%.2f W]"          <energy>        (1G_Bad)        { channel="zwave:device:Razberry2:node7:sensor_power" }

Used rules files
kitchen.rules

//### Rule warmup
rule "kitchen.rules loaded Event"
when
        System started
then
        logInfo("Warmup","kitchen.rules warmup completed")
end

// Abschalten des Küchen Boilers nach erreichen der Temperatur

rule "Turn Off Boiler After Warmup"
when
    Item Boiler_1G_Kueche_Switch received command ON
then
        Thread::sleep(10000)
    while (Boiler_1G_Kueche_Verbrauch.state > 100.0) {
        logInfo("Boiler Küche: ","Aufheizphase aktiv!")
        Thread::sleep(10000)
    }
        Boiler_1G_Kueche_Switch.send(OFF);
        logInfo("Boiler Küche: ","Automatische Abschaltung bei " + Boiler_1G_Kueche_Verbrauch.state + " W")
end

// Sende Zimmer Temperatur Status per Telegram

rule "Send Temperatur to Telegram"
when
        Item Temperatur_1G_Kueche changed
then
        logInfo("Temperatur Küche: ","Sende Telegram Message")
        if (Temperatur_1G_Kueche.state as Number > 20.0){
                sendTelegram("FlOpenHABot", "\uD83D\uDD25 Die Temperatur in der Küche beträgt jetzt %s Grad Celsius.", Temperatur_1G_Kueche.state.toString)
        }
        else {
                sendTelegram("FlOpenHABot", "\u2744 Die Temperatur in der Küche beträgt jetzt %s Grad Celsius.", Temperatur_1G_Kueche.state.toString)
        }
end

bad.rules

//### Rule warmup
rule "bad.rules loaded Event"
when
        System started
then
        logInfo("Warmup","bad.rules warmup completed")
end

// Abschalten des Bad Boilers nach erreichen der Temperatur

rule "Turn Off Boiler After Warmup"
when
    Item Boiler_1G_Bad_Switch received command ON
then
        Thread::sleep(10000)
    while (Boiler_1G_Bad_Verbrauch.state > 100.0) {
        logInfo("Boiler Bad: ","Aufheizphase aktiv!")
        Thread::sleep(10000)
    }
        Boiler_1G_Bad_Switch.send(OFF);
        logInfo("Boiler Bad: ","Automatische Abschaltung bei " + Boiler_1G_Bad_Verbrauch.state + " W")
        sendTelegram("FlOpenHABot", "Der Boiler im Badezimmer hat seine Zieltemperatur erreicht!")
end

// Sende Zimmer Temperatur Status per Telegram

rule "Send Temperatur to Telegram"
when
        Item Temperatur_1G_Bad changed
then
        logInfo("Temperatur Bad: ","Sende Telegram Message")
        if (Temperatur_1G_Bad.state as Number > 15.0){
                sendTelegram("FlOpenHABot", "\uD83D\uDD25 Die Temperatur im Bad beträgt jetzt %s Grad Celsius. ", Temperatur_1G_Bad.state.toString)
        }
        else {
                sendTelegram("FlOpenHABot", "\u2744 Die Temperatur im Bad beträgt jetzt %s Grad Celsius. ", Temperatur_1G_Bad.state.toString)
        }
end

Both of your rules have the same name. Every rule should have a unique name.

So change this:

rule "Turn Off Boiler After Warmup"

To

rule "Turn Off Boiler After Warmup - Kitchen"

Or something like that.

Other remark (not related to your problem): You use “sleep” to pause the rule for 10 seconds. I think I’ve read somewhere that timers are better for these situations.

1 Like

Thank you for this hint, i think this is a classic: A second pair of eyes needed

I will change this, but so far i have to say that the behavior was the same before i inserted this rule. I did an other try yesterday evening: I only changed something in the message text (added one space) and saved the kitchen.rules. And theres the effect again, now only the kitchen rule works and the bath rule is not executed anymore.

Next point the sleep thing. Yes, i also read about this, but i think the main “problem” with sleep is that it stops all “processes” and in this time nothing else is done. The timer would pause it in the background and release it after the given time. But same as the first point, i will give it a try.

Thank you so far. Any other ideas?

If that doesn’t seem to be the solution: Add some more logInfo statements, to see where the rule gets stuck. Also check openhab.log for anything that could help troubleshoot.

Where would you put logInfo statements to?

In the openhab.log, i watch it through karafshell (log:tail), as far as i’ve seen “live” there is no error. But i will do a grep over the log and filter out all errors. Maybe something i didn’t recognize.

@Dries

Thank you! You solved my problem! It was the thing with the similar names. Changed all rule names so that they are unique and now it works.