It seems that I still get the same error messages in the OH log for both rules and I don’t see the Blockly blocks in the Actual energy consumption rule. At first I deleted both rules, uninstalled the Marketplace add-ons and restarted OH. I then installed both add-on from the marketplace and created new rules. Somehow it seems that the add-ons were not perhaps updated when I tried to recreate new rules.
I saw earlier that you configured rrd4j as persistence, but always asked if influxDB would be supported.
If you use influxDB, please configure persistence to „default“ and try again.
When you uninstall the template through addon store and reinstall add them again, the latest version gets pulled from the marketplace, so you have the actual ones.
@rlkoshak do you have an idea what could be wrong ?
If I add both templates from the marketplace, I can add new rules from them and they are working fine….
Thanks for your feedback and sorry for the inconvenience.
I am new to rule templates, that’s why I forget about the dependency…
I will update the template post so that nobody else falls into that trap…
Looking at the historical rule it looks reasonable.
I don’t have all these Items so I can’t create an instance of the rule that makes sense in my system right now (I do have an energy meter so stay tuned) but looking at the JS code in the template the only thing that stands out is that first line doesn’t actually do anything:
It pulls the deltaSince but doesn’t save it to a variable so it’s kind of a noop.
But the rest of the rule looks OK so it should be fine as written.
The actual energy rule might have a problem. The last line of the script action seems to have an unmatched closing }. But it’s not entirely clear that’s really the case and how that happened at all using Blockly in the first place.
I see that you got it to work so that } is a mystery.
Note that in OH 4 most of those blocks are now implemented by the base Blockly under the Dates and Times category. The blocks are implemented slightly differently but if you used those users of your templates wouldn’t need to install the separate library.
Thanks for your feedback.
I tried to get rid of that dependency, but could not find the correct block. Can you please point me to which one you are referring to ?
2023-11-06 23:18:57.752 [ERROR] [b.automation.script.javascript.stack] - Failed to execute script:
org.graalvm.polyglot.PolyglotException: TypeError: Cannot read property "value" from undefined
at <js>.:program(<eval>:4) ~[?:?]
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:426) ~[?:?]
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:262) ~[java.scripting:?]
at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutocloseable.java:53) ~[?:?]
at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.java:78) ~[?:?]
at org.openhab.automation.jsscripting.internal.scriptengine.DelegatingScriptEngineWithInvocableAndAutocloseable.eval(DelegatingScriptEngineWithInvocableAndAutocloseable.java:53) ~[?:?]
at org.openhab.automation.jsscripting.internal.scriptengine.InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.eval(InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable.java:78) ~[?:?]
at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.lambda$0(ScriptActionHandler.java:71) ~[?:?]
at java.util.Optional.ifPresent(Optional.java:178) [?:?]
at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.execute(ScriptActionHandler.java:68) [bundleFile:?]
at org.openhab.core.automation.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1188) [bundleFile:?]
at org.openhab.core.automation.internal.RuleEngineImpl.runRule(RuleEngineImpl.java:997) [bundleFile:?]
at org.openhab.core.automation.internal.TriggerHandlerCallbackImpl$TriggerData.run(TriggerHandlerCallbackImpl.java:87) [bundleFile:?]
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) [?:?]
2023-11-06 23:18:57.757 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'energyUsageActual' failed: org.graalvm.polyglot.PolyglotException: TypeError: Cannot read property "value" from undefined
Start of Month and Year are working with the following
I updated the marketplace templates and both Edit script pages show the Blockly block. I have a small glitch, though. Some of the Items show “NULL” (see the screencopy) and this has been the case since I installed the widget.
I checked that e.g. the Item for Consumption Actual Month is “NULL”.
This is really nice widget and I’m going to adapt it to my other purposes.
Please note that the weekly/monthly/yearly Items get updated only at the first of a week/month/year, so you won’t see any values until then.
Your missing billing cycle value looks like a bug/issue. Anything in the logs? Did you set the DateTime Item correct?
This is a really simple but informative widget, I have modified it for my gas- and watermeter to have them shown with the same look and feel…
Yes, I have a energy meter reading for that date/time. There are no error/warning messages in the log. I think I need to look at your code and see how the billing cycle is handled.