A rule which runs at midnight that checks GitHub for a new release of OH. It updates three Items, one with the current version of OH, one with the latest version and a Switch which will be ON when the current version doesn’t match the latest.
rule "openHAB Update-Check"
when
Time cron "0 0 12 ? * SAT *"
then
var httpGet = sendHttpGetRequest("http://localhost:8080/rest/")
var currVersion = transform("JSONPATH", "runtimeInfo.version", httpGet)
httpGet = sendHttpGetRequest("https://api.github.com/repos/openhab/openhab-distro/releases/latest")
var OH_Version_Latest = transform("JSONPATH", "tag_name", httpGet)
if (OH_Version_Latest.contains("M"))
return;
val OH_installed = currVersion.toString.split("\\.")
val OH_latest = OH_Version_Latest.toString.split("\\.")
var x = 0
var y = 0
var boolean update_available = false
var i = 0
while (i < 3) {
x = Integer::parseInt(OH_installed.get(i))
y = Integer::parseInt(OH_latest.get(i))
if (y > x)
update_available = true
i += 1
}
if (update_available)
sendNotification("me@mail.com", "Update for openHAB available. Installed: "+ OH_Version.state.toString + ". Available: " + OH_Version_Latest)
end
Because this thread is basically the source for documentation and support for the rule template, it’s generally against the rules to post competing implementations and/or off topic content.
Unlike a regular post, posts in the marketplace have a very specific purpose. These threads are how one makes a rule template available to be installed through MainUI → Add-on store. It’s not a generic thread about testing for upgrades.
I won’t move this reply now, but if this thread starts to get populated with requests to support this Rules DSL version, I’ll have to move them to their own thread. Marketplace threads must remain laser focused and on topic to have any hope of being usable for their intended purpose.