openHAB 3.0 Milestone 2 discussion

As I’m migrating over my rules from OH2 to OH3 I’ve run into an issue with a library that I use in a few places. Specifically: “org.eclipse.smarthome.model.script.ScriptServiceUtil”. I use this to access items as I roll through a group looking at statuses. For example, I would use it as: “ScriptServiceUtil.getItemRegistry.getItem(”.

Unfortnately now I get an error of: “Script execution of rule with UID ‘thingstate-2’ failed: The name ‘ScriptServiceUtil’ cannot be resolved to an item or type; line 87, column 60, length 17” when the rule runs. I’m assuming that the problem is that I’m referencing org.eclipse.smarthome which I believe is now changed. Can someone point me to the direction of the proper location?

EDIT: For anyone looking, use “org.openhab.core.model.script.ScriptServiceUtil”


The eclipse smarthome pathing has been completely removed from OH3.

To be precise, it had been renamed, so now it is called


Thanks y’all!

Next question, why did this break executeCommandLine between OH2 and OH 3:

2020-11-08 22:00:41.584 [WARN ] [] - Error occurred when executing commandLine '[/usr/bin/curl -s -X GET 'http://removed:8060/query/device-info’]’ Cannot run program “/usr/bin/curl -s -X GET ‘http://removed:8060/query/device-info’”: error=2, No such file or directory

For reference, when I copy/paste the curl line at a bash prompt on the openhab user it works just fine.

Try putting the command into a shell script & run that, executeCommandLine has no shell environment.

As mentioned earlier in this thread, executeCommandLine() has a new syntax in OH3

I’ve just added this to the notice -

1 Like

Forgive the ignorance, what am I doing wrong here with the new syntax?

var String deviceinfo = executeCommandLine(Duration.ofSeconds(5),"/usr/bin/curl","-s","-X",“GET”,"’",url,“query/device-info’”)

I’ve tried with the ’ escaped and non escaped. All that I get back is null.

This looks like its going to produce something like
... ' somestuff query/device-info’
which is maybe not what you wanted.
If you want to build a string without spaces, do that first

var xx = "'" + url +  "query/device-info’"
executeCommandLine( ... "GET", xx)

Draft PR to add expire as a core feature was openend 10 hours ago


Also need to make sure to Validate JSON data… this tool may help

1 Like

I tend to use

1 Like

Still getting a null back. I dumped the deviceinfourl out to the log file and it looks fine. I ran the curl script manually and it returns no issues.

    var String url = ""
    var String deviceinfourl = ""

            url = s.get(1)
            deviceinfourl = "'" + url + "query/device-info'"
            var String deviceinfo = executeCommandLine(Duration.ofSeconds(5),"curl","-s","-X","GET",deviceinfourl)

If you are using a language other than Rules DSL, the item registry is available as the variable ir so you can just use ir.getItem( If you are using the image registry to get at an Item’s state you can use items: items[].

There is no reason to call toString on, name is already a String.

When you’re ready, we’d like to see your logs too. Why is this always such hard work. All of us make typos we can’t spot etc.

1 Like

Let me know what you want dialed up. I get no logging errors at all when this runs.

I HATE making typoes in messages meant to correct somebody else’s typo. :roll_eyes:

This is in the rules DSL hence the need for it. Agreed on the toString, I probably had it in there a long time ago for some reason and just never pulled it out.

I enabled debugs and I see this now.

2020-11-09 21:44:41.533 [DEBUG] [] - exit code '6', result '', errors '  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                             Dload  Upload   Total   Spent    Left  Speed
0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: 'http

I removed the single ’ in the url and I get the correct reply as per the debug back but I still get exit code 6 which is making it return null.

Edits on top of edits. When I send the URL as a string variable, without the ', it seems to work.

I’m seeing the same thing. I can manually remove the subject MergeList item and I can then run upgrade, but running apt update adds the list back.

Consequently, I recently updated Ubuntu to 20.04.01 (both for OH2 and OH3). Both environments have the same error message for the Test repository.

Is this possibly an Ubuntu thing?

In the new Rule Editor, how do you delete a rule? There doesn’t seem to be an option available other than to disable it.