Set the Color on Hue


(Billmans) #1

Hello,

I have enabled the Labs for my Smartthings and connected to my Hue lights. They are working great from the smartthings app and I would like to integrate some basic features into my own apps such as changing the color on the bulbs.

Any ideas how to do this? I have tried commands such as

settings.MultilevelSwitch?.setColor
settings.MultilevelSwitch?.setHue
settings.MultilevelSwitch?.setSaturation

But nothing seems to work, the emulator just keeps telling me that

Command ‘setHueLevel’ is not supported. Supported commands: [setLevel]

Thanks
B


(Eran) #2

Did you add the bulbs as Hue Bulbs? They have their own device type. Commands I’ve seen so far: setLevel(), setHue(), poll(), on(), off()


(Chrisb) #3

Looking at the code of the device type, it looks like these are commands that should be supported:

on, off, poll, nextLevel, setLevel, setSaturation, setHue, save, and refresh:

// handle commands
def on() {
	parent.on(this)
}

def off() {
	parent.off(this)
}

def poll() {
	parent.poll(this)
}

def nextLevel() {
	def level = device.latestValue("level") as Integer ?: 0
	if (level < 100) {
		level = Math.min(25 * (Math.round(level / 25) + 1), 100) as Integer
	}
	else {
		level = 25
	}
	setLevel(level)
}

def setLevel(percent) {
	log.debug "Executing 'setLevel'"
	parent.setLevel(this, percent)
}

def setSaturation(percent) {
	log.debug "Executing 'setSaturation'"
	parent.setSaturation(this, percent)
}

def setHue(percent) {
	log.debug "Executing 'setHue'"
	parent.setHue(this, percent)
}

def save() {
	log.debug "Executing 'save'"
}

def refresh() {
	log.debug "Executing 'refresh'"
	parent.poll(this)
}

(Rich D) #4

Billmans - Can you describe your setup. I can’t seem to get my Hue lights to work. The SmartThings app recognizes my Philips Hue hub and all 10 of my bulbs. It adds them as Things. But the app has only successfully turned on or off one or two lights, but just a few times. In other words, it seems to work 2% of the time, but is mostly useless. Any tips? Is your SmartThings hub next to your Philips Hue hub? Are they far from your bulbs? I’m stumped and frustrated.


(John Magrane) #5

Hi folks,
I’ve got 4 Hue bulbs connected to my system and things are working well. I use the following piece of code to turn the lights on to a specific color and brightness when motion is detected. The Hue hub is sitting next to my ST hub in the downstairs office while the bulbs are in the upstairs bedroom.

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(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) {
if (correctMode() && correctTime()) {
hueLights.setLevel(99)
hueLights.setSaturation(59)
hueLights.setHue(14)
hueLights.on()
}
}
}

John