Just a question: is there anybody not having problems in OH 2.3.0 with triggers? In my setup (https://github.com/cvdenzen/etc_openhab2, branch develop) only the time (cron) triggers seem to work. And every now and then (after a restart of openhab) the pir_gf_achterdeur17 triggers a rule.
The pir sensor is working very reliably, as I can see in the Openhab GUI and in the karaf logging:
22:42:50.340 [INFO ] [smarthome.event.ItemStateChangedEvent] - LichtIntensiteit_Woonkamer changed from 2.2916665 to 2.5
22:43:00.351 [INFO ] [smarthome.event.ItemStateChangedEvent] - LichtIntensiteit_Woonkamer changed from 2.5 to 2.2916665
22:43:25.257 [INFO ] [smarthome.event.ItemStateChangedEvent] - pir_gf_achterdeur17 changed from OPEN to CLOSED
22:43:33.634 [INFO ] [smarthome.event.ItemStateChangedEvent] - pir_gf_achterdeur17 changed from CLOSED to OPEN
22:43:38.976 [INFO ] [smarthome.event.ItemStateChangedEvent] - pir_gf_achterdeur17 changed from OPEN to CLOSED
22:43:46.478 [INFO ] [smarthome.event.ItemStateChangedEvent] - pir_gf_achterdeur17 changed from CLOSED to OPEN
22:44:00.338 [INFO ] [smarthome.event.ItemStateChangedEvent] - LichtIntensiteit_Woonkamer changed from 2.2916665 to 2.5
22:44:10.346 [INFO ] [smarthome.event.ItemStateChangedEvent] - LichtIntensiteit_Woonkamer changed from 2.5 to 2.2916665
22:44:20.346 [INFO ] [smarthome.event.ItemStateChangedEvent] - LichtIntensiteit_Woonkamer changed from 2.2916665 to 2.5
No that’s working reliably.
Maybe your rule file has a syntax error ? In that case it does not get compiled.
Assume you’ve properly enabled logging, you should see entries like this in openhab.log: 2018-09-20 22:58:18.618 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'Test.rules' has errors, therefore ignoring it: [104,9]: no viable alternative at input 'tem'
Because the items gets updated (as I can be seen in the log and in the GUI) I didn’t think it was important to mention the binding. I use the mqtt binding. The mqtt messages are created by a custom (self-written) osgi bundle. The source can be found at github. The configuration can also be found at github (the link in my original post).
I found (again) some strange things in the Openhab 2.3.0 rules magic. logDebug does not log, even after the command log:set DEBUG. Other log messages on this level are shown with log:display, but the rules logDebug messages are not shown.
Another thing is that the rules engine complains about something not being an Item or being null. I don’t understand and I have come to a point that I don’t want to understand it.
My next step will be to try to write the rules in plain Java (in an osgi bundle). Is there a place where I can find any helpful information?
Did you set the proper log level ? org.eclipse.smarthome.script it would need to be.
Another explanation would be that your rule is broken (you’ve mentioned it has got errors), then OH will stop processing it and eventually never get to that logDebug command.
You’re giving up too soon.
Post your rule(s) here, and the item definition used in the rule(s).
I strongly advise not to. You will be completely on your own.
I don’t use logDebug much so I have no experience to draw upon. As Markus says, perhaps the configuration in the log4j2 config is overriding the setting in karaf.
Without code I can only guess but if venture to guess that you are trying to cast the state of an item whose state is NULL. Or you might be seeing a known timing bug where rules start executing before all your items have been loaded.
I don’t know who is keeping after JS, if anyone. Most of the users who use jsr223 use Jython with a small few using groovy. @illnesse, are you using JS JSR223 rules? Have any advice if so?
I too recommend against this. You will be completely on your own. At least consider using NodeRed for rules. There are many on this forum who do so and there is good integration been the two. Heck, NodeRed is even a choice to install through openHABian.
Please show the rules, please show the errors. Copy and paste them as text here. Don’t forget to mark both rules and logs as “code” (just type ` three times in an extra row ahead and after the code:)
Your Code goes here
The fact, that only the time cron trigger works as expected means, that you have an issue with your triggers. It would be much more easy to find these issues when having a look to the code
My guess is that you are running another version of openhab and that the api has changed.
My simple rule is:
description: "Line: "+__LINE__,
execute: function( module, input)
var triggeringItem = getItem(getTriggeringItemStr(input));
var state = input.state;
if (isUninitialized(state)) state = triggeringItem.state;
var itemSensorTriggeredUI = getItem(triggeringItem.name+"UI");
// postUpdate(itemSensorTriggeredUI,formatUITimeStampfromJodaDate(DateTime.now()) + " " + state)
logInfo("this is script and state changed of " + getItem(triggeringItem.name) + ", state " + state)
In earlier versions of openhab, log:set DEBUG made openhab log my logDebug messages, maybe I have to find out where to set the level for org.eclipse.smarthome.script.
I found the breaking statement in my script, a ReentrantLock that is null (for some unexplained reason). The source can be found at https://github.com/cvdenzen/etc_openhab2.
Am I giving up too soon? I have spent many hours (in the last 3 years or so) trying to understand Xtend. And I have never had the feeling that I understood why it didn’t work and why a change made it work (yes, I have had working rules!).
In Karaf console enter log:set debug org.eclipse.smarthome.script
And as Rich and I replied: you will be completely on your own. With Xtend, while it’s got its strangenesses, there’s still people on the forum to help with.