Yes, you can use this function:
def getThisVersion() {
return "1.2.4"
}
def getLatestVersion() {
try {
httpGet([uri: "https://raw.githubusercontent.com/ryancasler/cast-web-api-Hubitat/master/Drivers/version.json"]) { resp ->
logger('debug', "response status: ${resp.status}")
String data = "${resp.getData()}"
logger('debug', "data: ${data}")
if(resp.status==200 && data!=null) {
def msg = parseJson(data)
def latestVersion = msg.version
return latestVersion
} else {
return null
}
}
} catch (e) {
logger('error', "something went wrong: $e")
return null
}
}
def checkForUpdate() {
def latestVersion = getLatestVersion()
def thisVersion = getThisVersion()
latestVersion = latestVersion.replace(".","")
thisVersion = thisVersion.replace(".","")
if (latestVersion == null) {
logger('error', "Couldn't check for new version, thisVersion: " + getThisVersion())
sendEvent(name: "updateStatus", value:"ERROR", displayed: true)
return null
} else {
logger('info', "checkForUpdate This Version: $thisVersion , Latest Version: $latestVersion")
if (thisVersion.equals(latestVersion)){
sendEvent(name:"updateStatus", value: "NOT REQUIRED", displayed: true)
}
else if (thisVersion > latestVersion){
sendEvent(name:"updateStatus", value: "BETA", displayed: true)
}
else if (thisVersion < latestVersion){
sendEvent(name:"updateStatus", value: "REQUIRED", displayed: true)
}
}
}
I made it a little simple for myself, it outputs to an attribute as REQUIRED, NOT REQUIRED or BETA. You just have to create a file in the github repo that contains the version number so you can pull it.