openHAB 4.0 SNAPSHOT discussion

The issue is that the ZigBee binding passes the full UID as string where it should only pass the id-part. The UID itself is fine. This was not working before, but did not result in an error. Since it is a clear bug to pass the UID instead of the id, this should be fixed in the binding.

2 Likes

I agree. It is at least unexpected that the configuration is not ā€œrestoredā€ and the backup is used again. I donā€™t think it has a high priority to fix it, but please open an issue for that.

Iā€™m back again with some new weirdness.

The following code:

var item = items.getItem('TestSwitch');
item.postUpdate( ((item.state == "ON") ? "OFF" : "ON") );
setTimeout( () => {
  console.log('changedSince true: ' + items.getItem('TestSwitch').history.changedSince(time.toZDT('PT-1M'), 'rrd4j'));
  console.log('changedSince false: ' + items.getItem('TestSwitch').history.changedSince(time.toZDT('PT-30S'), 'rrd4j')); 
}, time.toZDT('PT50S').getMillisFromNow());

generates a Java Heap Exception.

rmā”‚2023-02-01 14:47:09.646 [WARN ] [ore.internal.scheduler.SchedulerImpl] - Scheduled job 'org.openhab.automation.script.ui.scratchpad.timeout.1' failed and stopped       ā”‚
20ā”‚org.graalvm.polyglot.PolyglotException: Java heap space                                                                                                                 ā”‚la
rmā”‚        at org.rrd4j.core.Archive.fetchData(Archive.java:303) ~[?:?]                                                                                                    ā”‚
20ā”‚        at org.rrd4j.core.RrdDb.fetchData(RrdDb.java:986) ~[?:?]                                                                                                        ā”‚la
rmā”‚        at org.rrd4j.core.FetchRequest.fetchData(FetchRequest.java:163) ~[?:?]                                                                                          ā”‚
20ā”‚        at org.openhab.persistence.rrd4j.internal.RRD4jPersistenceService.query(RRD4jPersistenceService.java:330) ~[?:?]                                                ā”‚
20ā”‚        at org.openhab.core.persistence.extensions.PersistenceExtensions.getAllStatesBetween(PersistenceExtensions.java:1263) ~[?:?]                                    ā”‚
20ā”‚        at org.openhab.core.persistence.extensions.PersistenceExtensions.internalChanged(PersistenceExtensions.java:307) ~[?:?]                                         ā”‚
20ā”‚        at org.openhab.core.persistence.extensions.PersistenceExtensions.changedSince(PersistenceExtensions.java:286) ~[?:?]                                            ā”‚
00ā”‚        at org.openhab.core.persistence.extensions.PersistenceExtensions.changedSince(PersistenceExtensions.java:259) ~[?:?]                                            ā”‚36
20ā”‚        at java.lang.invoke.DirectMethodHandle$Holder.invokeStatic(DirectMethodHandle$Holder) ~[?:?]                                                                    ā”‚
20ā”‚        at java.lang.invoke.LambdaForm$MH/0x00000001015c8c00.invoke(LambdaForm$MH) ~[?:?]                                                                               ā”‚
20ā”‚        at java.lang.invoke.LambdaForm$MH/0x0000000100d59400.invokeExact_MT(LambdaForm$MH) ~[?:?]                                                                       ā”‚
20ā”‚        at <js>.changedSince(/openhab/conf/automation/js/node_modules/openhab/items/item-history.js:68) ~[?:?]                                                          ā”‚
20ā”‚        at <js>.:=>(<eval>:7) ~[?:?]                                                                                                                                    ā”‚

Changing persistence from rrd4j to mapdb works as expected (or at least doesnā€™t throw an error, but changedSince returns true in both cases which shouldnā€™t be the case but thatā€™s a different issue.

@rlkoshak - can you try latest snapshot where this is already included?

I tested on snapshot #3296 and I still get the exception.

Given that that fix was merged a mere 18 hours ago, maybe it wonā€™t be available until #3297? Iā€™m on Docker so the snapshots are potentially delayed a bit since a new image canā€™t be created until after the distro build completes.

Any idea where to look to see the status of the snapshot builds?

Edit: Indeed it looks like the snapshot is delayed. I just saw mention of #3298 in a new issue Things not in alphabetical order on UI Ā· Issue #1673 Ā· openhab/openhab-webui Ā· GitHub so I may have to wait a couple of days to test this.

Edit2: OK, managed to test on 3299 and can confirm that the exception went away. :partying_face:

thanks!

2 Likes

This one is a minor nit pick but has the potential to become really annoying for upgraders.

After an upgrade from 3.4 to 4.0, the javascript tranformation add-on remains listed in /var/lib/openhab/config/org/openhab/addons.config and I can see no way to remove it though the UI directly.

I tried to explore the REST API but I couldnā€™t figure out a way to get any information or remove it from there.

I looked in the karaf console but I canā€™t find a way to list that itā€™s configured to install there. Obviously it doesnā€™t show up under bundles because it cannot be installed.

The only way I can figure out to remove it from being attempted to install (and the resultant error) is to manually edit addons.config.

Is there a way we can automatically remove this add-ons during the upgrade?

I wish I had more details to report on this one but I donā€™t. Please let me know what might prove useful and Iā€™ll gather it.

What Iā€™m finding is an inconsistent restart behavior with OH.

ScriptEngine for language not found

2023-02-09 09:07:38.776 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - ScriptEngine for language 'application/javascript' could not be found for identifier: 241daa5c-789c-4e0d-a430-75c38fef80b2

About one in three restarts will generate a ton of these errors (I suspect one for each rule).

system runlevel triggered rules

Sometimes, these rules just never get triggered. I have them set to runlevel 40 but Iā€™ve tried every run level available and see the same result. Occasionally (I canā€™t give a good measure for how often yet) they simply wonā€™t trigger. Running them manually later works just fine and non-runlevel triggered rules run fine too.

I donā€™t have any runlevel rules where that is the only trigger for the rule, if that matters. Thereā€™s always at least one other trigger.

rules page fails to load
At least twice after a restart the rules page will fail to load. Scripts and Schedule loaded just fine. This one is really odd and may just be gremlins. Iā€™ll report more when/if it happens again. Itā€™s only happened to me twice so far. Iā€™m mainly posting here in case others have see this.

Edit: I think I may have found the root cause of this one. I was attempting to avoid some ā€œMulti threaded accessā€ errors on a rule that calls another rule and sometimes it gets pounded. Iā€™ve applied a gatekeeper to spread the commands out and as Iā€™ve increased the timing Iā€™m starting to see:

  ā”‚2023-02-09 09:22:29.408 [WARN ] [ab.core.internal.events.EventHandler] - Dispatching/filtering event for subscriber 'org.openhab.core.events.EventSubscriber' failed: Taā”‚
  ā”‚sk java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask@2f538f6d[Not completed, task = java.util.concurrent.Executors$RunnableAdapter@5f063a90[Wrapped tā”‚
  ā”‚ask = org.openhab.core.automation.internal.TriggerHandlerCallbackImpl$TriggerData@6d9588f8]] rejected from java.util.concurrent.ScheduledThreadPoolExecutor@796b02e2[Terā”‚
  ā”‚minated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 1]                                                                                      ā”‚
  ā”‚java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask@2f538f6d[Not completed, task = java.util.concā”‚
  ā”‚urrent.Executors$RunnableAdapter@5f063a90[Wrapped task = org.openhab.core.automation.internal.TriggerHandlerCallbackImpl$TriggerData@6d9588f8]] rejected from java.util.ā”‚
  ā”‚concurrent.ScheduledThreadPoolExecutor@796b02e2[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 1]                                   ā”‚
  ā”‚        at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2065) ~[?:?]                                                   ā”‚
  ā”‚        at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:833) ~[?:?]                                                                           ā”‚
  ā”‚        at java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(ScheduledThreadPoolExecutor.java:340) ~[?:?]                                                 ā”‚
00ā”‚        at java.util.concurrent.ScheduledThreadPoolExecutor.schedule(ScheduledThreadPoolExecutor.java:562) ~[?:?]                                                       ā”‚
20ā”‚        at java.util.concurrent.ScheduledThreadPoolExecutor.submit(ScheduledThreadPoolExecutor.java:715) ~[?:?]                                                         ā”‚
20ā”‚        at java.util.concurrent.Executors$DelegatedExecutorService.submit(Executors.java:748) ~[?:?]                                                                    ā”‚
20ā”‚        at org.openhab.core.automation.internal.TriggerHandlerCallbackImpl.triggered(TriggerHandlerCallbackImpl.java:57) ~[?:?]                                         ā”‚
20ā”‚        at org.openhab.core.automation.internal.module.handler.GroupStateTriggerHandler.receive(GroupStateTriggerHandler.java:144) ~[?:?]                               ā”‚
20ā”‚        at org.openhab.core.internal.events.EventHandler.lambda$0(EventHandler.java:151) ~[?:?]                                                                         ā”‚
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.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) [?:?]

Now this would make sense if gatekeeper created a separate timer for each event awaiting itā€™s time to run but it doesnā€™t. It has one looping timer that works off a queue.

More investigation is required but this is a problem Iā€™m sure Iā€™m causing through abusing OH in ways it canā€™t handle.

**No config description"
Every reboot I see this warning:

2023-02-09 08:56:09.678 [WARN ] [core.thing.internal.ThingManagerImpl] - No config description for 'channel-type:http:channel-config-switch' found when normalizing configuration for 'http:url:adguard:protection_status'. This is probably a bug.

This is related to the HTTP binding (see Simple AdGuard Home Integration using the HTTP Binding).

Iā€™m not sure what to do about it but the Things still appears to work.

I donā€™t think this is directly related to the HTTP binding, but could be related to bindings having channel configuration. Iā€™m seeing the same for a new binding Iā€™m developing, but not consistently. I think it may get fixed by:

1 Like

Hi,

Iā€™m finding a few bugs and wondering if anyone knows anything about them before I submit issues on gitub.

1. time.Duration

      const timerDuration = items.getItem('BackHall_Ceiling_Light_MotionTimer').state // A Number Item

      console.info(time.Duration.ofSeconds(1))
      console.info(time.Duration.ofMinutes(1))

      console.info(time.Duration.ofSeconds(timerDuration))

give me PT1S, PT1M, and PT1S respectively.

But

console.info(time.Duration.ofMinutes(timerDuration))

throws an error:

ArithmeticException: Multiplication overflows: 1 * 60: ArithmeticException: Multiplication overflows: 1 * 60

and ofHours says something similar:

ArithmeticException: Multiplication overflows: 1 * 3600: ArithmeticException: Multiplication overflows: 1 * 3600

only ā€˜ofSecondsā€™ seems to work.

2. things.getThings() .setLabel
When I change a thingā€™s label with JS Scripting, it works, but doesnā€™t stick after a reboot.

things.getThing('test:thing:45636344247:62464367').setLabel('A New Label')

3. items.replaceItem
With JS Scripting, if I set the giBaseType to ā€˜Stringā€™, it doesnā€™t apply this to the new item. Other base types and aggregation functions work fine.

items.replaceItem({
        type: 'Group',
        name: 'Item_Name',
        label: 'Item Label',
        groups: ['group1', 'group2'],
        tags: ['Setpoint'],
        category: 'lightbulb',
        giBaseType: 'Switch'
        //  groupFunction: aggregationFunction
    });

4. Applying metadata
When I apply metadata (any kind) using JS scripting, it works, but the UI displays ā€˜Not Setā€™

let itemToEdit = items.getItem('Test_Item);
itemToEdit.replaceMetadata('stateDescription', '', { options: 'ON=MOTION,OFF=NO MOTION'} );

5. material icons
I can apply a material icon and it works in most places.
image

but it shows as blank in a default list widget

******** I Posted this in the wrong place and am moving it here. I already got a reply which Iā€™ll post here: *******

Please post to openHAB 4.0 SNAPSHOT discussion where the 4.0 SNAPSHOT problems are discussed.

Note that timerDuration in this case is a String. The .state is always a String. You might need to parse it to a Number first.

But in any case, this is 100% implemented in the joda-js library so any issue would need to be filed and corrected there. Itā€™s not an OH problem.

How is the Thing defined? In a text file or through the UI?

What use case would have you changing the label of a Thing?

Note, this code is not correct (missing a closing ā€™ on the first line).

Which version of openhab-js are you using? The metadata was completely reworked in the latest release.

Show the full config from the ā€œCodeā€ tab.

You are testing the 4.0 SNAPSHOT. Tons of breaking changes are being introduced with almost every build. Welcome to the bleeding edge.

Yes, this worked for me. Thank you

const timerDuration = items.getItem('BackHall_Ceiling_Light_MotionTimer').state
console.info(time.Duration.ofHours(+timerDuration))

with the JS Scripting command:

things.getThing('test:thing:45636344247:62464367').setLabel('A New Label')

I am using it to rename things to remove some bits deCONZ adds to the thing names, and to rename them be able to make items from them based on the name. I can then recreate all my lights, motion sensors, TRVs, and everything else generic in my system in one go. Itā€™s working great so far. I can rebuild my entire system and make small changes to names, labels, icons etc to hundreds of items at once.

That is a typo, the bug is still there. I am using the latest openhab-js, installed with npm. I specifically needed the metadata updates to make this project happen.

There is no code. This is the default widget that gets displayed in the Locations tab of the main page.

No, that doesnā€™t create a Thing. And it doesnā€™t make much sense to create a thing in a rule anyway.

If this the thing ā€œtest:thing:45636344247:62464367ā€ doesnā€™t exist before that call, itā€™s not surprising if it disappears after a restart. At a minimum it wonā€™t be a complete Thing and it definitely isnā€™t connected to any binding.

If you want a Thing to test stuff with, see the Magic Binding in the marketplace which lets you define Things that can be used to test with. But again, you wouldnā€™t be creating the Thing from a Rule this way. Thatā€™s putting the cart before the horse.

If itā€™s for existing Things, thatā€™s a question for someone who maintains core as to whether changes made that way are even expected to be saved or not.

But going forward you have to option to change the name and the UID of Things at the time you accept them from the inbox. You can change the name later through MainUI or the REST API also.

As far as I know, the default widgets use the oh icons set on the Itemā€™s ā€œcategoryā€. If you want to use material, f7, or iconify icons it requires a custom widget configuration. How are you telling it to use a material icon?

1 Like

I didnā€™t say it made a new thing. I said it changes the label of a thing. It works. I can see it happening. It just doesnā€™t hold after reboot.

I just typed material:iconname into the category field of the item in the UI

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.