Hue - how to detect colormode

I a trying to create a rule that blinks a hue bulb (with the alert channel), but saves the current bulb state upfront and restores that state afterwards. For example: the light is in colortemperature mode (a warm white) and when I press a UI button, the bulb blinks red 15 times and then switches back to it’s previous state. When restoring, I should set the color OR the coltemp channel and NOT both.

The API has a colormode = “ct” value, but this does not seem to be available as a channel.

Is there a (another) way to get the state of colormode?

Hi Robert,

You can try to use the HTTP binding and a JavaScript Transformation to get the colormode value via the Philips Hue API. Replace <HUE_BRIDGE_IP>, <HUE_API_KEY> and <BULB_ID> with your dependant values.


String hueLivingRoomColorMode "ColorMode [%s]" <light> {


(function(i) {
    var json = JSON.parse(i);
    return json["state"]["colormode"];

Please be aware that this examples may contain errors or typos, I wrote it down untested.

I don’t know Hue, but can’t you just save off the states of the Items linked to the Hue bulb in question to a local var and then sendCommand those states back to the bulb after the lights are done blinking? Assuming that works, that would be a more generic approach that would work with any type of light, not just Hue.

I have since discovered that I can use the color code to also set the white temperature. So I’m using that for now.

This is my rule for the record.

rule "BowlBlinkRed"
	Item Light_StudyBowl_Blink received command

	var String BlinkColor = ""
	switch(receivedCommand) {
		case "RED":  BlinkColor = "0,100,100"
		case "BLUE": BlinkColor = "240,100,100"
		default:     BlinkColor = "0,0,100"

	// save current settings
	val SavedSwitch  = Light_StudyBowl.state // ON or OFF
	val SavedColor   = Light_StudyBowl_Color.state  // HSB

	// set color to red and long blink
	Light_StudyBowl_Color.sendCommand( BlinkColor )
	Thread::sleep(15 * 1000) // let alert finish

	// restore
	if (SavedSwitch == OFF) {
	} else {
		Light_StudyBowl_Color.sendCommand( '' + SavedColor )


Thanks for sharing your rule. I have this on my to-do list for a while. This will be a good point to start with and to adapt it for my requirements.

You said that you use an item linked to the color channel, right? I always thought I have to send HSBType values as commands. I am happy to see, that StringType works too.

1 Like

The sendCommand does the type conversion.

Thank you for sharing your rule.
I tried it out but have a problem with the lights not restoring their color values. If they are off and I send the blink command, they retain the Blink color values. If they were on when the command was sent, everything works fine and the values are restored.

Any pointers on where to look? Is there a debugger where you can see the values of the variables when running a rule?

Bye, Frido.

1 Like

Argh! It’s been a while since I’ve actually looked at the code.
A suggestion would be to modify the restore part of the rule to also restore the saved color when the light was off before blinking (untested, YMMV):

	// restore
	Light_StudyBowl_Color.sendCommand( '' + SavedColor )
	if (SavedSwitch == OFF) {

Thank you, will try that out (as soon as I get back from summer holidays, that is…)
I am trying to blink a Hue LED stripe when a window is open and I leave the house…

Bye, Frido

This is my item config:

// bollamp in studeerkamer zolder
Switch Light_StudyBowl          "Bollamp" <light>      (Hue, gLights_Study) [ "Lighting" ] { channel="hue:0210:home:bulb3:color"}
Color  Light_StudyBowl_Dimmer   "Dimmer"        <slider> (Hue) { channel="hue:0210:home:bulb3:color"}
Color  Light_StudyBowl_Color    "Kleur"        <colorwheel> (Hue) { channel="hue:0210:home:bulb3:color"}
Dimmer Light_StudyBowl_ColTemp  "Kleurtemp."   <temperature> (Hue) { channel="hue:0210:home:bulb3:color_temperature"}
Switch Light_StudyBowl_Effect   "Effect"       <switch>     (Hue) { channel="hue:0210:home:bulb3:effect"}
String Light_StudyBowl_Alert    "Alert"        <alarm>      (Hue) { channel="hue:0210:home:bulb3:alert"}
String Light_StudyBowl_Blink    "Knipperen"        <colorwheel>      (Hue) {autoupdate="false"} // set by UI

and for the record this is a partial sitemap

	Frame label="Blink" {
		Switch item=Light_StudyBowl_Blink mappings=[ "RED"="Rood", "BLUE"="Blauw" ]
		Switch      item=Light_StudyBowl
		Slider      item=Light_StudyBowl_Dimmer visibility=[Light_StudyBowl==ON]
		Colorpicker item=Light_StudyBowl_Color visibility=[Light_StudyBowl==ON]
		Slider      item=Light_StudyBowl_ColTemp visibility=[Light_StudyBowl==ON]
		Switch      item=Light_StudyBowl_Effect visibility=[Light_StudyBowl==ON]
		Switch      item=Light_StudyBowl_Alert mappings=["NONE"="GEEN","SELECT"="ENKEL","LSELECT"="LANG"] visibility=[Light_StudyBowl==ON]

Thanks again. I didn’t find the time to adopt it for my setup.