I’m running openHAB 4.0.0.M1 with the ‘JavaScript Scripting (Nashorn)’ installed.
But getting the error, not sure if I need something else?
Just had a quick look, and I can’t find graalVM.
I’m running openHAB 4.0.0.M1 with the ‘JavaScript Scripting (Nashorn)’ installed.
But getting the error, not sure if I need something else?
Just had a quick look, and I can’t find graalVM.
You shouldn’t need anything else. Did you try with the adjusted version I loaded 1h ago? I made a slight change that could have an impact.
I need to copy/paste from 2 installation since I can’t find the rule template in OH4. But if I did it correct, I’m getting now following error:
Script execution of rule with UID '07f5211181' failed: java.lang.NullPointerException: Cannot invoke "java.time.temporal.TemporalUnit.addTo(java.time.temporal.Temporal, long)" because "unit" is null
I just tried with an OH4 snapshot and Nashorn js installed. It runs fine.
Check out line 66 in the script. That’s where I have made the change. It should be:
timer = ScriptExecution.createTimerWithArgument(now.plus(delayInSeconds, ChronoUnit.SECONDS), func, function() {
That’s correct, I’ve got the latest version. But still having:
2023-04-26 19:38:46.775 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID '07f5211181' failed: java.lang.NullPointerException: Cannot invoke "java.time.temporal.TemporalUnit.addTo(java.time.temporal.Temporal, long)" because "unit" is null
Will have some other tests tomorrow.
Guess something is wrong in my system, but not sure where. Everything else seems to be working fine. Can I add extra debugs to the logs?
Just did an upgrade towards 4.0.0.M2, but no luck
When I check the installed bundles, I see I have 2 JavaScript Scripting? Not sure why. But no difference with 1 installed, the other or both. Always the same error.
openhab> bundle:list | grep ava
37 │ Active │ 80 │ 30.1.0.jre │ Guava: Google Core Libraries for Java
38 │ Active │ 80 │ 1.0.1 │ Guava InternalFutureFailureAccess and InternalFutures
54 │ Active │ 80 │ 1.2 │ javax.annotation API
88 │ Active │ 80 │ 1.0.0.2 │ Apache ServiceMix :: Bundles :: javax.inject
234 │ Active │ 80 │ 2.1.0 │ Units of Measurement Common Library for Java
240 │ Active │ 80 │ 1.6.2 │ JavaMail API
253 │ Active │ 80 │ 2.2.19 │ rxjava
256 │ Active │ 80 │ 20180813.0.0 │ JSON in Java
257 │ Active │ 80 │ 0.3.0.v20220506-1020 │ EdDSA-Java
258 │ Active │ 80 │ 5.2.1.OH1 │ nrjavaserial
266 │ Active │ 80 │ 2.1.2 │ Java Concurrency Tools Core Library
268 │ Active │ 80 │ 4.0.0.M2 │ openHAB Add-ons :: Bundles :: Automation :: JavaScript Scripting (Nashorn)
323 │ Active │ 80 │ 4.0.0.M2 │ openHAB Add-ons :: Bundles :: Automation :: JavaScript Scripting
You installes both the old javascript addon (nashorn) and the new one (using graalvm). It is likely the code is run using the newer one. I did not test that, so that’s likely the problem. I will look into it when I move to OH4.
@brononius A version for OH 4.0 for the JavaScript Scripting Add-on (ECMAScript 2022+ ES6) is now available here.
Ahhh, nice !!!
Works perfectly.
2023-06-02 18:17:14.224 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'garbage_collection_waste' updated to 2023-06-02T00:00:00.000+0200
2023-06-02 18:17:14.224 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'garbage_collection_waste' changed from NULL to 2023-06-02T00:00:00.000+0200
2023-06-02 18:17:14.224 [INFO ] [openhab.event.GroupStateUpdatedEvent] - Group 'garbage_collection' updated to 2023-06-02T00:00:00.000+0200 through garbage_collection_waste
2023-06-02 18:17:14.224 [INFO ] [hab.event.GroupItemStateChangedEvent] - Item 'garbage_collection' changed from NULL to 2023-06-02T00:00:00.000+0200 through garbage_collection_waste
2023-06-02 18:17:14.228 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'garbage_collection_pmd' updated to 2023-06-02T00:00:00.000+0200
2023-06-02 18:17:14.228 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'garbage_collection_pmd' changed from NULL to 2023-06-02T00:00:00.000+0200
2023-06-02 18:17:14.228 [INFO ] [openhab.event.GroupStateUpdatedEvent] - Group 'garbage_collection' updated to 2023-06-02T00:00:00.000+0200 through garbage_collection_pmd
2023-06-02 18:17:14.233 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'garbage_collection_paper' updated to 2023-06-02T00:00:00.000+0200
2023-06-02 18:17:14.234 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'garbage_collection_paper' changed from NULL to 2023-06-02T00:00:00.000+0200
2023-06-02 18:17:14.234 [INFO ] [openhab.event.GroupStateUpdatedEvent] - Group 'garbage_collection' updated to 2023-06-02T00:00:00.000+0200 through garbage_collection_paper
Thanks!
Please find some updates for the Flemish region in Belgium:
var WASTE_ITEMS = {
RESIDUAL_WASTE: { “item”: “Waste_residual”, “fraction”: [“residu”, “huisvuil”, “omb”, “restafval”, “huisvuil diftar”] },
PMD: { “item”: “Waste_pmd”, “fraction”: [“pmd”] },
GFT: { “item”: “Waste_gft”, “fraction”: [“gft”, “vegetable”, “kitchen”, “organiques”, “gft-diftar”] },
PAPER_CARDBOARD: { “item”: “Waste_paper”, “fraction”: [“paper”, “paper-cardboard”] },
TEXTILE: { “item”: “”, “fraction”: [“textile”] },
PRUNING_WOOD: { “item”: “Waste_wood”, “fraction”: [“pruning”, “verhakselen”, “snoeihout”] },
GLASS: { “item”: “”, “fraction”: [“glass”] },
BULKY_WASTE: { “item”: “Waste_bulk”, “fraction”: [“bulky”, “grofvuil”] }
};
@lvdh
“huisvuil diftar” and “gft-diftar” should already work (“huisvuil” and “gft” are in the search strings and it looks for substrings.
Do you have an example output where “snoeihout” and/or “grofvuil” are used? I can then add them.