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.
18 name: "Light Up the Night",
19 namespace: "smartthings",
20 author: "SmartThings",
21 description: "Turn your lights on when it gets dark and off when it becomes light again.",
22 category: "Convenience",
23 iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet-luminance.png",
24 iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet-luminance@2x.png"
28 section("Monitor the luminosity...") {
29 input "lightSensor", "capability.illuminanceMeasurement"
31 section("Turn on a light...") {
32 input "lights", "capability.switch", multiple: true
37 subscribe(lightSensor, "illuminance", illuminanceHandler)
42 subscribe(lightSensor, "illuminance", illuminanceHandler)
45 // New aeon implementation
46 def illuminanceHandler(evt) {
47 def lastStatus = state.lastStatus
48 if (lastStatus != "on" && evt.integerValue < 30) {
50 state.lastStatus = "on"
52 else if (lastStatus != "off" && evt.integerValue > 50) {
54 state.lastStatus = "off"