Checking for openHAB updates - simple rule

Is it possible to also check if a binding has been updated? Both verified , on the market place and on github?

The version number of all the official bindings will move forward with the relase version number of the core. The only way to know what changes are included in a given release number is to watch the merged PRs on github. I don’t know how versioning is managed on the IoT marketplace.

Have you tried the code on post #15

2018-05-28 11:07:20.736 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Error during the execution of startup rule 'rule 2: Check for openHAB distro updates': For input string: "Release Build"

I geht this error.

Any idea what i have to change in my rule?

rule "rule 2: Check for openHAB distro updates"
when
    Time is midnight or
    Item OH_CheckForUpdates received command ON or
    System started
then
    OH_Status.postUpdate("Checking...")
    var String cloudbeesUrl = "https://openhab.ci.cloudbees.com/job/openHAB-Distribution/api/json?tree=lastSuccessfulBuild[number]"
    var String currentBuildString = executeCommandLine("/etc/openhab2/scripts/check-oh-build.sh", 2000)
    var response = sendHttpGetRequest(cloudbeesUrl)
    var lastBuildNumber = transform("JSONPATH", "$.lastSuccessfulBuild.number", response)
    OH_LastBuild.postUpdate(lastBuildNumber)
    if (Integer.parseInt(currentBuildString) < Integer.parseInt(lastBuildNumber)) {
            OH_Status.postUpdate("neues Update vorhanden: #" + lastBuildNumber)
            // Do something with that information
    }
    else {
            OH_Status.postUpdate("kein Update verfügbar")
    }
    OH_CheckForUpdates.postUpdate(OFF)
end

I have identified this part of my rule, which is causing the error:
(rest of the rule is running without errors)

if (Integer.parseInt(currentBuildString) < Integer.parseInt(lastBuildNumber)) {
            OH_Status.postUpdate("neues Update vorhanden: #" + lastBuildNumber)
    }

And this:

2018-05-28 11:44:05.674 [WARN ] [me.internal.engine.RuleContextHelper] - Variable 'currentBuild' on rule file 'oh_update.rules' cannot be initialized with value 'org.eclipse.xtext.xbase.impl.XConstructorCallImplCustom@51a0072b (invalidFeatureIssueCode: null, validFeature: false, explicitConstructorCall: true, anonymousClassConstructorCall: false)': For input string: "Release Build"
#!/bin/bash
sed -n 's/build-no\s*: //p' /var/lib/openhab2/etc/version.properties | cut -d '#' -f 2

currentBuildString contains “Release Build” and thus it cannot be parsed into Integer.
You need to make sure contains any number before you proceed with comparing it with lastBuildNumber:

if (currentBuildString.matches(".*\\d+.*") && Integer.parseInt(currentBuildString) < Integer.parseInt(lastBuildNumber)) {
   ...
}

Didn’t test it!

But what has changed since the last few weeks? I was on a snapshot maybe 2 weegs ago and all worked, today i made an update and now it doen´t work anymore…

This is the version.properties-file:

openHAB Distribution Version Information
----------------------------------------
build-no        : Release Build
online-repo     : https://dl.bintray.com/openhab/mvn/online-repo/2.3

Repository        Version
----------------------------------------
openhab-distro  : 2.3.0
smarthome       : 0.10.0.oh230
openhab-core    : 2.3.0
openhab1-addons : 1.12.0
openhab2-addons : 2.3.0
karaf           : 4.1.5

So when the release 2.3 is out and the new 2.4 snapshots are running, it will probably work again without any changes?

In the last couple of weeks there was some release candidates for 2.3 being published and that maybe what “broke” it. My guess is that it should get back to normal after the first 2.4 snapshot is released

Which has already happened :wink:

1 Like

But it´s not online yet… :blush:

https://openhab.ci.cloudbees.com/job/openHAB-Distribution/api/json?

Yes it is, I just have updated to openHAB 2.4.0 Build #1292

Ok, i can see it now. I made a snapshot update about 2 hours ago and in this version i couldn´t see, which build it was. I only could se release build…

Now i made another apt-get update / upgrade and there is a new update again… Now i can see #1292 in paper UI and in the versions-file too.

I am just building up the snapshot rules new and have some questions. From the properties file i could get the installed buzild and the distro. From cloudbees i get the latest build (json). Now my question: Is it possible to get the distro online?

Thanks

Has someone recognized that the build number from cloudbees has not changed since #1392?

So the rules are more or lesse useless.

Thomas

The location has changed. It now is at https://ci.openhab.org/.

1 Like

I will check that - Now it is working again.

Thanks

My rule worked fine the last couple of months. Since a few days I receive the following error:

2019-02-10 21:30:31.653 [ERROR] [ntime.internal.engine.RuleEngineImpl] 
- Error during the execution of startup rule 'Check for openHAB distro updates': For input string: "
{"_class":"hudson.maven.MavenModuleSet","lastSuccessfulBuild":
{"_class":"hudson.maven.MavenModuleSetBuild","number":1519}}"

Anybody an idea?

I’ve just updated the post with the proper REST API endpoint:

https://ci.openhab.org/job/openHAB-Distribution/api/json?tree=lastSuccessfulBuild[number]

1 Like

I guess the brackets should be replaced by %5B and %5D in the URL

1 Like

My fault was: I had to reinstall all bindings because of the snapshot bug in #1518 and forgot to re-install the JSONPath Transformation. I am very sorry - thanks @kubawolanin for your kind help.