Update sonos-music-modes.groovy
[smartapps.git] / third-party / AlarmThing-Alert.groovy
1 /**
2  *  SmartAlarmAlert
3  *
4  *  Copyright 2014 ObyCode
5  *
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:
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
14  *
15  */
16 definition(
17     name: "SmartAlarmAlert",
18     namespace: "com.obycode",
19     author: "ObyCode",
20     description: "Alert me when my alarm status changes (armed, alarming, disarmed).",
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"
24 )
25
26 preferences {
27     section("Alert me when this alarm changes state (arming, armed, disarmed, alarm):") {
28         input "theAlarm", "capability.alarm", multiple: false, required: true
29     }
30 }
31
32 def installed() {
33     log.debug "Installed with settings: ${settings}"
34
35     initialize()
36 }
37
38 def updated() {
39     log.debug "Updated with settings: ${settings}"
40
41     unsubscribe()
42     initialize()
43 }
44
45 def initialize() {
46     log.debug "in initialize"
47     subscribe(theAlarm, "alarmStatus", statusChanged)
48 }
49
50 def statusChanged(evt) {
51     if (evt.value == "away") {
52         sendPush("Alarm armed to 'away'")
53     } else if (evt.value == "stay") {
54         sendPush("Alarm armed to 'stay'")
55     } else if (evt.value == "arming") {
56         sendPush("Alarm is arming")
57     } else if (evt.value == "alarm") {
58         sendPush("ALARM IS GOING OFF!")
59     } else if (evt.value == "disarmed") {
60         sendPush("Alarm is disarmed")
61     }
62 }