Last active
December 21, 2015 08:48
-
-
Save vlaminck/6280411 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Learning Lights | |
* | |
* Author: steve | |
* Date: 2013-08-20 | |
*/ | |
preferences { | |
section("Setup") { | |
input "luminosity", "capability.illuminanceMeasurement", title:"Luminosity Sensor" | |
input "switches", "capability.switch", title:"Switches to turn on", multiple:true | |
} | |
section("Optional") { | |
input "motion", "capability.motionSensor", title:"Motion Detector", required:false | |
} | |
} | |
def installed() { | |
log.debug "Installed with settings: ${settings}" | |
initialize() | |
} | |
def updated() { | |
log.debug "Updated with settings: ${settings}" | |
unsubscribe() | |
initialize() | |
} | |
def initialize() { | |
subscribe(app, appTouch) | |
subscribe(luminosity, "illuminanceMeasurement.illuminance", a) | |
subscribe(luminosity, "illuminanceMeasurement", b) | |
subscribe(luminosity, "illuminance", c) | |
subscribe(motion, "motion.active", motionActiveHandler) | |
} | |
def appTouch(evt) { | |
log.debug "Learn" | |
on() | |
negate() | |
} | |
def motionActiveHandler(evt) { | |
log.debug "motion $evt" | |
on() | |
negate() | |
} | |
def a(evt) { | |
log.debug "a ${evt}" | |
} | |
def b(evt) { | |
log.debug "b ${evt}" | |
} | |
def c(evt) { | |
log.debug "c ${evt}" | |
} | |
def illuminanceHandler(evt) { | |
log.debug "luminosity $evt" | |
on() | |
negate() | |
} | |
private on() { | |
log.debug "on" | |
} | |
private negate() { | |
log.debug "negate" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment