Problem turning off Hue Lights in Scheduled Procedure - possible bug?


(John Magrane) #1

Hi,
I’m developing an app that, among other things, will turn on some Hue lights when motion is detected and then turn them off when there is no longer any motion. To prevent the lights going on and off a lot, the off() command executes in a function called by a runIn command. That is where the problem is occurring. When the off() command is executed in the function called by the runIn, an error is generated by the simulator. If I execute the command in the event procedure all works OK. The code below has everything stripped out to isolate the issue. If you run this with the off() command active in the motionInactiveHandler, lights go on and off fine. If it is run with the command active in turnOffLights function, the following error is generated

error Unknown name value for enum class physicalgraph.device.DataType: COLOR_MAP

Also note if you run the simulator with virtual devices for the lights it works fine, I’m only seeing this when using physical bulbs. Can anyone confirm they see the same or point out a flaw?

/**
*/
preferences {
section(“When there’s movement…”) {
input “motionSensor”, “capability.motionSensor”, title: “Where?”, multiple: true
}
section (“Control these lights…”) {
input “hueLights”, “capability.switch”, multiple: true
}
}

def installed() {
subscribe(hueLights, “switch”, manualSwitchHandler)
subscribe(motionSensor, “motion.active”, motionActiveHandler)
subscribe(motionSensor, “motion.inactive”, motionInactiveHandler)
}

def updated() {
unsubscribe()
subscribe(motionSensor, “motion.active”, motionActiveHandler)
subscribe(motionSensor, “motion.inactive”, motionInactiveHandler)
}

def motionActiveHandler(evt) {
hueLights.on()
}

def motionInactiveHandler(evt) {
// hueLights.off()
runIn (5, turnOffLights)
}
def turnOffLights() {
hueLights.off()
}

Thanks,
John