Ok. So I have changed tactics and much thanks to you all for helping. The humidity sensor just would not kick in quick enough to make a meaningful change so I made the trigger an open/closed sensor mounted on the shower door.
I wrote this app (probably not that well) to turn off lights/on lights when the door is closed and reverse the process when the door is open. Two things, I cannot figure out:
-
How can I make it so that app does not trigger on a false alarm. For example, if I open and close the shower door within 5 seconds of each other I may not want the recipe to fire twice rapidly for open then close. (ie. maybe I am hanging a towel)
-
As I have a motion sensor in my bathroom, I tried to disable the motion sensor when the app is triggered. Take a look at the code and tell me what I am doing wrong.
/**
preferences {
section (“When the door closes…”) {
input “contact1”, “capability.contactSensor”, title: “Where?”
}
section (“Turn on the shower light…”) {
input “switch1”, “capability.switch”, title: “Shower Light”
}
section (“And turn off the bathroom light…”){
input “switch2”, “capability.switch”, title: “Bathroom Dimmer”
}
section (“Disable the bathroom motion sensor…”){
input “motion1”, “capability.motionSensor”, title: “Which Motion Sensor”
}
}
def installed()
{
log.debug "Intalled with settings ${settings}"
subscribe(contact1, “contact.closed”, contactClosedHandler)
subscribe(contact1, “contact.open”, contactOpenHandler)
subscribe(motion1, “motion”, motionHandler)
state.enabled = true
state.runoff = true
}
def updated()
{
log.debug "Updated with settings ${settings}"
unsubscribe()
subscribe(contact1, “contact.closed”, contactClosedHandler)
subscribe(contact1, “contact.open”, contactOpenHandler)
}
def motionHandler(evt) {
log.debug "Motion Handler - Evt value: ${evt.value}"
if (evt.value == “active”) {
if (state.enabled) {
log.debug(“Turning on lights”)
switch2?.on()
} else {
log.debug (“Motion disabled - not turning on lights”)
}
}
}
def contactClosedHandler(evt) {
log.debug "Closed Handler - Evt Value: ${evt.value}"
if (evt.value == “closed”) {
log.trace "I have turned on the shower light and turned off the bathroom light for the next 30 minutes"
state.enabled = false
switch1.on()
switch2.off()
def thirtyMinuteDelay = 60 *30
runIn(thirtyMinuteDelay, turnOffSwitch)
}
}
def turnOffSwitch() {
switch1.off()
switch2.on()
}
def contactOpenHandler(evt) {
switch1.off()
switch2.on()
def thirtyOneMinuteDelay = 60 *31
runIn(thirtyOneMinuteDelay, turnOnSwitch)
log.trace “Your Shower is done, I have turned off the shower light and turned on the bathroom light for the next 31 minutes”
}
def turnOnSwitch() {
switch1.off
switch2.off
}
def enable() {
log.debug "Motion enabled"
state.enabled = true
}
Thank you all again for your help.