openHAB 3.0 Milestone 2 discussion

First of all, I would like to say that I’m very impressed about OH3.
Actually I’m trying to migrate my OH2 instance, but I have some problems with the sitemap validator.
I’m using unicode charactors to display some icons in Basic-UI, but the validator don’t like them:

Switch item=LG_TV0_KeyDummyArrow mappings=[0="\u2190", 1="\u2193", 2="\u2191", 3="\u2192"]

Is unicode not longer supported? Or is there another way to define it?

There is another problem with the sitemap validator:
If I define a selection with mapping in the code view and then switch to design view and back the quotes get lost and the result is an validation error.

Code: Selection item=LG_TV0_Application mappings=["com.webos.app.livetv"="TV", "com.webos.app.tvguide"="TV Guide"]

After switch: Selection item=LG_TV0_Application mappings=[com.webos.app.livetv="TV",com.webos.app.tvguide="TV Guide"]

Did you actually use smart quotes or just forget the code fences here? :wink:

Sorry I forgot the code fences

1 Like

I thought it best to check because I would expect smart quotes to break things.

Before I go file a bug, is there any reason isNumeric() is no longer working?

2020-11-12 22:00:33.993 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'roku-4' failed: 'isNumeric' is not a member of 'java.lang.String'; line 170, column 16, length 67 in roku

caused by:
receivedCommand.split("_").get(1).isNumeric()

I’ve tried other variants by adding .toString() to force (what should already be a string) to be recognized as a string and it has no impact. The purpose of this check is to see if the string that was sent is a number (in this case, an app ID for a roku).

i only have added 4 things, these 4 in the second picture, so there is no thing with the same name :confused:

Has that ever worked? isNumeric is not a method on java.lang.String for neither Java 8 nor Java 11 and you are working with a java.lang.String. Are you using Jython perhaps?

It’s worked fine on OH2. It’s been part of my Roku rules for several years now. All rules DSL, nothing fancy. I use zulu for my java backend so maybe it was pulled out between zulu8 and zulu11?

To my amazement, it does not explode in OH2.5 / Oracle Java 8
but neither does it seem to work

var xx = "32.7"
var yy = xx.isNumeric()
logInfo("test", " yy is " + yy.toString)
2020-11-13 00:16:20.782 [INFO ] [.eclipse.smarthome.model.script.test] -  yy is false
1 Like

Removed in OH3

1 Like

Just counting down to M3 where I can finally use OH3 with expire binding

3 Likes

I open an issue on this, but posting here in case anyone knows of a fix.

I inadvertently while using the rest api explorer sent a malformed request to add an item OH. Everytime I start openHAB I receive an error and rules, items and other elements are not loaded.

2020-11-13 11:10:35.608 [WARN ] [ore.common.registry.AbstractRegistry] - Cannot add "SwitchItem" with key "API Switch": The specified name of the item 'API Switch' is not valid!
java.lang.IllegalArgumentException: The specified name of the item 'API Switch' is not valid!
	at org.openhab.core.items.ItemUtil.assertValidItemName(ItemUtil.java:79) ~[bundleFile:?]
	at org.openhab.core.internal.items.ItemRegistryImpl.initializeItem(ItemRegistryImpl.java:183) ~[bundleFile:?]
	at org.openhab.core.internal.items.ItemRegistryImpl.onAddElement(ItemRegistryImpl.java:232) ~[bundleFile:?]
	at org.openhab.core.internal.items.ItemRegistryImpl.onAddElement(ItemRegistryImpl.java:1) ~[bundleFile:?]

It appears the request to add the item is persisted somewhere (maybe by the karaf framework?) but I can’t seem to find where to clear it out. Does anyone know how to clear out pending elements without a reinstall? I have already cleared the cache.

Can you delete the Item with API Explorer?

It is likely stores in the JsonDb. It should be editable with OH shut down, I believe.

Can you delete the Item with API Explorer?

No because the item is never added successfully added

It is likely stores in the JsonDb. It should be editable with OH shut down, I believe

The JSON DB is empty

It appears it gets persisted somewhere by the framework itself as an event.

Any suggestion on how to import isNumeric() back into the rules DSL for use? I’ve tried just importing org.apache.commons.lang.StringUtils at the top but I can’t seem to get the syntax for StringUtils working correctly.

That would have worked had you used “32” instead of “32.7”. It very literally only looks for 0-9 as the only characters, the decimal point caused it to fail.

Just do something like:

var str = "32"
try {
   var number = Integer.parseInt(str)
   // Do stuff
} catch (NumberFormatException e) {
   // Do other stuff
}
1 Like

That worked. Not the most elegant thing but it gets me back up and going. Thanks!

I really like where Openhab is going with these releases! Some quirks that I have observed so far:

  • time to boot openhab up is significantly longer than it was with openhab 2 (now ~5 minutes, before ~30 seconds)
  • overall a tad less snappy than OH2, especially latency between physical interaction and reaction of the system
  • sometimes most of my rules just stop working. Right now I can’t make them work anymore, but since its in the middle of the night now I give up :slight_smile:
    All rules have been imported from OH2 rules files.

Relevant Log entries (interesting: Caused by: java.lang.IllegalStateException: Cannot create a duplicate value ‘newState’.):

[ERROR] [e.automation.internal.RuleEngineImpl] - Failed to execute rule ‘licht-2’: Fail to execute action: script
[DEBUG] [e.automation.internal.RuleEngineImpl] -
java.lang.RuntimeException: Fail to execute action: script
at org.openhab.core.automation.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1187) ~[bundleFile:?]
at org.openhab.core.automation.internal.RuleEngineImpl.runRule(RuleEngineImpl.java:987) [bundleFile:?]
at org.openhab.core.automation.internal.TriggerHandlerCallbackImpl$TriggerData.run(TriggerHandlerCallbackImpl.java:91) [bundleFile:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.lang.IllegalStateException: Cannot create a duplicate value ‘newState’.
at org.eclipse.xtext.xbase.interpreter.impl.DefaultEvaluationContext.newValue(DefaultEvaluationContext.java:46) ~[?:?]
at org.openhab.core.model.script.runtime.internal.engine.DSLScriptEngine.createEvaluationContext(DSLScriptEngine.java:143) ~[?:?]
at org.openhab.core.model.script.runtime.internal.engine.DSLScriptEngine.eval(DSLScriptEngine.java:118) ~[?:?]
at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.lambda$0(ScriptActionHandler.java:62) ~[?:?]
at java.util.Optional.ifPresent(Optional.java:183) ~[?:?]
at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.execute(ScriptActionHandler.java:59) ~[?:?]
at org.openhab.core.automation.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1179) ~[bundleFile:?]
… 7 more

Running on build #2009

Edit: #2009 seems to be broken acc. to Rule causes high load and queue issues - #5 by Lolodomo

1 Like