2 * Lock it at a specific time
4 * Copyright 2014 Erik Thayer
6 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
7 * in compliance with the License. You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
12 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
13 * for the specific language governing permissions and limitations under the License.
17 name: "Lock it at a specific time",
18 namespace: "user8798",
19 author: "Erik Thayer",
20 description: "Make sure a door is locked at a specific time. Option to add door contact sensor to only lock if closed.",
21 category: "Safety & Security",
22 iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
23 iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png"
28 section("At this time every day") {
29 input "time", "time", title: "Time of Day"
31 section("Make sure this is locked") {
32 input "lock","capability.lock"
34 section("Make sure it's closed first..."){
35 input "contact", "capability.contactSensor", title: "Which contact sensor?", required: false
37 section( "Notifications" ) {
38 input "sendPushMessage", "enum", title: "Send a push notification?", metadata:[values:["Yes", "No"]], required: false
39 input "phone", "phone", title: "Send a text message?", required: false
43 schedule(time, "setTimeCallback")
47 def updated(settings) {
49 schedule(time, "setTimeCallback")
52 def setTimeCallback() {
61 def currentState = contact.contactState
62 if (currentState?.value == "open") {
63 def msg = "${contact.displayName} is open. Scheduled lock failed."
65 if (sendPushMessage) {
78 def msg = "Locking ${lock.displayName} due to scheduled lock."
80 if (sendPushMessage) {