At one point with this logic I was able to get a notification, but when I tried to also change the mode, I messed something up. Now this doesn’t seem to work, but I imagine it’s something very small because it does compile properly. You can use this as a guide, but it doesn’t appear to do anything in its current form, and I’ve had it…
definition(
name: “Notify Me When Cleaners Open Door”,
namespace: “”,
author: “CCooney”,
description: “Notifies when a specific user code is used on door.”,
category: “Safety & Security”,
iconUrl: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png”,
iconX2Url: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png”)
preferences
{
section(“When a door unlocks…”) {
input “lock1”, “capability.lock”
}
section(“And this user opened the door:”){
input “User1”, “enum”, title: “User Code”, metadata:[values:[“1”,“2”,“3”,“4”,“5”]]
}
section(“Send this message (optional, sends standard status message if not specified)”){
input “messageText”, “text”, title: “Message Text”, required: false
}
section( “Notifications” ) {
input “sendPushMessage”, “enum”, title: “Send a push notification?”, metadata:[values:[“Yes”,“No”]], required:false
input “phone”, “phone”, title: “Send a Text Message?”, required: false
}
section(“And change to this mode”) {
input “newMode”, “mode”, title: “Mode?”, required: false
}
}
def installed() {
log.debug "Installed with settings: ${settings}"
subscribeToEvents()
}
def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
subscribeToEvents()
}
def subscribeToEvents() {
log.debug "Settings: ${settings}"
subscribe(lock1, "lock", eventHandler)
}
def eventHandler(evt) {
if (evt.value == “unlocked”) {
if (evt.data == ‘{“usedCode”:’+User1+’}’)
{ send(evt) }
}}
private send(evt) {
if ( sendPushMessage != “No” ) {
log.debug( “sending push message” )
sendPush( msg )
}
if ( phone ) {
log.debug( "sending text message" )
sendSms( phone, msg )
}
log.debug msg
}