Closed mherwege closed 1 week ago
When working on this PR, I tested all overloads and @jlaur tested as well, I wonder why it fails for you.
Have you configured the add-on to use the included library version?
@florian-h05 - I just retested with one of my previous testcases, and it fails for me also now, but only when using library injection (I still have the manually installed openhab-js you provided previously).
The example is here: openhab/openhab-addons#16889
And the logs:
org.graalvm.polyglot.PolyglotException: TypeError: invokeMember (persist) on org.openhab.core.persistence.extensions.PersistenceExtensions failed due to: no applicable overload found (overloads: [Method[public static void org.openhab.core.persistence.extensions.PersistenceExtensions.persist(org.openhab.core.items.Item,org.openhab.core.types.TimeSeries,java.lang.String)], Method[public static void org.openhab.core.persistence.extensions.PersistenceExtensions.persist(org.openhab.core.items.Item,java.lang.String)], Method[public static void org.openhab.core.persistence.extensions.PersistenceExtensions.persist(org.openhab.core.items.Item)], Method[public static void org.openhab.core.persistence.extensions.PersistenceExtensions.persist(org.openhab.core.items.Item,java.time.ZonedDateTime,org.openhab.core.types.State)], Method[public static void org.openhab.core.persistence.extensions.PersistenceExtensions.persist(org.openhab.core.items.Item,java.time.ZonedDateTime,org.openhab.core.types.State,java.lang.String)], Method[public static void org.openhab.core.persistence.extensions.PersistenceExtensions.persist(org.openhab.core.items.Item,java.time.ZonedDateTime,java.lang.String)], Method[public static void org.openhab.core.persistence.extensions.PersistenceExtensions.persist(org.openhab.core.items.Item,java.time.ZonedDateTime,java.lang.String,java.lang.String)], Method[public static void org.openhab.core.persistence.extensions.PersistenceExtensions.persist(org.openhab.core.items.Item,org.openhab.core.types.TimeSeries)]], arguments: [JavaObject[TotalPrice (Type=GroupItem, BaseType=NumberItem, Members=5, State=2.2856937562500000000000000000000008400000 DEF/kWh, Label=, Category=) (org.openhab.core.items.GroupItem)] (HostObject), DynamicObject<JSOrdinary>@16cf3a38 (DefaultLayout)])
at <js>.#n(@openhab-globals.js:2) ~[?:?]
at <js>.persist(@openhab-globals.js:2) ~[?:?]
at <js>.:=>(test.js:35) ~[?:?]
at <js>.:=>(@jsscripting-globals.js:167) ~[?:?]
at com.oracle.truffle.polyglot.PolyglotFunctionProxyHandler.invoke(PolyglotFunctionProxyHandler.java:154) ~[?:?]
at jdk.proxy1.$Proxy208.run(Unknown Source) ~[?:?]
at org.openhab.automation.jsscripting.internal.threading.ThreadsafeTimers.lambda$1(ThreadsafeTimers.java:107) ~[?:?]
at org.openhab.core.internal.scheduler.SchedulerImpl.lambda$12(SchedulerImpl.java:189) ~[?:?]
at org.openhab.core.internal.scheduler.SchedulerImpl.lambda$1(SchedulerImpl.java:88) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
at java.lang.Thread.run(Thread.java:833) [?:?]
console.log(utils.OPENHAB_JS_VERSION);
logs "5.1.0"
I installed the addon in a fresh install and didn’t change any configuration. So I was expecting the included library version to be used. I didn’t install it externally either.
and it fails for me also now, but only when using library injection
This made me find the error very quickly, I will provide a fix tomorrow.
@mherwege @jlaur Have you been able to verify that the issue is fixed now?
@mherwege @jlaur Have you been able to verify that the issue is fixed now?
I just tried with build 4131:
Unfortunately it still did not work. Does it work for you?
I didn’t try yet, didn’t have a snapshot with the update installed so far.
@jlaur Second attempt, please merge: https://github.com/openhab/openhab-addons/pull/16926
@florian-h05 @jlaur The snapshot build still does not contain the newest openhab-js version, but I updated the bundle manually. I can confirm it now works for me with the development work done for Blocky and the test example listed here: https://github.com/openhab/openhab-webui/pull/2596#issuecomment-2186494902
Great. Wrt to the snapshot: it seems Jenkins did not build a snapshot due to some issues, but I’ve read that it should work again now.
Wrt to the snapshot: it seems Jenkins did not build a snapshot due to some issues, but I’ve read that it should work again now.
Yes, but it is still running. So it should be resolved in a bit.
Build has just finished.
For me it still doesn't work with build 4132.
It worked for me when manually building the bundle while working on the openhab-js code.
Is there anything it would help to check? Oh, now I noticed rule output of:
console.log(utils.OPENHAB_JS_VERSION);
Result:
2024-06-24 17:52:10.497 [INFO ] [enhab.automation.script.file.test.js] - 5.1.1
This is unexpected. I had cleaned cache and tmp.
This is indeed interesting. Please check what’s inside /etc/openhab/automation/js/node_modules and check the add-on settings.
In automation/node_modules I have:
But I have configured the add-on to use injection. When flipping that setting to use above provided library I get:
2024-06-24 18:06:26.850 [INFO ] [enhab.automation.script.file.test.js] - 5.0.0
Can you please remove them both?
Sure, I just tried that, it made no difference. I also deleted cache+tmp before starting openHAB again.
Seems that something went wrong during the addon build and no new bundle was uploaded.
I have just checked which JS Scripting add-on version I get for the current snapshot, it is 4.2.0.202406230328
which obviously is too old to contain openhab-js 5.1.2.
@florian-h05 - with build 4135 I can finally confirm that version 5.1.2 is installed and that the rule utilizing the new PersistenceExtensions
works with this injected new version.
Based on https://github.com/openhab/openhab-js/pull/341, I am experimenting with persisting TimeSeries, the aim being to build this into Blockly.
In my tests, I am running build #4125, which I believe should include the updated js version (JavaScrip Scripting bundle addon version is 4.2.0.202406170328).
The following code fails on the last line (largely generated from my Blockly experiment, but running from a UI script). The first
persist
call with aZonedDateTime
andString serviceId
works. The second call (last line) fails, and the log tells it cannot find an applicable overload function. As you can see, this code retrieves states from persistence from one item and tries to store the retrieved values to another item.Here is the log:
I may be doing something wrong here, but I was expecting it would be possible to create a
TimeSeries
to then persist it.