Skip to content

Commit

Permalink
v1.5.0 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
csteele-PD authored Dec 4, 2023
1 parent d2e5293 commit 405e918
Showing 1 changed file with 8 additions and 68 deletions.
76 changes: 8 additions & 68 deletions BetterLaundryMonitor_Parent.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
*
*
* csteele: v1.5.0 Add Contact sensor child
* Remove UpdateCheck, rely on HPM to check for a new version.
*
*/
public static String version() { return "v1.4.4" }

public static String version() { return "v1.5.0" }


definition(
Expand Down Expand Up @@ -66,7 +72,6 @@ def updated() {
log.debug "Updated with settings: ${settings}"
unschedule()
unsubscribe()
// schedule("0 0 14 ? * FRI *", updateCheck) It's run every time it's displayed
if (debugOutput) runIn(1800,logsOff)
initialize()
}
Expand All @@ -88,75 +93,10 @@ def logsOff() {


def display() {
updateCheck()
section{
paragraph "\n<hr style='background-color:#1A77C9; height: 1px; border: 0;'></hr>"
paragraph "<div style='color:#1A77C9;text-align:center;font-weight:small;font-size:9px'>Developed by: Kevin Tierney, ChrisUthe, C Steele<br/>Version Status: $state.Status<br>Current Version: ${version()} - ${thisCopyright}</div>"
}
}


// Check Version ***** with great thanks and acknowledgment to Cobra (CobraVmax) for his original code ****
def updateCheck()
{
def paramsUD = [uri: "https://hubitatcommunity.github.io/Hubitat-BetterLaundryMonitor/version2.json"]

asynchttpGet("updateCheckHandler", paramsUD)
}


def updateCheckHandler(resp, data) {

state.InternalName = "BLMparent"

if (resp.getStatus() == 200 || resp.getStatus() == 207) {
respUD = parseJson(resp.data)
//log.warn " Version Checking - Response Data: $respUD" // Troubleshooting Debug Code - Uncommenting this line should show the JSON response from your webserver
state.Copyright = "${thisCopyright} -- ${version()}"
// uses reformattted 'version2.json'
def newVer = padVer(respUD.application.(state.InternalName).ver)
def currentVer = padVer(version())
state.UpdateInfo = (respUD.application.(state.InternalName).updated)
// log.debug "updateCheck: ${respUD.driver.(state.InternalName).ver}, $state.UpdateInfo, ${respUD.author}"

switch(newVer) {
case { it == "NLS"}:
state.Status = "<b>** This Application is no longer supported by ${respUD.author} **</b>"
log.warn "** This Application is no longer supported by ${respUD.author} **"
break
case { it > currentVer}:
state.Status = "<b>New Version Available (Version: ${respUD.application.(state.InternalName).ver})</b>"
log.warn "** There is a newer version of this Application available (Version: ${respUD.application.(state.InternalName).ver}) **"
log.warn "** $state.UpdateInfo **"
break
case { it < currentVer}:
state.Status = "<b>You are using a Test version of this Application (Expecting: ${respUD.application.(state.InternalName).ver})</b>"
break
default:
state.Status = "Current"
if (descTextEnable) log.info "You are using the current version of this Application"
break
}

sendEvent(name: "chkUpdate", value: state.UpdateInfo)
sendEvent(name: "chkStatus", value: state.Status)
}
else
{
log.error "Something went wrong: CHECK THE JSON FILE AND IT'S URI"
}
}

/*
padVer
Version progression of 1.4.9 to 1.4.10 would mis-compare unless each column is padded into two-digits first.
*/
def padVer(ver) {
def pad = ""
ver.replaceAll( "[vV]", "" ).split( /\./ ).each { pad += it.padLeft( 2, '0' ) }
return pad
}

def getThisCopyright(){"&copy; 2019 C Steele "}
def getThisCopyright(){"&copy; 2019 C Steele "}

0 comments on commit 405e918

Please sign in to comment.