}
def initialize() {
+ // Adjustment for saved state
+ frequency = frequency + 1
def MAX_CONTACT=30
state?.lastThermostatMode = null
// subscribe to all contact sensors to check for open/close events
clearStatus(indice)
} else if ((evt.value == "open") && (state?.status[indice] != "scheduled")) {
def takeActionMethod= "takeAction${indice}"
- runIn(freq, "${takeActionMethod}",[overwrite: false])
state?.status[indice] = "scheduled"
+ runIn(freq, "${takeActionMethod}",[overwrite: false])
log.debug "${theSensor[indice]} is now open and will be checked every ${delay} minute(s) by ${takeActionMethod}"
}
}
def maxNotif = (givenMaxNotif) ?: 5
def max_open_time_in_min = maxOpenTime ?: 5 // By default, 5 min. is the max open time
def msg
+ def open = "open"
+ def closed = "closed"
def contactState = theSensor[indice].currentState("contact")
log.trace "takeAction>${theSensor[indice]}'s contact status = ${contactState.value}, state.status=${state.status[indice]}, indice=$indice"
- if ((state?.status[indice] == "scheduled") && (contactState.value == "open")) {
+ //if ((state?.status[indice] == "scheduled") && (contactState.value == "open")) {
+ if ((state?.status[indice] == "scheduled") && (contactState == open)) {
state.count[indice] = state.count[indice] + 1
log.debug "${theSensor[indice]} was open too long, sending message (count=${state.count[indice]})"
def openMinutesCount = state.count[indice] * delay
takeActionMethod= "takeAction${indice}"
msg = "contact still open at ${theSensor[indice]}, about to reschedule $takeActionMethod"
log.debug msg
- runIn(freq, "${takeActionMethod}", [overwrite: false])
- } else if (contactState.value == "closed") {
+ //runIn(freq, "${takeActionMethod}", [overwrite: false])
+ //} else if (contactState.value == "closed") {
+ } else if (contactState == closed) {
restore_tstats_mode()
clearStatus(indice)
takeActionMethod= "takeAction${indice}"
return
}
tstats.each {
- it.poll() // to get the latest value at thermostat
+ //it.poll() // to get the latest value at thermostat
state.lastThermostatMode = state.lastThermostatMode + "${it.currentThermostatMode}" + ","
}
log.debug "save_tstats_mode>state.lastThermostatMode= $state.lastThermostatMode"