Skip to content

Commit

Permalink
Update BathroomHumidityChild.src
Browse files Browse the repository at this point in the history
  • Loading branch information
heidrickla authored Jul 9, 2021
1 parent f2a3d18 commit 8c30367
Showing 1 changed file with 32 additions and 38 deletions.
70 changes: 32 additions & 38 deletions Apps/BathroomHumidityFan/BathroomHumidityChild.src
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import groovy.transform.Field
import hubitat.helper.RMUtils

def setVersion() {
state.version = "1.1.40" // Version number of this app
state.version = "1.1.41" // Version number of this app
state.InternalName = "BathroomHumidityFan" // this is the name used in the JSON file for this app
}

Expand Down Expand Up @@ -43,7 +43,6 @@ preferences {
def mainPage() {
dynamicPage(name: "", title: "", install: true, uninstall: true, refreshInterval:0) {
ifTrace("mainPage")
turnOffLoggingTogglesIn30()
setPauseButtonName()
setCreateSmartSwitchButtonName()

Expand Down Expand Up @@ -117,11 +116,11 @@ def mainPage() {
}
section(title: "Logging Options:", hideable: true, hidden: hideLoggingSection()) {
if (detailedInstructions == true) {paragraph "Enable Info logging for 30 minutes will enable info logs to show up in the Hubitat logs for 30 minutes after which it will turn them off. Useful for checking if the app is performing actions as expected."}
input "isInfo", "bool", title: "Enable Info logging for 30 minutes", submitOnChange: false, required:false, defaultValue: false
input name: "isInfo", type: "bool", title: "Enable Info logging for 30 minutes?", defaultValue: true
if (detailedInstructions == true) {paragraph "Enable Debug logging for 30 minutes will enable debug logs to show up in the Hubitat logs for 30 minutes after which it will turn them off. Useful for troubleshooting problems."}
input "isDebug", "bool", title: "Enable debug logging for 30 minutes", submitOnChange: false, required:false, defaultValue: false
input name: "isDebug", type: "bool", title: "Enable debug logging for 30 minutes?", defaultValue: true
if (detailedInstructions == true) {paragraph "Enable Trace logging for 30 minutes will enable trace logs to show up in the Hubitat logs for 30 minutes after which it will turn them off. Useful for following the logic inside the application but usually not neccesary."}
input "isTrace", "bool", title: "Enable Trace logging for 30 minutes", submitOnChange: false, required:false, defaultValue: false
input name: "isTrace", type: "bool", title: "Enable Trace logging for 30 minutes?", defaultValue: true
if (detailedInstructions == true) {paragraph "Logging level is used to permanantly set your logging level for the application. This is useful if you prefer you logging set to a low level and then can use the logging toggles for specific use cases so you dont have to remember to go back in and change them later. It's also useful if you are experiencing issues and need higher logging enabled for longer than 30 minutes."}
input "ifLevel","enum", title: "Logging level", required: false, multiple: true, submitOnChange: false, options: logLevelOptions
paragraph "NOTE: Logging level overrides the temporary logging selections."
Expand Down Expand Up @@ -172,6 +171,9 @@ def updated() {
if (state?.createSmartSwitch == null) {(state.createSmartSwitch = false)}
unsubscribe()
unschedule()
if (ifInfo) runIn(1800,infoOff)
if (ifDebug) runIn(1800,debugOff)
if (ifTrace) runIn(1800,traceOff)
initialize()
if (fanSwitch?.currentValue("switch") != null) {state.fanSwitchStatus = "[Fan: ${fanSwitch.currentValue("switch")}]"
} else if (fanSwitch?.latestValue("switch") != null) {state.fanSwitchStatus = "[Fan: ${fanSwitch.latestValue("switch")}]"
Expand Down Expand Up @@ -225,6 +227,28 @@ def modeChangeHandler() {
}
}

def disableInfoIn30Handler(evt) {
if (isInfo == true) {
runIn(1800, infoOff)
log.info "Info logging disabling in 30 minutes."
}
}

def disableDebugIn30Handler(evt) {
if (isDebug == true) {
runIn(1800, debugOff)
log.debug "Debug logging disabling in 30 minutes."
}
}

def disableTraceIn30Handler(evt) {
if (isTrace == true) {
if (isTrace == true) {runIn(1800, traceOff)}
log.trace "Trace logging disabling in 30 minutes."
}
}


// Main Humidity Handler
def humidityHandler(evt) {
// Device status
Expand Down Expand Up @@ -1107,49 +1131,19 @@ private timeIntervalLabel() {
}

// Logging functions
def turnOffLoggingTogglesIn30() {
if (!isInfo) {app.updateSetting("isInfo",[value:"false",type:"bool"])}
if (!isDebug) {app.updateSetting("isDebug",[value:"false",type:"bool"])}
if (!isTrace) {app.updateSetting("isTrace",[value:"false",type:"bool"])}
if (isInfo == true) {runIn(1800, infoOff)}
if (isDebug == true) {runIn(1800, debugOff)}
if (isTrace == true) {runIn(1800, traceOff)}
}

def infoOff() {
log.info "${state.thisName}: Info logging disabled."
app.updateSetting("isInfo",[value:"false",type:"bool"])
if (isInfo == false) {log.warn "${state.thisName}: Info logging disabled."}
}

def debugOff() {
log.info "${state.thisName}: Debug logging disabled."
app.updateSetting("isDebug",[value:"false",type:"bool"])
if (isDebug == false) {log.warn "${state.thisName}: Debug logging disabled."}
}

def traceOff() {
log.trace "${state.thisName}: Trace logging disabled."
app.updateSetting("isTrace",[value:"false",type:"bool"])
}

def disableInfoIn30() {
if (isInfo == true) {
runIn(1800, infoOff)
log.info "Info logging disabling in 30 minutes."
}
}

def disableDebugIn30() {
if (isDebug == true) {
runIn(1800, debugOff)
log.debug "Debug logging disabling in 30 minutes."
}
}

def disableTraceIn30() {
if (isTrace == true) {
runIn(1800, traceOff)
log.trace "Trace logging disabling in 30 minutes."
}
if (isTrace == false) {log.warn "${state.thisName}: Trace logging disabled."}
}

def ifWarn(msg) {log.warn "${state.thisName}: ${msg}"}
Expand Down

0 comments on commit 8c30367

Please sign in to comment.