Rule not working after update to 2.5.6-2

Tags: #<Tag:0x00007f61734400d0> #<Tag:0x00007f617362ff30> #<Tag:0x00007f617362fda0>

So far as I can see you can work around it with a sertenv

These are clickable links to github issues and patches

I don’t appear to have that line in setenv

I don’t know if it’s related, but in the log, right after the new build boots up, I see this:

2020-06-23 21:34:13.809 [WARN ] [mmon.WrappedScheduledExecutorService] - Scheduled runnable ended with an exception: 
java.lang.NullPointerException: null
	at org.openhab.binding.weatherunderground.internal.handler.WeatherUndergroundBridgeHandler$1.run(WeatherUndergroundBridgeHandler.java:111) ~[?:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_252]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_252]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) ~[?:1.8.0_252]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) ~[?:1.8.0_252]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_252]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_252]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_252]

It seems to refer to WeatherUnderground, which was a failed attempt to connect to that service - but it also mentions scheduling.

HI,

I upgraded to 2.5.6.2, and I had Java exceptions and errors reported of my Python rules upon the first start. I restarted the openhab2 service and all was normal afterward. I don’t know if what I saw is related to your issue, but I thought it worth mentioning.

Regards,
Burzin

Thanks. I restarted several times, so I don’t think that’s it.

Jython does indeed have the most support and the largest collection of users here on this forum compared to JavaScript. But there are some JavaScript users around as well.

In the short run, Jython will be easier. In the long run I suspect both will be well supported with examples, helper libraries and such.

I don’t think it’s related as I believe the bindings interact with the scheduler differently from the Timers and cron triggered rules (there is no intermediary). But anything is possible.

Is the above the only cron triggered rule you have and if not, does that rule work? Do Timers work? If these work, the problem isn’t a generic scheduling problem but something with that specific rule.

1 Like

I only have one rule, yep.

When you say timers, do you mean like cron jobs? I have a backup run via a cron job, and that ran at 3am last night as usual.

If there’s a problem with the rule, wouldn’t there be an error in the log?

I’ve removed all the content from the rule, and it still doesn’t do anything:

load(Java.type("java.lang.System").getenv("OPENHAB_CONF")+'/automation/lib/javascript/core/rules.js');

JSRule
(
	{
	    name: "Open/close ventilation bypass in summer",
	    description: "Opens and closes the ventilation bypass as needed in summer",
	    /*Runs every 2 minutes*/
	    triggers: 
	    [
	        TimerTrigger("0 0/2 * * * ?")
	    ],
	    execute: function( module, input)
	    {
	    	 logInfo('Hello');
	 	}
	}
);

I also tried eliminating the log filter that removes the Modbus connection error, in case it was filtering out something it shouldn’t. Same result. The last thing you see in the log is:

2020-06-24 17:29:17.733 [INFO ] [me.core.service.AbstractWatchService] - Loading script 'OpenOrCloseBypass.js'

After that, nothing, except for those filtered-out Modbus connection errors.

Even when I execute the rule from PaperUI, I see “rule executed”, but no output. So it’s not just a timer thing.

Wait a sec… has the required location for rules changed? What’s the path where they need to be placed?

No, openHAB Timers created using createTimer: https://www.openhab.org/docs/configuration/actions.html#timers, in Jython see https://openhab-scripters.github.io/openhab-helper-libraries/Guides/But%20How%20Do%20I.html#use-a-timer and for JavaScript you should be able to adapt Experimental Next-Gen Rules Engine Documentation 5 of : Actions (NOTE: that thread was written before there were Helper Libraries and written to show how to create Rules through PaperUI so not everything there may still be accurate).

JavaScript is lazily evaluated. Lots and lots of errors will never appear until the rule actually runs. I would expect to see an error if the trigger where incorrect though.

The big problem when executing the rule from PaperUI is it doesn’t appear to get the scope. Consequently it doesn’t necessarily have access to logInfo, for example. Though you should usually see an error in the logs when that happens.

Maybe you need to enable the logs through. See step 3. at https://openhab-scripters.github.io/openhab-helper-libraries/Getting%20Started/Installation.html (you might need to click on the JavaScript tab).

$OH_CONF/automation/jsr223/javascript/personal

It’s in the right spot or else you wouldn’t see the “Loading script” log statement and it wouldn’t appear in your Rules menu in PaperUI.

Actually it isn’t. It’s in automation\jsr223.

I think the subfolders were added with the updated libraries.

You still get the “loading script” statement even if it’s in the parent directory. However, same outcome.

I did see the bit about logging but I assumed that whatever logging was operational by default before would still be. So I take it that’s not the case.

I can’t quite decipher the logging instructions. It talks about the Karaf console, and then about the configuration file, but I can’t see how to translate the Karaf console command into settings in the config file.

Perhaps something like:

log4j2.logger.jsr223.level = DEBUG

?

Yep. Found this post here:

Bingo. I now get the logs and the rule is working. Many thanks.

If you’d put your topic anywhere other than Beginners, I probably would have seen it and could have helped out right away. I only got here after you linked to my post, but I’ve moved it now, as this definitely is not a beginner question!

Many things have been changed and added to the JavaScript helper libraries and I plan to do more to bring the functionality up to the level of the ones for Jython.

Considering just the helper libraries, definitely go with Jython! The JS libraries are better than they were, but are limited by the version of Nashorn supplied in JDK8. Eventually, we will have a newer versioin of JavaScript that is compatible with scripted automation. Considering just the scripting language, definitely go with Jython! JavaScript works well for websites, but it is pretty useless for automation. There is a small number of people who use JavaScript, so I do my best to support it and will continue to build out the JavaScript helper libraries. I am working on an addon for distributing the JavaScript helper libraries, as well as addons for Kotlin, Groovy and jRuby.

1 Like

Yeah, using JS is swimming against the tide, although it would be the easiest for me right now. OK, so I’ll learn Python. I’ve never really used it except once years ago. Something new.

In case you have not seen these…

https://openhab-scripters.github.io/openhab-helper-libraries/index.html

I’m not quite there yet! Maybe in a few weeks from now.