Does anyone know if this is possible? (setting hue colors with hex)
I had read on the forum that setColor([hex: #00FF00, level: 50]) was possible but I cannot get it to work.
The reason I ask is because I am capturing the state of the hue before I change it and want to reset it back. When you get the current state of color it returns a hex value, but I cannot find a way to send it back to the bulb.
Supposedly the Hue Notification app will reset the state but I can’t get that app to work either.
What am I doing wrong?
I have tried this 100 ways, but this is what I have been working with right now, i simplified it to do some testing and have experimented with many different ways to capture vales…
any help is appreciated, thanks
preferences {
section("Turn on when there's movement..."){
input "motion1", "capability.motionSensor", title: "Where?"
}
section("And off when there's been no movement for..."){
input "minutes1", "number", title: "Minutes?"
}
section("Control these bulbs...") {
input "hues", "capability.colorControl", title: "Which Hue Bulbs?", required:true, multiple:false
}
}
def installed() {
subscribe(motion1, "motion", motionHandler)
}
def updated() {
unsubscribe()
subscribe(motion1, "motion", motionHandler)
}
def motionHandler(evt) {
log.debug "$evt.name: $evt.value"
if (evt.value == "active") {
def huecolor = hues.currentValue("color")
log.debug "current color: ${huecolor}"
def huelevel = hues.currentValue("level")
log.debug "current level: ${huelevel}"
def hueswitch = hues.currentValue("switch")
log.debug "current switch: ${hueswitch}"
def huehue = hues.currentValue("hue")
log.debug "current hue: ${huehue}"
def huesat = hues.currentValue("saturation")
log.debug "current sat: ${huesat}"
log.debug "turning hues red for motion"
// hues.setColor(hex: #5100FF, level: 100) // testing using hex values, wont work
hues.setHue(100)
hues.setLevel(100)
} else if (evt.value == "inactive") {
runIn(minutes1 * 60, scheduleCheck, [overwrite: false])
}
}
def scheduleCheck() {
log.debug "schedule check"
def motionState = motion1.currentState("motion")
if (motionState.value == "inactive") {
def elapsed = now() - motionState.rawDateCreated.time
def threshold = 1000 * 60 * minutes1 - 1000
if (elapsed >= threshold) {
log.debug "Motion has stayed inactive long enough since last check ($elapsed ms): resetting lights"
hues.setColor([hex: $huecolor, level: $huelevel])
} else {
log.debug "Motion has not stayed inactive long enough since last check ($elapsed ms): doing nothing"
}
} else {
log.debug "Motion is active, do nothing and wait for inactive"
}
}