Sorry about this guys. I am sure this is very basic. I took the “Light up the night” code and I wanted to change the value of luminance so I set the level. The code I have doesn’t do anything, but I am pretty sure it’s because I am newb.
My ultimate goal is to have motion only turn on a light when luminance is below a certain level and then turn off the light once motion stops.
/**
* Motion in the dark
*
* Copyright 2014 Joe Rosiak
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
*/
definition(
name: "Motion in the dark",
namespace: "Keo",
author: "Joe Rosiak",
description: "Turns the light on when luminance is low. This code should allow you to set the level of light and if it's too low motion will turn on the lamp.",
category: "Convenience",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
oauth: true)
preferences {
section("Monitor the luminosity...") {
input "lightSensor", "capability.illuminanceMeasurement"
input("lightLevel", "number", title: "Set Your Lunination percentage:")
}
section("Turn on a light...") {
input "lights", "capability.switch", multiple: true
}
}
def installed() {
log.debug "Installed with settings: ${settings}"
subscribe(lightSensor, "illuminance", illuminanceHandler)
initialize()
}
def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
subscribe(lightSensor, "illuminance", illuminanceHandler)
initialize()
}
// New aeon implementation
def illuminanceHandler(evt) {
def lastStatus = state.lastStatus
//if (lastStatus != "on" && evt.integerValue < lightLevel) {
if (evt.integerValue < lightLevel) {
lights.on()
state.lastStatus = "on"
}
//else if (lastStatus != "off" && evt.integerValue > lightLevel) {
else if (evt.integerValue > lightLevel) {
lights.off()
state.lastStatus = "off"
}
}
def initialize() {
// TODO: subscribe to attributes, devices, locations, etc.
}
I turn off all of the lights and expected the light module to turn on, but nothing. I don’t even see anything in logging.
Any advice?