mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-08 05:31:56 +00:00
Modifying 'Reminders using notifications and light'
This commit is contained in:
@@ -70,6 +70,9 @@ def initialize() {
|
||||
// how many minutes to look in the past from the reminder time, for an open draw
|
||||
state.minutesToCheckOpenDraw = 60
|
||||
|
||||
// is true when LED notification is set after exceeding 10 minutes past reminder time
|
||||
state.ledNotificationTriggered = false
|
||||
|
||||
// Set a timer to run once a day to notify if draw wasn't opened yet
|
||||
schedule(reminderTime, checkOpenDrawInPast)
|
||||
|
||||
@@ -78,11 +81,13 @@ def initialize() {
|
||||
// Should turn off any LED notification on OPEN state
|
||||
def contactHandler(evt){
|
||||
if (evt.value == "open") {
|
||||
// always call out to stop any possible LED notification
|
||||
log.debug "Cabinet opened. Sending reset to LED"
|
||||
// if LED notification triggered, reset it.
|
||||
log.debug "Cabinet opened"
|
||||
if (state.ledNotificationTriggered) {
|
||||
resetLEDNotification()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the draw was NOT opened within 60 minutes of the timer send notification out.
|
||||
def checkOpenDrawInPast(){
|
||||
@@ -150,6 +155,8 @@ def isOpened(minutes){
|
||||
// Saves current color and sets the light to RED
|
||||
def setLEDNotification(){
|
||||
|
||||
state.ledNotificationTriggered = true
|
||||
|
||||
// turn light back off when reset is called if it was originally off
|
||||
state.ledState = deviceLight.currentValue("switch")
|
||||
|
||||
@@ -165,9 +172,13 @@ def setLEDNotification(){
|
||||
// Sets the color back to the original saved color
|
||||
def resetLEDNotification(){
|
||||
|
||||
state.ledNotificationTriggered = false
|
||||
|
||||
// return color to original
|
||||
log.debug "Reset LED color to: $state.origColor"
|
||||
if (state.origColor != null) {
|
||||
deviceLight.setHue(state.origColor)
|
||||
}
|
||||
|
||||
// if the light was turned on just for the notification, turn it back off now
|
||||
if (state.ledState == "off") {
|
||||
|
||||
Reference in New Issue
Block a user