Update gentle-wake-up.groovy
[smartapps.git] / official / turn-on-at-sunset.groovy
1 /**
2  *  Turn on at Sunset
3  *
4  *  Copyright 2015 SmartThings
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: "Turn on at Sunset",
18     namespace: "examples",
19     author: "SmartThings",
20     description: "Turn on lights at sunset, based on your location's geofence.",
21     category: "My Apps",
22     iconUrl: "https://s3.amazonaws.com/smartapp-icons/ModeMagic/rise-and-shine.png",
23     iconX2Url: "https://s3.amazonaws.com/smartapp-icons/ModeMagic/rise-and-shine@2x.png",
24     iconX3Url: "https://s3.amazonaws.com/smartapp-icons/ModeMagic/rise-and-shine@2x.png")
25
26 preferences {
27     section("Lights") {
28         input "switches", "capability.switch", title: "Which lights to turn on?"
29     }
30 }
31
32 def installed() {
33     initialize()
34 }
35
36 def updated() {
37     unsubscribe()
38     initialize()
39 }
40
41 def initialize() {
42     subscribe(location, "sunset", sunsetHandler)
43 }
44
45 def sunsetHandler(evt) {
46     log.debug "turning on lights at sunset"
47     switches.on()
48 }