Checking for openHAB updates - simple rule

rules
update
openhabian
Tags: #<Tag:0x00007f212a61ebd8> #<Tag:0x00007f212a61ea20> #<Tag:0x00007f212a61e8e0>

(Kim Skatun) #22

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


(Rich Koshak) #23

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.


(Hartmut Schwensen) #25

The script from #1 from @kubawolanin doesn’t seem to work anymore. Probably because of the milestone build.

2018-05-23 15:23:45.431 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Error during the execution of startup rule 'Check for openHAB distro updates': For input string: "Milestone Build"


(Hartmut Schwensen) #26

Can someone still provide a running version? Thanks for your contribution in advance.


(Vincent Regaud) #27

Have you tried the code on post #15


(Hallo Ween) #28
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

(Hallo Ween) #29

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

(Kuba Wolanin) #30

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!


(Hallo Ween) #31

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?


(Vincent Regaud) #32

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


(Ben Clark) #33

Which has already happened :wink:


(Hallo Ween) #34

But it´s not online yet… :blush:

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


(Vincent Regaud) #35

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


(Hallo Ween) #36

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.


(Thomas Bail) #37

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


(Thomas Bail) #38

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

So the rules are more or lesse useless.

Thomas


(Mark) #39

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


(Thomas Bail) #40

I will check that - Now it is working again.

Thanks