openHAB 4.0 SNAPSHOT discussion

And my question was

How is the Thing defined?

and your answer is

with the JS Scripting command:

which very clearly does not create/define a Thing.

Is this thing defined in a .things file? Manually through the UI? Automatically discovered and accepted from the Inbox?

I’m not sure that’s fully supported. It’s worth filing an issue on that one, but I’ve not seen anything posted to indicate that that should work. But the fact that it let you do it at all shows that maybe it could be made to work.

Sorry crossed wires. The Thing was added from the inbox in the UI.

Hi all, any quick solution to get my PH calculation back to work ? Nashorn is installed, but didn’t help.

PH.rules

rule "PHSensor1"
when
    Item ads1115_voltage0 changed
then
	val ads_ph_1 = ads1115_voltage0.state.toString
	val ads_ph_result1 = transform("JS", "PH1.js", ads_ph_1)
	PHSensor1.postUpdate(ads_ph_result1)
end

PH1.js

(function(value) {
    var PH_1= parseInt(value);
	var voltagePH7_1 = 15372
	var voltagePH4_1 = 4845
	var PH7_1 = 7
	var PH4_1 = 4
	PH_step_1 = ((voltagePH7_1) - (voltagePH4_1)) / (PH7_1 - PH4_1)
    var result_1 =  PH7_1 - ((voltagePH7_1 - PH_1) / PH_step_1)
	var result1_1 = parseFloat(result_1).toFixed(2);
    return result1_1;
})(input)

See above, there is no more JS transform. You must use the SCRIPT transform.

1 Like

I just upgraded to the latest snapshot (it’s reporting #3304).

No logs! :scream:

After some investigation I discovered that org.ops4j.pax.logging.cfg was empty. I can’t imagine what could have caused that to occur. Nothing appears to have changed on these files and related files for quite some time. I’m reporting here in case it was not a gremlin in my machine and something that is happening to more people.

Note, the contents of that file should be

org.ops4j.pax.logging.log4j2.config.file=${karaf.etc}/log4j2.xml

Also, as an update, the Zigbee problem should be fixed in the next SNAPSHOT. The fix was merged 15 hours ago but is not a part of snapshot #3304 yet.

Seems to be a problem that occurs from time to time, reason unknown: [SOLVED] OH3 logging not possible, openhab.log last entries some days ago

1 Like

If it’s from a .things file, it is not expected to be persisted at all. If it’s a managed thing (UI/API/JSON), it will be persisted but only if you call update with the thing on the ManagedThingProvider, which I’m guessing is not being done for you (for now?) by the JS Scripting helper library. The upcoming major release of the Ruby scripting helper library has some support for ensuring changes (like to labels) to managed items are persisted, but not yet for things (document GenericItem#label= and GenericItem#category= by ccutrer · Pull Request #174 · ccutrer/openhab-jrubyscripting · GitHub for the relevant PR if anyone is interested).

1 Like

Rich, zigbee bundle build died in Jenkins, kinda weird, it failed with no failures.

Upgraded to #3313 and all rules are broken. There appears to be up to three separate problems.

Problem 1

The first seems to be a problem with the addon.xml file for the Zigbee binding.

20│--------------------------------------------- file got truncated /srv/openhab/userdata/logs/openhab.log 2023/02/14 07:56:04---------------------------------------------│
20│2023-02-14 07:56:11.707 [INFO ] [org.openhab.core.Activator          ] - Starting openHAB 4.0.0 (build Build #3313)                                                     │
20│2023-02-14 07:56:12.501 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Time zone set to 'America/Denver'.                                                             │
20│2023-02-14 07:56:12.516 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Location set to 'X,Y'.                                      │
20│2023-02-14 07:56:12.517 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Locale set to 'en_US'.                                                                         │
20│2023-02-14 07:56:12.518 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Measurement system set to 'US'.                                                                │
20│2023-02-14 07:56:19.406 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'test.items'                                                                     │
20│2023-02-14 07:56:20.031 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'rrd4j.persist'                                                                  │
20│2023-02-14 07:56:20.098 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'mapdb.persist'                                                                  │
20│2023-02-14 07:56:28.775 [INFO ] [.core.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007                                    │
20│2023-02-14 07:56:34.019 [WARN ] [ty.util.ssl.SslContextFactory.config] - Trusting all certificates configured for Client@581281f4[provider=null,keyStore=null,trustStore│
20│=null]                                                                                                                                                                  │
20│2023-02-14 07:56:34.020 [WARN ] [ty.util.ssl.SslContextFactory.config] - No Client EndPointIdentificationAlgorithm configured for Client@581281f4[provider=null,keyStore│is.g│=null,trustStore=null]                                                                                                                                                  │
00│2023-02-14 07:56:34.036 [WARN ] [core.thing.internal.ThingManagerImpl] - No config description for 'channel-type:http:channel-config-switch' found when normalizing conf│5920│iguration for 'http:url:adguard:protection_status'. This is probably a bug.                                                                                             │
20│2023-02-14 07:56:34.100 [INFO ] [nding.http.internal.HttpThingHandler] - Using the insecure client for thing 'http:url:adguard'.                                        │
20│2023-02-14 07:56:34.456 [INFO ] [.network.internal.utils.NetworkUtils] - CIDR prefix is smaller than /24 on interface with address 172.17.0.1/16, truncating to /24, som│
20│e addresses might be lost                                                                                                                                               │
20│2023-02-14 07:56:36.764 [INFO ] [nternal.manager.ShellyManagerServlet] - Shelly Manager started at http(s)://10.10.1.112:8080/shelly/manager                            │
20│2023-02-14 07:56:37.017 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to 'argus.koshak.lan' with clientid openhab                    │
20│2023-02-14 07:56:37.240 [WARN ] [ig.xml.osgi.XmlDocumentBundleTracker] - The XML document '/OH-INF/addon/addon.xml' in module 'org.openhab.binding.zigbee' could not be │
20│parsed:                                                                                                                                                                 │
20│---- Debugging information ----                                                                                                                                         │
20│cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException                                                                                       │
20│cause-message       : author                                                                                                                                            │
20│class               : java.util.ArrayList                                                                                                                               │
20│required-type       : java.util.ArrayList                                                                                                                               │
20│converter-type      : com.thoughtworks.xstream.converters.collections.CollectionConverter                                                                               │
20│path                : /addon/author                                                                                                                                     │
20│line number         : 10                                                                                                                                                │
20│class[1]            : org.openhab.core.addon.xml.internal.AddonInfoXmlResult                                                                                            │
20│required-type[1]    : org.openhab.core.addon.xml.internal.AddonInfoXmlResult                                                                                            │
20│converter-type[1]   : org.openhab.core.addon.xml.internal.AddonInfoConverter                                                                                            │
20│version             : 1.4.19                                                                                                                                            │
20│-------------------------------                                                                                                                                         │
20│com.thoughtworks.xstream.converters.ConversionException:                                                                                                                │
20│---- Debugging information ----                                                                                                                                         │is.g│cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException                                                                                       │
20│cause-message       : author                                                                                                                                            │
20│class               : java.util.ArrayList                                                                                                                               │
20│required-type       : java.util.ArrayList                                                                                                                               │
20│converter-type      : com.thoughtworks.xstream.converters.collections.CollectionConverter                                                                               │is.g│path                : /addon/author                                                                                                                                     │
20│line number         : 10                                                                                                                                                │
20│class[1]            : org.openhab.core.addon.xml.internal.AddonInfoXmlResult                                                                                            │
20│required-type[1]    : org.openhab.core.addon.xml.internal.AddonInfoXmlResult                                                                                            │
20│converter-type[1]   : org.openhab.core.addon.xml.internal.AddonInfoConverter                                                                                            │
20│version             : 1.4.19                                                                                                                                            │
20│-------------------------------                                                                                                                                         │
00│        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:81) ~[bundleFile:1.4.19]                                                        │1020│        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72) ~[bundleFile:1.4.19]                              │
20│        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:68) ~[bundleFile:1.4.19]                                                 │
20│        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:52) ~[bundleFile:1.4.19]                                                 │
20│        at org.openhab.core.addon.xml.internal.AddonInfoConverter.unmarshal(AddonInfoConverter.java:77) ~[?:?]                                                          │
20│        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:74) ~[bundleFile:1.4.19]                                                        │
20│        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72) ~[bundleFile:1.4.19]                              │
20│        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:68) ~[bundleFile:1.4.19]                                                 │
20│        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:52) ~[bundleFile:1.4.19]                                                 │
20│        at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:136) ~[bundleFile:1.4.19]                                                         │
20│        at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32) ~[bundleFile:1.4.19]                        │
20│        at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1421) ~[bundleFile:1.4.19]                                                                           │
20│        at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1399) ~[bundleFile:1.4.19]                                                                           │
20│        at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1350) ~[bundleFile:1.4.19]                                                                             │
20│        at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1304) ~[bundleFile:1.4.19]                                                                             │
20│        at org.openhab.core.config.xml.util.XmlDocumentReader.readFromXML(XmlDocumentReader.java:105) ~[bundleFile:?]                                                   │
20│        at org.openhab.core.config.xml.osgi.XmlDocumentBundleTracker.parseDocuments(XmlDocumentBundleTracker.java:396) [bundleFile:?]                                   │
20│        at org.openhab.core.config.xml.osgi.XmlDocumentBundleTracker.processBundle(XmlDocumentBundleTracker.java:382) [bundleFile:?]                                    │
20│        at org.openhab.core.config.xml.osgi.XmlDocumentBundleTracker$2.run(XmlDocumentBundleTracker.java:347) [bundleFile:?]                                            │  
.g│        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) [?:?]                                                                                │
20│        at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]                                                                                               │
20│        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]                                         │
20│        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]                                                                        │
20│        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]                                                                        │is.g│        at java.lang.Thread.run(Thread.java:833) [?:?]                                                                                                                  │
20│Caused by: com.thoughtworks.xstream.mapper.CannotResolveClassException: author                                                                                          │
20│        at com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:81) ~[bundleFile:1.4.19]                                                          │
20│        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125) ~[bundleFile:1.4.19]                                                         │
20│        at com.thoughtworks.xstream.mapper.DynamicProxyMapper.realClass(DynamicProxyMapper.java:55) ~[bundleFile:1.4.19]                                                │
20│        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125) ~[bundleFile:1.4.19]                                                         │
20│        at com.thoughtworks.xstream.mapper.PackageAliasingMapper.realClass(PackageAliasingMapper.java:88) ~[bundleFile:1.4.19]                                          │
20│        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125) ~[bundleFile:1.4.19]                                                         │
20│        at com.thoughtworks.xstream.mapper.ClassAliasingMapper.realClass(ClassAliasingMapper.java:79) ~[bundleFile:1.4.19]                                              │
20│        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125) ~[bundleFile:1.4.19]                                                         │is.g│        at com.thoughtworks.xstream.mapper.ArrayMapper.realClass(ArrayMapper.java:74) ~[bundleFile:1.4.19]                                                              │
20│        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125) ~[bundleFile:1.4.19]                                                         │
00│        at com.thoughtworks.xstream.mapper.SecurityMapper.realClass(SecurityMapper.java:71) ~[bundleFile:1.4.19]                                                        │3320│        at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125) ~[bundleFile:1.4.19]                                                         │
20│        at com.thoughtworks.xstream.mapper.CachingMapper.realClass(CachingMapper.java:47) ~[bundleFile:1.4.19]                                                          │
20│        at com.thoughtworks.xstream.core.util.HierarchicalStreams.readClassType(HierarchicalStreams.java:29) ~[bundleFile:1.4.19]                                       │
20│        at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readBareItem(AbstractCollectionConverter.java:131) ~[bundleFile:1.4.19]          │
20│        at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:117) ~[bundleFile:1.4.19]              │
20│        at com.thoughtworks.xstream.converters.collections.CollectionConverter.addCurrentElementToCollection(CollectionConverter.java:99) ~[bundleFile:1.4.19]          │
20│        at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:92) ~[bundleFile:1.4.19]                     │
20│        at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:86) ~[bundleFile:1.4.19]                     │
20│        at com.thoughtworks.xstream.converters.collections.CollectionConverter.unmarshal(CollectionConverter.java:81) ~[bundleFile:1.4.19]                              │
20│        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:74) ~[bundleFile:1.4.19]                                                        │
20│        ... 24 more                                                                                                                                                     │

The Zwave binding has a similar error.

Problem 2

The second problem is related to creating the script engine.

20│2023-02-14 07:56:38.495 [INFO ] [ort.loader.AbstractScriptFileWatcher] - (Re-)Loading script '/openhab/conf/automation/js/node_modules/openhab/@globals-webpack.config.j│
20│s'                                                                                                                                                                      │
20│2023-02-14 07:56:39.006 [INFO ] [io.openhabcloud.internal.CloudClient] - Connected to the openHAB Cloud service (UUID = d0...e1, base URL = http://localhost:8080)      │is.g│2023-02-14 07:56:43.934 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error while creating ScriptEngine                                                              │
20│org.graalvm.polyglot.PolyglotException: Cannot invoke "java.nio.file.Path.resolve(java.nio.file.Path)" because the return value of "java.nio.file.Path.getRoot()" is nul│
20│l                                                                                                                                                                       │
20│        at org.openhab.automation.jsscripting.internal.OpenhabGraalJSScriptEngine.isRootNodePath(OpenhabGraalJSScriptEngine.java:312) ~[?:?]                            │
20│        at org.openhab.automation.jsscripting.internal.OpenhabGraalJSScriptEngine$1.checkAccess(OpenhabGraalJSScriptEngine.java:190) ~[?:?]                             │is.g│        at com.oracle.truffle.api.TruffleFile.checkAccess(TruffleFile.java:2125) ~[?:?]                                                                                 │
20│        at com.oracle.truffle.api.TruffleFile.exists(TruffleFile.java:288) ~[?:?]                                                                                       │
20│        at com.oracle.truffle.js.runtime.JSRealm.addCommonJSGlobals(JSRealm.java:1617) ~[?:?]                                                                           │
20│        at com.oracle.truffle.js.runtime.JSRealm.addOptionalGlobals(JSRealm.java:1692) ~[?:?]                                                                           │
20│        at com.oracle.truffle.js.runtime.JSRealm.initialize(JSRealm.java:2193) ~[?:?]                                                                                   │
20│        at com.oracle.truffle.js.lang.JavaScriptLanguage.initializeContext(JavaScriptLanguage.java:362) ~[?:?]                                                          │is.g│        at com.oracle.truffle.js.lang.JavaScriptLanguage.initializeContext(JavaScriptLanguage.java:114) ~[?:?]                                                          │
20│        at com.oracle.truffle.api.TruffleLanguage$Env.postInit(TruffleLanguage.java:3317) ~[?:?]                                                                        │
00│        at com.oracle.truffle.api.LanguageAccessor$LanguageImpl.postInitEnv(LanguageAccessor.java:289) ~[?:?]                                                           │0920│        at com.oracle.truffle.polyglot.PolyglotLanguageContext.ensureInitialized(PolyglotLanguageContext.java:689) ~[?:?]                                               │
20│        at com.oracle.truffle.polyglot.PolyglotContextImpl.eval(PolyglotContextImpl.java:1294) ~[?:?]                                                                   │
20│        at com.oracle.truffle.polyglot.PolyglotContextDispatch.eval(PolyglotContextDispatch.java:63) ~[?:?]                                                             │
20│        at org.graalvm.polyglot.Context.eval(Context.java:399) ~[?:?]                                                                                                   │
20│        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.evalInternal(GraalJSScriptEngine.java:376) ~[?:?]                                                     │
20│        at com.oracle.truffle.js.scriptengine.GraalJSBindings.initGlobal(GraalJSBindings.java:96) ~[?:?]                                                                │
20│        at com.oracle.truffle.js.scriptengine.GraalJSBindings.initContext(GraalJSBindings.java:92) ~[?:?]                                                               │
20│        at com.oracle.truffle.js.scriptengine.GraalJSBindings.requireContext(GraalJSBindings.java:86) ~[?:?]                                                            │
20│        at com.oracle.truffle.js.scriptengine.GraalJSBindings.put(GraalJSBindings.java:129) ~[?:?]                                                                      │
20│        at javax.script.SimpleScriptContext.setAttribute(SimpleScriptContext.java:246) ~[java.scripting:?]                                                              │
20│        at org.openhab.core.automation.module.script.internal.ScriptEngineManagerImpl.addAttributeToScriptContext(ScriptEngineManagerImpl.java:286) ~[?:?]              │
20│        at org.openhab.core.automation.module.script.internal.ScriptEngineManagerImpl.createScriptEngine(ScriptEngineManagerImpl.java:156) ~[?:?]                       │
20│        at org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcher.createAndLoad(AbstractScriptFileWatcher.java:328) ~[?:?]              │9.78│        at org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcher.lambda$15(AbstractScriptFileWatcher.java:306) ~[?:?]                  │
20│        at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) [?:?]                                                                       │
20│        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) [?:?]                                                                                │
20│        at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]                                                                                               │
20│        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]                                         │
20│        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]                                                                        │
20│        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]                                                                        │
20│        at java.lang.Thread.run(Thread.java:833) [?:?]                                                                                                                  │is

This error repeats for every file in $OH_CONF/automation/js

Problem 3 (may be another symptom of Problem 2)

Several of my rules are throwing this error:

20│2023-02-14 07:56:43.958 [ERROR] [e.automation.internal.RuleEngineImpl] - Failed to execute rule 'debounce4': Cannot invoke "java.util.Map.put(Object, Object)" because "│
.g│this.global" is null                                                                                                                                                    │

It seems reasonable that this error is caused by problem 2 failing to load and/or initialize something (cache perhaps?).

Your first issue is related to Remove author from addon xsd by kaikreuzer · Pull Request #3362 · openhab/openhab-core · GitHub or more specifically to the failed zigbee and zwave builds over the last few days: https://ci.openhab.org

I believe second and third issue are the same. I encountered the same today and while debugging the first one (Cannot invoke "java.nio.file.Path.resolve(java.nio.file.Path)" because the return value of "java.nio.file.Path.getRoot()" is null) I found in the debugger that this.global is null when setting the engine identifier in the script context. I’m still not sure what the root cause is.

2 Likes

I guessed it had to do with that PR. I created an issue on Zigbee [The XML document '/OH-INF/addon/addon.xml' in module 'org.openhab.binding.zigbee' could not be parsed · Issue #797 · openhab/org.openhab.binding.zigbee · GitHub] and was about to open on on zwave. Is that premature and should I close it, or go ahead and open one for Zwave too? I went ahead and closed it.

As I’m understanding it, the bindings already have a fix for this and once the builds work the problem will be solved.

Thankfully it doesn’t appear to prevent the bindings from working.

Let me know if there is any additional information or tests I can provide to help diagnosing the second two problems. Because it’s a loading file problem I immediately started wondering if those file watcher PRs that have recently been merged are the culprit.

I have created Fix build by J-N-K · Pull Request #1847 · openhab/org.openhab.binding.zwave · GitHub and Fix build by J-N-K · Pull Request #798 · openhab/org.openhab.binding.zigbee · GitHub to fix the build issues.

1 Like

I opened the below issue related to this. This seems to me to be related to the jsscripting addon more than being a core issue but I could be wrong.

Hurray! The builds completed! :partying_face:

Yep, and I have also already built a new distro from it! Build #3314 should have the new versions included.

1 Like

I can confirm, build #3314 fixes author problem in the addon.xml file from openHAB 4.0 SNAPSHOT discussion - #166 by rlkoshak as well as the Zigbee Channel ID problem reported in openHAB 4.0 SNAPSHOT discussion - #106 by rlkoshak.

Looking better! I hope the file.Path problem is this easy to find and fix too.

And I learned where to look to see when the last build was. :smiley:

Thanks everyone!

Unfortunately it’s not so easy. The issue seems to be the relative/absolute path, but I don’t know what is expected, so it’s hard to fix. Maybe @florian-h05, @digitaldan or @jpg0 can answer that.

If my absolute path to the the nodes_modules is /Users/jan/Documents/openhab-3.4.0-SNAPSHOT/userdata/automation/js/node_modules, what are isRootNodePath and nodeFileToResource(Path path) expected to return for the directory /Users/jan/Documents/openhab-3.4.0-SNAPSHOT/userdata/automation/js/node_modules and the file /Users/jan/Documents/openhab-3.4.0-SNAPSHOT/userdata/automation/js/node_modules/pingilib/index.js?

@digitaldan authored this in [jsscripting] Support non unix file paths by digitaldan · Pull Request #11805 · openhab/openhab-addons · GitHub. This was before my time as JS Scripting contributor, but reading through the PR and the linked issue I understand the purpose. I can provide you more information tomorrow.

Other JS issues will be fixed by [jsscripting] Fix node_modules handling by J-N-K · Pull Request #14398 · openhab/openhab-addons · GitHub

2 Likes

I just updated to SNAPSHOT #3323 which, if I’m reading Jenkens right is 10 hours old, so it should contain the fixes for [jsscripting] Fix node_modules handling by J-N-K · Pull Request #14398 · openhab/openhab-addons · GitHub (and the related fix for core).

Unfortunately, I’m still seeing some new errors. I tried it both with openhab-js installed via npm and using the version that comes with the add-on.

  │2023-02-20 10:04:16.400 [ERROR] [b.automation.script.javascript.stack] - Failed to execute script:                                                                      │
  │org.graalvm.polyglot.PolyglotException: TypeError: Cannot load CommonJS module: 'path'                                                                                  │
  │        at com.oracle.truffle.polyglot.PolyglotMapAndFunction.apply(PolyglotMapAndFunction.java:46) ~[?:?]                                                              │
  │        at org.openhab.automation.jsscripting.internal.OpenhabGraalJSScriptEngine.lambda$11(OpenhabGraalJSScriptEngine.java:259) ~[?:?]                                 │
  │        at java.util.Optional.orElseGet(Optional.java:364) ~[?:?]                                                                                                       │
  │        at org.openhab.automation.jsscripting.internal.OpenhabGraalJSScriptEngine.lambda$9(OpenhabGraalJSScriptEngine.java:259) ~[?:?]                                  │
  │        at <js>.:program(@globals-webpack.config.js:1) ~[?:?]                                                                                                           │
  │        at org.graalvm.polyglot.Context.eval(Context.java:399) ~[?:?]                                                                                                   │
  │        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:458) ~[?:?]                                                             │
  │        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:400) ~[?:?]                                                             │
  │        at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247) ~[java.scripting:?]                                                                    │
  │        at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutoc│
  │e.java:58) ~[?:?]                                                                                                                                                       │
  │        at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEng│
Ca│InvocableAndAutoCloseable.java:90) ~[?:?]                                                                                                                               │
20│        at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutoc│
00│e.java:58) ~[?:?]                                                                                                                                                       │42
20│        at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEng│
20│InvocableAndAutoCloseable.java:90) ~[?:?]                                                                                                                               │
20│        at org.openhab.core.automation.module.script.internal.ScriptEngineManagerImpl.loadScript(ScriptEngineManagerImpl.java:184) ~[?:?]                               │
20│        at org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcher.createAndLoad(AbstractScriptFileWatcher.java:341) ~[?:?]              │
20│        at org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcher.lambda$15(AbstractScriptFileWatcher.java:315) ~[?:?]                  │
20│        at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) [?:?]                                                                       │
20│        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) [?:?]                                                                                │
20│        at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]                                                                                               │
20│        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]                                         │
20│        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]                                                                        │
20│        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]                                                                        │
20│        at java.lang.Thread.run(Thread.java:833) [?:?]                                                                                                                  │
20│2023-02-20 10:04:16.589 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script '/openhab/conf/automation/js/openhab-js/@globals-webpack.conf│
20│ig.js': org.graalvm.polyglot.PolyglotException: TypeError: Cannot load CommonJS module: 'path'                                                                          │
20│2023-02-20 10:04:16.595 [WARN ] [ort.loader.AbstractScriptFileWatcher] - Script loading error, ignoring file '/openhab/conf/automation/js/openhab-js/@globals-webpack.co│
20│nfig.js'                                                                                                                                                                │
Ca│2023-02-20 10:04:16.684 [INFO ] [ort.loader.AbstractScriptFileWatcher] - (Re-)Loading script '/openhab/conf/automation/js/openhab-js/@openhab-globals.js'               │
2

...

  │2023-02-20 10:04:41.123 [ERROR] [b.automation.script.javascript.stack] - Failed to execute script:                                                                      │
Ca│org.graalvm.polyglot.PolyglotException: TypeError: Cannot load CommonJS module: './index'                                                                               │
20│        at com.oracle.truffle.polyglot.PolyglotMapAndFunction.apply(PolyglotMapAndFunction.java:46) ~[?:?]                                                              │
20│        at org.openhab.automation.jsscripting.internal.OpenhabGraalJSScriptEngine.lambda$11(OpenhabGraalJSScriptEngine.java:259) ~[?:?]                                 │
20│        at java.util.Optional.orElseGet(Optional.java:364) ~[?:?]                                                                                                       │
20│        at org.openhab.automation.jsscripting.internal.OpenhabGraalJSScriptEngine.lambda$9(OpenhabGraalJSScriptEngine.java:259) ~[?:?]                                  │
20│        at <js>.:anonymous(@openhab-globals.js:5) ~[?:?]                                                                                                                │la
rm│        at <js>.:program(@openhab-globals.js:3) ~[?:?]                                                                                                                  │
20│        at org.graalvm.polyglot.Context.eval(Context.java:399) ~[?:?]                                                                                                   │la
rm│        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:458) ~[?:?]                                                             │
20│        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:400) ~[?:?]                                                             │la
rm│        at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247) ~[java.scripting:?]                                                                    │
20│        at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutoc│
20│e.java:58) ~[?:?]                                                                                                                                                       │la
rm│        at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEng│
20│InvocableAndAutoCloseable.java:90) ~[?:?]                                                                                                                               │
00│        at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutoc│17
20│e.java:58) ~[?:?]                                                                                                                                                       │
20│        at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEng│
20│InvocableAndAutoCloseable.java:90) ~[?:?]                                                                                                                               │
20│        at org.openhab.core.automation.module.script.internal.ScriptEngineManagerImpl.loadScript(ScriptEngineManagerImpl.java:184) ~[?:?]                               │
20│        at org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcher.createAndLoad(AbstractScriptFileWatcher.java:341) ~[?:?]              │
20│        at org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcher.lambda$15(AbstractScriptFileWatcher.java:315) ~[?:?]                  │
20│        at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) [?:?]                                                                       │
20│        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) [?:?]                                                                                │
20│        at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]                                                                                               │
20│        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]                                         │
20│        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]                                                                        │
20│        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]                                                                        │
20│        at java.lang.Thread.run(Thread.java:833) [?:?]                                                                                                                  │
20│2023-02-20 10:04:41.138 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script '/openhab/conf/automation/js/openhab-js/@openhab-globals.js':│
20│ org.graalvm.polyglot.PolyglotException: TypeError: Cannot load CommonJS module: './index'                                                                              │
20│2023-02-20 10:04:41.138 [WARN ] [ort.loader.AbstractScriptFileWatcher] - Script loading error, ignoring file '/openhab/conf/automation/js/openhab-js/@openhab-globals.js│
20│'                                                                                                                                                                       │
20│2023-02-20 10:04:41.149 [INFO ] [ort.loader.AbstractScriptFileWatcher] - (Re-)Loading script '/openhab/conf/automation/js/openhab-js/test/@runtime.mock.js'             │  

And so on. I’m not seeing the error talking about global not being defined at least so that’s progress.

Not all the errors are exactly the same. Most of them are the “TypeError: Cannot load CommonJS module” but I’m also seeing stuff like

rm│2023-02-20 10:04:51.979 [ERROR] [b.automation.script.javascript.stack] - Failed to execute script:                                                                      │
20│org.graalvm.polyglot.PolyglotException: ReferenceError: "jest" is not defined                                                                                           │la
rm│        at <js>.:program(cache.spec.js:1) ~[?:?]                                                                                                                        │
20│        at org.graalvm.polyglot.Context.eval(Context.java:399) ~[?:?]                                                                                                   │la
rm│        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:458) ~[?:?]                                                             │
20│        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:400) ~[?:?]                                                             │
20│        at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247) ~[java.scripting:?]                                                                    │la
rm│        at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutoc│
20│e.java:58) ~[?:?]                                                                                                                                                       │
20│        at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEng│
20│InvocableAndAutoCloseable.java:90) ~[?:?]                                                                                                                               │
20│        at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutoc│
20│e.java:58) ~[?:?]                                                                                                                                                       │la
rm│        at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEng│
00│InvocableAndAutoCloseable.java:90) ~[?:?]                                                                                                                               │22
20│        at org.openhab.core.automation.module.script.internal.ScriptEngineManagerImpl.loadScript(ScriptEngineManagerImpl.java:184) ~[?:?]                               │
20│        at org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcher.createAndLoad(AbstractScriptFileWatcher.java:341) ~[?:?]              │
20│        at org.openhab.core.automation.module.script.rulesupport.loader.AbstractScriptFileWatcher.lambda$15(AbstractScriptFileWatcher.java:315) ~[?:?]                  │
20│        at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) [?:?]                                                                       │
20│        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) [?:?]                                                                                │
20│        at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]                                                                                               │
20│        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]                                         │
20│        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]                                                                        │
20│        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]                                                                        │
20│        at java.lang.Thread.run(Thread.java:833) [?:?]                                                                                                                  │
20│2023-02-20 10:04:51.984 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script '/openhab/conf/automation/js/openhab-js/test/cache.spec.js': │
20│org.graalvm.polyglot.PolyglotException: ReferenceError: "jest" is not defined                                                                                           │
20│2023-02-20 10:04:51.984 [WARN ] [ort.loader.AbstractScriptFileWatcher] - Script loading error, ignoring file '/openhab/conf/automation/js/openhab-js/test/cache.spec.js'│

There are tons of these but a lot of them seem to be coming from the unit tests.

However, once everything settles, the rules appear to work without error. So the errors are more alarming than a problem, though I do need to remember to manually run my System runlevel reached rules by hand after a restart. :partying_face: