setColor() argument

I ran a code to alternate between colors and ended up with a missing method exception. It said my setColor() method was the problem. My line of code was setColor(0, 100), 0 being the hue value and the saturation.(this should be red). Did i pass the arguments in the method wrong or is there something else i can do?

Against what specific type of Device (brand, model, Device Type Handler source…)?

The Capability definition (One simple home system. A world of possibilities. | SmartThings) is not always properly implemented in the DTH.

1 Like

Here’s the code i’m using for the bulb grouper
I referred to that capability reference when making the code. Did I pass the arguments wrong.? If you can provide an example of how to invoke the setColor() method with the correct arguments that’ll be extremely helpful.

This definition (linked and pasted before) of setColor() is incorrect.

setColor( hue, saturation ) takes 2 arguments, not 1.

See lines 107-112.

def setColor(value){
	// log.debug "setColor(${value})"
	// stupid hack to set the state the first time this device is used. Won't select a color other than #FFFFFF without it.
	if (!state?.color) state.color = "#FF0000"
    sendEvent(name: "color", value: value.hex, data: value)

My part of code that caused of an error was this:
def setColorHandler1(evt){
slaves.setColor(0, 100)//sets bulb to red
runIn(60, setColorHandler2)//changes to green in 1 minute

0 is hue and 100 is saturation so setColor() took 2 arguments in this case. Am i supposed to include the ‘%’ sign


However, there is no guarantee that the Device Type Handler you are calling has properly implemented the setColor() method.

I recommend you share the full source codes of the DTH(s) and involved SmartApps so we can debug further.

1 Like