The simplest of rules won't fire

This rule, which I expect to run all the time, does noting. Why?

rule "Anything changes"
when
  Item gAll changed
then
  logInfo("Status", "Something has CHANGED")
end

Lots of gorup with lots of items are part of gAll… I would expect something would trigger… but I see no blib in the openhab.log.

Try “received update” instead of “changed”

Thomas

1 Like

I tried… nope.
And it would puzzle me, because both are valid trigger conditions for a rule. :frowning:

Added this rule to a clean install of openhab – it works only with ‘received update’.

I can only call this nonsense! :rage:

Had yesterday the same Problem with changed and received update.

Thomas

On which version of openHAB are you seeing this?

OH2B3 one of the latest nightlys

Thomas

1.8.3

this is literally driving me crazy… to fiddle for hours on simple things that should actually work!

Or this one:

rule "ATA is offline"
when
  Item Network_ATA received command or
  Item Network_ATA changed or
  Item Network_ATA received update
then
  logInfo("Network", "ATA received command")
  if (receivedCommand==OFF) {
    logInfo("Network", "ATA is OFF (command)")
  }
end

It is a switch of an item that works:
Switch Network_ATA "Network ATA" <network> (gNetwork) {nh="192.168.1.9"}

I can set this switch to off… and it does not trigger the rule above!

Any ideas what the heck is happening here?

Refusal of Work, Holidays, … :slight_smile:

If it weren’t this frustrating… :slight_smile:

Have carried the ATA rule over to a Windows based OH 1.8.3… it works.

2016-07-30 19:54:54.045 [INFO ] [runtime.busevents ] - Network_ATA received command ON 2016-07-30 19:54:54.054 [INFO ] [g.openhab.model.script.Network] - ATA received command 2016-07-30 19:54:54.054 [INFO ] [g.openhab.model.script.Network] - ATA received command 2016-07-30 19:54:54.054 [INFO ] [g.openhab.model.script.Network] - ATA received command 2016-07-30 19:54:58.062 [INFO ] [runtime.busevents ] - Weather_Temperature state updated to 13 2016-07-30 19:55:19.489 [INFO ] [runtime.busevents ] - Network_ATA state updated to ON 2016-07-30 19:55:19.489 [INFO ] [g.openhab.model.script.Network] - ATA received command

Five things are required to make this work:

  1. the group: gNetwork
  2. the item: Switch Network_ATA "Network ATA" <network> (gNetwork) {nh="192.168.1.9"}
  3. the sitemap: Group item=gNetwork
  4. the rule…
  5. org.openhab.binding.networkhealth-1.8.3.jar

I have copied the .item, .rule and .sitemap entries from OH 1.8.3 on the Raspberry to the Windows machine.

The event log looks different to the Linux one…

Maybe things are happening, and the log does not show it it.
But it shows other INFO entries.

Linux event log: 2016-07-30 20:00:02 - Network_ATA state updated to ON
Windows even log, see above:
2016-07-30 19:55:19.489 [INFO ] [runtime.busevents ] - Network_ATA state updated to ON
But nothing in the Linux openhab.log

What am I missing… seems to be something bigger…

I have a similar setup on a RPi, openHAB 1.8.3:

item:
Switch phone1 "Phone 1" <present> (gMobiles,gRestore) { nh="192.168.2.40" }

event.log:
2016-07-30 21:28:13 - phone1 state updated to ON

And I have (on an INFO level log) also nothing in the openhab.log.
I didn’t try debug logging though, because the network health binding is working fine.

So at least it’s not a general openHAB problem …

Edit: and btw, the trigger is on
Item gMobiles changed

2nd Edit: Did you try
if (Network_ATA.state==OFF)
instead of
if (receivedCommand==OFF)

Of course it is!

If you instruct logInfo, it is supposed to show in the normal log level, without having to change the lockback.xml and restarting the service.

What we are seeing here is behaviour where you cannot test a rule, because the logInfo level does not seem to work.

I have changed the rule on both (Linux|Windows) to:

rule "ATA is offline"
when
  Item Network_ATA received command or
  Item Network_ATA changed or
  Item Network_ATA received update
then
  logInfo("gNetwork", "Rule: ATA is offline triggered")
  if (receivedCommand==OFF) {
    logInfo("gNetwork", "ATA is OFF (command)")
  }
  else if (Network_ATA.state==OFF) {
    logInfo("gNetwork", "ATA is OFF (state)")
  }
  else if (Network_ATA.state == "OFF") {
    logInfo("gNetwork", "ATA is 'OFF' (state)")
  }
end

telling me exactly which action it seem to accept (here on Windows):

2016-07-31 09:26:17.934 [INFO ] [.openhab.model.script.gNetwork] - Rule: ATA is offline triggered
2016-07-31 09:26:17.934 [INFO ] [.openhab.model.script.gNetwork] - Rule: ATA is offline triggered
2016-07-31 09:26:17.934 [INFO ] [runtime.busevents             ] - Network_ATA received command OFF
2016-07-31 09:26:17.939 [INFO ] [.openhab.model.script.gNetwork] - Rule: ATA is offline triggered
2016-07-31 09:26:17.959 [INFO ] [.openhab.model.script.gNetwork] - ATA is OFF (state)
2016-07-31 09:26:17.969 [INFO ] [.openhab.model.script.gNetwork] - ATA is OFF (command)
2016-07-31 09:26:17.984 [INFO ] [.openhab.model.script.gNetwork] - ATA is OFF (state)
2016-07-31 09:26:21.787 [INFO ] [runtime.busevents             ] - Network_ATA state updated to ON
2016-07-31 09:26:21.787 [INFO ] [.openhab.model.script.gNetwork] - Rule: ATA is offline triggered
2016-07-31 09:26:21.787 [INFO ] [.openhab.model.script.gNetwork] - Rule: ATA is offline triggered
2016-07-31 09:27:01.423 [INFO ] [runtime.busevents             ] - Weather_Temperature state updated to 10
2016-07-31 09:27:05.435 [INFO ] [runtime.busevents             ] - Weather_Humidity state updated to 82
2016-07-31 09:27:21.789 [INFO ] [runtime.busevents             ] - Network_ATA state updated to ON
2016-07-31 09:27:21.789 [INFO ] [.openhab.model.script.gNetwork] - Rule: ATA is offline triggered

while on Linux:

rule "ATA is offline"
when
  Item Network_ATA received command or
  Item Network_ATA changed or
  Item Network_ATA received update
then
  logInfo("gNetwork", "Rule: ATA is offline triggered")
  sendMail("blah@gmail.com", "Rule: Item Network_ATA", "Rule: ATA is offline triggered")
  if (receivedCommand==OFF) {
    logInfo("gNetwork", "ATA is OFF (command)")
    sendMail("blah@gmail.com", "Rule: Item Network_ATA", "OFF (command)")
  }
  else if (Network_ATA.state=="OFF") {
    logInfo("gNetwork", "ATA is OFF (state)")
    sendMail("blah@gmail.com", "Rule: Item Network_ATA", "'OFF' (state)")
  }
  else if (Network_ATA.state==OFF) {
    logInfo("gNetwork", "ATA is OFF (state)")
    sendMail("blah@gmail.com", "Rule: Item Network_ATA", "OFF (state)")
  }
end

no entry in log shows other than Refreshing model max01.rules
the mial is also not sent, despite mail working.

Meaning OH does not trigger this rule!

What else could be wrong? Please…

I had another issue I thought it was related – which in fact is.

Removing all rules I could do without fixed the logInfo and email issues…

Solution by Rich:

:ok_hand:

… put your variables first :wink: