2 * Copyright 2015 SmartThings
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 * in compliance with the License. You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
10 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
11 * for the specific language governing permissions and limitations under the License.
13 * Scheduled Mode Change - Presence Optional
21 name: "Scheduled Mode Change",
22 namespace: "smartthings",
23 author: "SmartThings",
24 description: "Changes mode at a specific time of day.",
25 category: "Mode Magic",
26 iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/App-LightUpMyWorld.png",
27 iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/App-LightUpMyWorld@2x.png"
31 section("At this time every day") {
32 input "time", "time", title: "Time of Day"
34 section("Change to this mode") {
35 input "newMode", "mode", title: "Mode?"
37 section( "Notifications" ) {
38 input("recipients", "contact", title: "Send notifications to") {
39 input "sendPushMessage", "enum", title: "Send a push notification?", options: ["Yes", "No"], required: false
40 input "phoneNumber", "phone", title: "Send a text message?", required: false
55 schedule(time, changeMode)
59 log.debug "changeMode, location.mode = $location.mode, newMode = $newMode, location.modes = $location.modes"
60 if (location.mode != newMode) {
61 if (location.modes?.find{it.name == newMode}) {
62 setLocationMode(newMode)
63 send "${label} has changed the mode to '${newMode}'"
66 send "${label} tried to change to undefined mode '${newMode}'"
73 if (location.contactBookEnabled) {
74 log.debug("sending notifications to: ${recipients?.size()}")
75 sendNotificationToContacts(msg, recipients)
78 if (sendPushMessage == "Yes") {
79 log.debug("sending push message")
84 log.debug("sending text message")
85 sendSms(phoneNumber, msg)
93 app.label ?: "SmartThings"