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.
21 name: "Photo Burst When...",
22 namespace: "smartthings",
23 author: "SmartThings",
24 description: "Take a burst of photos and send a push notification when...",
25 category: "SmartThings Labs",
26 iconUrl: "https://s3.amazonaws.com/smartapp-icons/Partner/photo-burst-when.png",
27 iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Partner/photo-burst-when@2x.png"
31 section("Choose one or more, when..."){
32 input "motion", "capability.motionSensor", title: "Motion Here", required: false, multiple: true
33 input "contact", "capability.contactSensor", title: "Contact Opens", required: false, multiple: true
34 input "acceleration", "capability.accelerationSensor", title: "Acceleration Detected", required: false, multiple: true
35 input "mySwitch", "capability.switch", title: "Switch Turned On", required: false, multiple: true
36 input "arrivalPresence", "capability.presenceSensor", title: "Arrival Of", required: false, multiple: true
37 input "departurePresence", "capability.presenceSensor", title: "Departure Of", required: false, multiple: true
39 section("Take a burst of pictures") {
40 input "camera", "capability.imageCapture"
41 input "burstCount", "number", title: "How many? (default 5)", defaultValue:5
43 section("Then send this message in a push notification"){
44 input "messageText", "text", title: "Message Text"
46 section("And as text message to this number (optional)"){
47 input("recipients", "contact", title: "Send notifications to") {
48 input "phone", "phone", title: "Phone Number", required: false
55 log.debug "Installed with settings: ${settings}"
60 log.debug "Updated with settings: ${settings}"
65 def subscribeToEvents() {
66 subscribe(contact, "contact.open", sendMessage)
67 subscribe(acceleration, "acceleration.active", sendMessage)
68 subscribe(motion, "motion.active", sendMessage)
69 subscribe(mySwitch, "switch.on", sendMessage)
70 subscribe(arrivalPresence, "presence.present", sendMessage)
71 subscribe(departurePresence, "presence.not present", sendMessage)
74 def sendMessage(evt) {
75 log.debug "$evt.name: $evt.value, $messageText"
78 (1..((burstCount ?: 5) - 1)).each {
79 camera.take(delay: (500 * it))
82 if (location.contactBookEnabled) {
83 sendNotificationToContacts(messageText, recipients)
88 sendSms(phone, messageText)