I'm currently trying to collect Bulbs attributes so i can then return each bulb to its previous state. I'm able to collect almost all attributes except for color which is returning null. this worked for me on ST is it different on Hubitat for currentColor ?
def state = bulbs.collect{it.currentSwitch == "on"}
def hue = bulbs.collect{it.currentHue}
def saturation = bulbs.collect{it.currentSaturation}
def colorTemperature = bulbs.collect{it.currentColorTemperature}
def level = bulbs.collect{it.currentLevel}
def color = bulbs.collect{it.currentColor}
def qty = state.size
If you are getting the hue, saturation and level, why do you need the color? You might want to try currentRGB or currentColorName.
http://docs.hubitat.com/index.php?title=Driver_Capability_List#ColorControl
I just realized that I'm getting everything I need with the temp,hue and saturation.My current problem is setting the everything to the previous state. Is not working.
What I'm I doing wrong here?
bulbs.eachWithIndex {s, i ->
def previousState = state[i]
if (previousState) {
def previousColorTemperature = colorTemperature[i]
def previousLevel = level[i]
def previousSaturation = saturation[i]
def previousHue = hue[i]
s.on()
s.setLevel($previousLevel)
s.setSaturation($previousSaturation)
s.setHue($previousHue)
}
else {
s.off()
}
Well, wouldnt you also want to get the color mode to know whether to restore the color or the color temp? You don't want to restore both.
Of course, a properly coded drive will have all of the attributes in effect at the time of the code baseline. So, I would think you would get something back for "color" since it has be around for a long time. The same would be true for the command setColor. So the logic would be similar to
setLevel (level(i))
If (colorMode(i) == "CT") {
setColorTemperature(colorTemperature{i})
} else if (colorMode(i) == "RGB") {
setColor(color(i))
}
Question: @mike.maxwell: Looking today, I see attribute RGB for capability Color Control. Do you have any additional definition?
Dave Gutheinz
The RGB attribute for color control isn't fully implemented in our drivers at this time.
2 Likes