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 * Cameras On When I'm Away
15 * Author: danny@smartthings.com
20 name: "Cameras On When I'm Away",
21 namespace: "smartthings",
22 author: "SmartThings",
23 description: "Turn cameras on when I'm away",
24 category: "Available Beta Apps",
25 iconUrl: "https://s3.amazonaws.com/smartapp-icons/Partner/dropcam-on-off-presence.png",
26 iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Partner/dropcam-on-off-presence@2x.png"
30 section("When all of these people are home...") {
31 input "people", "capability.presenceSensor", multiple: true
33 section("Turn off camera power..."){
34 input "switches1", "capability.switch", multiple: true
39 log.debug "Installed with settings: ${settings}"
40 log.debug "Current people = ${people.collect{it.label + ': ' + it.currentPresence}}"
41 subscribe(people, "presence", presence)
45 log.debug "Updated with settings: ${settings}"
46 log.debug "Current people = ${people.collect{it.label + ': ' + it.currentPresence}}"
48 subscribe(people, "presence", presence)
53 log.debug "evt.name: $evt.value"
54 if (evt.value == "not present") {
56 log.debug "checking if everyone is away"
57 if (everyoneIsAway()) {
58 log.debug "starting on Sequence"
60 runIn(60*2, "turnOn") //two minute delay after everyone has left
64 if (!everyoneIsAway()) {
72 log.debug "canceling On requests"
75 log.info "turning off the camera"
82 log.info "turned on the camera"
85 unschedule("turnOn") // Temporary work-around to scheduling bug
88 private everyoneIsAway()
91 for (person in people) {
92 if (person.currentPresence == "present") {
97 log.debug "everyoneIsAway: $result"