[SOLVED] Rule does not fire - desperate

Sorry for no better Subject, i have a rule that simply does ot fire. tried a lot and did check multiple times.
I have a jeelink temperature item that comes from within the fridge - and should fire when temp goes above 15 degree…but never fires. Anyone can see what may be wrong? Temperature is a number/temp item.

Logs do not see anything to complain about.

 // ***************************************************************************************************
rule "FridgeAlert - Notification"
when
    Item NG5_JeelinkFridge_Temperature received update
then
  if (NG5_JeelinkFridge_Temperature.state > 15) {
       sendMail("xxxxxxxxxxxxxxxxxxxxxx", "Fridge TempAlert | " + NG5_JeelinkFridge_Temperature.state + "°C", "---EoM---")
       sendPushoverMessage(pushoverBuilder("Fridge | " + NG5_JeelinkFridge_Temperature.state + "°C").withTitle("TempAlert").withSound("alien"))
  }
end

Did you use VisuslStudioCode to edit the rule file? This editor should highlight syntax problems?
Did you check the logs when saving the file?
Use some logInfo lines in order to see if the rule does trigger but does not run your desired code lines.

Possibly you need the ‘as Number’?

if (NG5_JeelinkFridge_Temperature.state as Number > 15) {

EDIT: although this got marked as the solution, I don’t think it really is the solution. I believe there are 3 choices:

  1. compare with the units, adding the degree C or degree F as appropriate
  2. change the item (if possible) to a Number without the UoM
  3. extract the Number value out of the state and then compare against the value

These are described in other posts and links in this thread.

What makes you think that? Your rule could fire every minute, but unless it gets past the if() you will have no way to tell.

First law of “rule doesn’t fire” - find out.
First line of suspect rule ‘then’ section -
logInfo("test", "my rule has fired")

3 Likes

Add a logInfo just after the then to check is the rule triggers at all:

rule "FridgeAlert - Notification"
when
    Item NG5_JeelinkFridge_Temperature received update
then
    logInfo("TEST",  NG5_JeelinkFridge_Temperature.state.toString)
    if (NG5_JeelinkFridge_Temperature.state > 15) {
        sendMail("xxxxxxxxxxxxxxxxxxxxxx", "Fridge TempAlert | " + NG5_JeelinkFridge_Temperature.state + "°C", "---EoM---")
        sendPushoverMessage(pushoverBuilder("Fridge | " + NG5_JeelinkFridge_Temperature.state + "°C").withTitle("TempAlert").withSound("alien"))
    }
end

Also, can we see a log of the item changing value, please?

@norbert_jordan
I was fighting this just yesterday. As said above, your temperature has UnitofMeasurement. You also need to get the value of the state, not just the state itself, so try this:

if ((NG5_JeelinkFridge_Temperature.state as Number)  > 15 | "°C")  {

In that way you compare apples with apples. That made my rule fire.

Enable debug level logging for org.eclipse.smarthome.model.rules plus watch events.log if the condition is met.

No that didn’t make your rule fire.
What makes the rule fire is the trigger event
That line of code is an if statement inside a rule
And you are correct about apples and oranges

@vzorglub Of course you are correct! Let me rephrase: That made me get the result that I wanted.:smiley:

1 Like

many thanks of course you did make it work!!!
I was not aware that Jeelink (or whoever is in charge within the framework) did create a number:temp item…i simply changed it in PaperUI to number and so the rule finally works…

Thanks a lot!!!

Please tick the solution post, thanks

hm, i did it already this morning. can you please check.