Happy Thanksgiving.
I have been tinkering with the ‘Turn it On for 5 minutes app’ to enable a series of hue lights to come on at low dimmer level for 5 minutes when my wemo motion sensor is triggered.
I have all that working but here is the wrinkle. I only want the trigger to occur between 4:30 and 7:00 am.
Here is where I am thus far, but I don’t know how to write the statement to check the time and only activate the trigger where the time within the parameters.
Anyone able to lend a hand… and more importantly explain it?
/**
* Turn It On For 5 Minutes
* Turn on a switch when a contact sensor opens and then turn it back off 5 minutes later.
*
* Author: SmartThings
*/
definition(
name: "Turn It On For 5 Minutes",
namespace: "smartthings",
author: "SmartThings",
description: "When my closet motion sensor is triggered in between 4:30 and 5:45am, turn on the kitchen accent lights (on low) for 10 minutes.",
category: "Safety & Security",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_contact-outlet.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_contact-outlet@2x.png"
)
preferences {
section("When it opens..."){
input "Motion", "capability.motionSensor"
}
section("Turn dimmers on low for 5 minutes..."){
input "dimmers", "capability.switchLevel", multiple: true, title: "Which Lights?", required: true
input "level", "number", title: "How bright?, 0-99", required: true
}
section("Before this time of day"){
input "timeOfDay1", "beforetime", title: "Time?"
}
section("After this time of day"){
input "timeOfDay2", "aftertime", title: "Time?"
}
}
def installed() {
log.debug "Installed with settings: ${settings}"
subscribe(Motion, "motion.active", motionActiveHandler)
}
def updated(settings) {
log.debug "Updated with settings: ${settings}"
unsubscribe()
subscribe(Motion, "motion.inactive", motionInactiveHandler)
}
def motionActiveHandler(evt) {
dimmers.setLevel(level)
def tenMinuteDelay = 60 * 10
runIn(tenMinuteDelay, turnOffSwitch)
}
def turnOffSwitch() {
dimmers.off()
}