Using slider to switch hue light on results in state of 100% ("ON")

Hi there,

I am having issues with my HUE lights and turning them on when I run the command “sendCommand(Hue_light, 30)”. When executing this command the light goes on as expected, but then I get a status update that the light is “ON”. This results in a status change from 30 to 100 as “ON” is interpreted as 100% I guess.
My HUE light is correctly on 30% but Hue_light.state incorrectly shows 100 instead of 30.

I defined my Hue_light as dimmer and I am using OpenHAB1.8

Is this a feature or a bug? Is there something I am missing?

Thanks.

Could you post the complete item and sitemap definition for the hue item?
I can also try out the behaviour in my system tomorrow.

Hi Dominic,

Here it is:

items:
// ================================= Woonkamer ===============================================

Dimmer Hue_booglamp “Booglamp” (gWoonkamer) { hue=“8” }
Dimmer Hue_staandelamp_onder “Staande lamp onder” (gWoonkamer) { hue=“9” }
Dimmer Hue_staandelamp_boven “Staande lamp boven” (gWoonkamer) { hue=“10” }
Dimmer Hue_iris “Iris” (gWoonkamer) { hue=“12” }
Color Hue_iris_color “Iris_color” (gWoonkamer) { hue=“12” }

Sitemap:
sitemap test label=“Main Menu”
{
Frame {
Group label=“Woonkamer” icon=“groundfloor” {
Switch item=Z_Haard_Switch label=“Haard” icon=“fire”
Slider item=Hue_staandelamp_onder label=“Staande lamp onder [%d %%]” icon=“hue”
Slider item=Hue_staandelamp_boven label=“Staande lamp boven [%d %%]” icon=“hue”
Slider item=Hue_iris label=“Iris [%d %%]” icon=“hue”
Switch item=gKeuken label=“Lamp keuken” icon=“hue”
Switch item=gEetkamer label=“Lampen eetkamer” icon=“hue”
Slider item=Hue_lichtslang label=“Lichtslang [%d %%]” icon=“hue”
Switch item=Z_switch_schuur label=“Schuur”
Slider item=Hue_voordeurlamp label=“Voordeurlamp [%d %%]” icon=“hue”
Slider item=Hue_booglamp label=“Booglamp [%d %%]” icon=“hue”
}

	Group label="Eerste verdieping" icon="firstfloor" {
                    Group label="1st slaapkamer" icon="bedroom" {
		  Slider item=Hue_slaapkamer_1st label="Slaapkamerlamp [%d %%]" icon="hue"			
                      Slider item=Hue_bloom label="Bloom [%d %%]" icon="hue"
                    }
                    Group label="Hoofd slaapkamer" icon="bedroom" {
                      Slider item=Hue_slaapkamer label="Slaapkamerlamp [%d %%]" icon="hue" 
                    }

                    Slider item=Hue_overloop label="Overloop dimmer [%d %%]" icon="hue"
	}		
}	
Frame {
	Group label="Tuin" icon="garden" {
		Switch item=Shutter_Living_switch1 label="Zonscherm [%d %%]" mappings=[100="Uit", STOP="Stop", 0="In"]			
		Switch item=Gordijn_achter_switch1 label="Gordijn achter [%d %%]"			
		//Switch item=Tuindimmer label="Tuinverlichting"			
		Slider item=Tuindimmer label="Tuindimmer [%d %%]" icon="outdoorlight" 
	}		
}	
Frame {
	Group label="Energie status" icon="socket" {
		Text item=item_haard_energy icon="energy"			
		Text item=item_haard_current icon="energy"			
		Text item=item_haard_kwh icon="energy"			
		Text item=Tuindimmer_Energy icon="energy"			
		Text item=Tuindimmer_Kwh icon="energy"			
		Text item=energie_totaal_vermogen_mqtt icon="house"			
		Group label="Gas" icon="shield" {
			Text item=gas_totaal icon="house"				
			Text item=GasConsumption_Today icon="house"				
			Text item=GasConsumption_CostToday icon="house"				
		}			
	}		
}	
Frame {
	Group label="Weer" icon="climate" {
		Text item=Temperatuur_buiten_mqtt icon="temperature"			
		Text item=Luchtvochtigheid_buiten_mqtt icon="climate"			
		Text item=Luchtdruk_buiten_mqtt icon="climate"			
		Chart item=Temperatuur_buiten_mqtt label="temp [%.2f]" icon="bedroom"			
	}		
}	
Frame {
	Group label="Radio" icon="network" {
		Switch item=woonkamer label="Radio" icon="switch"			
		Slider item=woonkamerVolume label="Volume [%d %%]" icon="settings"			
		Selection item=Sonos_Radio_Station mappings=[0="off", 1="Lounge FM Terrace", 2="NPO Radio 4", 3="Radio 10 80's"]			
	}		
}	
Frame {
	Group label="Telefoon" icon="bluetooth" {
		Text item=Inkomende_call_mqtt icon="boy0"			
	}		
}	
Frame label="Test" {
	Selection item=Scene_General label="Scene selection" icon="moon" mappings=[0="Uit", 1="Ochtend", 2="Dinner", 3="Avond"]		
}	
Frame {
	Group label="Sensors" icon="heating" {
		Group label="Voordeur" icon="socket" {
			Text item=Z_Woonkamer_Switch_Bat icon="socket"				
			Text item=Z_Voordeur_sensor				
			Text item=Z_Voordeur_sensor_Bat				
		}			
		Group label="Tuinhuis" icon="network" {
			Text item=Fibaro_Motion_1_Motion				
			Text item=Fibaro_Motion_1_Temp icon="temperature"				
			Text item=Fibaro_Motion_1_Lux icon="sun"				
			Text item=Fibaro_Motion_1_Tamper				
			Text item=Fibaro_Motion_1_Bat				
		}			
		Group label="Schuur" icon="corridor" {
			Text item=Schuur_Motion_Motion				
			Text item=Schuur_Motion_Lux icon="sun"				
			Text item=Schuur_Motion_Temp icon="temperature"				
			Text item=Schuur_Motion_Bat icon="socket"				
		}			
	}		
}	

}

Rules:
licht.rules

rule “Woonkamer_light_on”
when
Item Z_Woonkamer_Switch changed from OFF to ON
then
var HSBType paars = new HSBType(“307.9816513761468,85.49019607843137,100”)

  sendCommand(Hue_staandelamp_boven,80)
  sendCommand(Hue_staandelamp_onder,80)
  sendCommand(Hue_iris_color,paars)
  sendCommand(Hue_booglamp,50)
  sendCommand(Hue_lichtslang_color,paars)
 sendCommand(Z_Haard_Switch,ON)

end

rule “Woonkamer_light_off”
when
Item Z_Woonkamer_Switch changed from ON to OFF
then
sendCommand(Hue_staandelamp_boven,0)
sendCommand(Hue_staandelamp_onder,0)
sendCommand(Hue_iris,0)
sendCommand(Hue_booglamp,0)
sendCommand(Hue_lichtslang,0)
sendCommand(Z_Haard_Switch,OFF)
end

events.log:
2016-01-10 20:02:10 - Z_Woonkamer_Switch received command ON <–Zwave switch pressed
2016-01-10 20:02:10 - Z_Woonkamer_Switch state updated to ON
2016-01-10 20:02:11 - Hue_staandelamp_boven received command 80
2016-01-10 20:02:11 - Hue_staandelamp_onder received command 80
2016-01-10 20:02:11 - Hue_iris_color received command 307.9816513761468,85.49019607843137,100
2016-01-10 20:02:11 - Hue_booglamp received command 50
2016-01-10 20:02:11 - Hue_lichtslang_color received command 307.9816513761468,85.49019607843137,100
2016-01-10 20:02:12 - Z_Haard_Switch received command ON
2016-01-10 20:02:12 - Z_Haard_Switch state updated to ON
2016-01-10 20:02:12 - Hue_staandelamp_boven state updated to ON
2016-01-10 20:02:12 - Hue_iris_color state updated to ON
2016-01-10 20:02:12 - Hue_iris state updated to ON
2016-01-10 20:02:12 - Hue_lichtslang state updated to ON
2016-01-10 20:02:12 - Hue_booglamp state updated to ON
2016-01-10 20:02:12 - Hue_lichtslang_color state updated to ON
2016-01-10 20:02:12 - Hue_staandelamp_onder state updated to ON

2016-01-10 20:02:15 - Z_Woonkamer_Switch received command OFF <–Zwave switch pressed
2016-01-10 20:02:15 - Z_Woonkamer_Switch state updated to OFF
2016-01-10 20:02:15 - Hue_staandelamp_boven received command 0
2016-01-10 20:02:15 - Hue_staandelamp_onder received command 0
2016-01-10 20:02:16 - Hue_iris received command 0
2016-01-10 20:02:16 - Hue_booglamp received command 0
2016-01-10 20:02:16 - Hue_lichtslang received command 0
2016-01-10 20:02:16 - energie_totaal_vermogen_mqtt state updated to 420
2016-01-10 20:02:16 - Z_Haard_Switch received command OFF
2016-01-10 20:02:16 - Z_Haard_Switch state updated to OFF
2016-01-10 20:02:18 - Hue_staandelamp_boven state updated to OFF
2016-01-10 20:02:18 - Hue_iris_color state updated to OFF
2016-01-10 20:02:18 - Hue_iris state updated to OFF
2016-01-10 20:02:18 - Hue_lichtslang state updated to OFF
2016-01-10 20:02:18 - Hue_booglamp state updated to OFF
2016-01-10 20:02:18 - Hue_lichtslang_color state updated to OFF
2016-01-10 20:02:18 - Hue_staandelamp_onder state updated to OFF

Hi @eggn1n3 ,

if you want to use the Dimmer functionality, you have to specify the dimmer items the following way:
Dimmer Hue_booglamp "Booglamp" (gWoonkamer) { hue="8;brightness" } (note the brightness in the end, see https://github.com/openhab/openhab/wiki/Hue-Binding#brightness-dimmer-items for details)

Hi @dominicdesu, thanks for the suggestion. Unfortunately it didn’t make a difference at all. I still see the same behaviour.

Hi @eggn1n3, okay, then more questions :smile:
Do you have the hue refresh polling activated?
What happens when the Z_Haard_Switch is switched to on? It is not sending the ON command to a group item in which all hue lamps are included, I assume?

This is my log:

2016-01-11 20:25:27.978 [INFO ] [runtime.busevents             ] - COLampColor received command 54,0,100
2016-01-11 20:25:33.744 [DEBUG] [inding.hue.internal.HueBinding] - Start Hue data refresh
2016-01-11 20:25:33.929 [DEBUG] [inding.hue.internal.HueBinding] - Done Hue data refresh.
2016-01-11 20:25:33.933 [INFO ] [runtime.busevents             ] - COLampColor state updated to ON
2016-01-11 20:25:33.945 [INFO ] [runtime.busevents             ] - COLampColor state updated to 54,0,100
2016-01-11 20:25:33.962 [INFO ] [runtime.busevents             ] - COLampBrightness state updated to ON
2016-01-11 20:25:33.971 [INFO ] [runtime.busevents             ] - COLampBrightness state updated to 100

for items

Color  COLampColor                  (gCorridor)    {hue="4"}
Dimmer COLampBrightness    <hue>    (gCorridor)    {hue="4;brightness;30"}

So they are not only retrieving the ON state but also the brightness percentage value.
How does your log look like after you added the brightness to the item?

You could also try explicitly sending the PercentType to the hue, although I am not sure if this will change anything:
sendCommand(Hue_staandelamp_boven,new PercentType(80))

Hi @dominicdesu,
I do have the hue refresh polling activated:
hue_refresh=2500

The Z_Haard_Switch turns on/off an electric device (stove). For sake of simplicity I removed that form my rule. I only have one Hue light that is now switched on/off but I see the same thing (I added brightness to hue item file as you described).

I am lost now…

Do you see “state updated to 100” or “state updated to 80/50/30” ?

How does your issue actually manifest? Do you use the Hue_light.state in a rule and it is wrong, or does the Slider in the UI show an incorrect value?

When I check the events.log file I see that the state is updated to ON but not to the percentage:

2016-01-12 09:02:59 - Hue_staandelamp_onder received command 15
2016-01-12 09:02:59 - Hue_staandelamp_onder state updated to ON

I also tried to send a command like this:

curl --header “Content-Type: text/plain” --request POST --data “15” http://192.168.5.4:8080/rest/items/Hue_staandelamp_onder

Which give me status “100” and not “15”:

curl http://192.168.5.4:8080/rest/items/Hue_staandelamp_onder/state
100

(note, so now and then it works, but testing it for say 10 times, I get 5 or 6 times it does not work).

But when I use the slider on the webinterface it works ok every time:

2016-01-12 09:08:21 - Hue_staandelamp_onder received command 9
2016-01-12 09:08:22 - Hue_staandelamp_onder state updated to ON
2016-01-12 09:08:22 - Hue_staandelamp_onder state updated to 9

Does the slider send another command?

Current config:
items:
Dimmer Hue_staandelamp_onder “Staande lamp onder” (gWoonkamer) { hue=“9;brightness;30” }

sitemap:
Slider item=Hue_staandelamp_onder label=“Staande lamp onder [%d %%]” icon=“hue”

This is really strange…
Unfortunately I have no idea what else it could be… maybe someone else can help?

As a last resort (at least from my side), you could set the hue binding to debug level TRACE, and then post the openhab.log when you sent the command (and the following hue refresh), maybe we can spot something, maybe not…

Hi @dominicdesu,
I think I am on to something. It looks that the behaviour seems to come from the fact that when you turn on the light with the same value as before, the HUE bridge will only send an “ON” update. When you switch the light on with another value the HUE bridge sends “ON” and then the value.

This explains why the slider always seem to work (the chance that you hit the same value on the slider is small). When I execute my script I always send the same value.

I checked this by sending data directly to the HUE bridge:

Turning light on with brightness value (128)
curl --header "Content-Type: text/plain" --request PUT --data "{\"on\":true, \"bri\":128}" "http://192.168.5.134/api/openHABRuntime/lights/1/state"

Turning light off:
curl --header "Content-Type: text/plain" --request PUT --data "{\"on\":false, \"bri\":128}" "http://192.168.5.134/api/openHABRuntime/lights/1/state"

When I turn the light on again with the aforementioned on command, the events.log shows only “ON” only.
When I turn the light off and then on again with another brightness value, the events.log shows “ON” and then the other brightness value.

So to summarize: if I switch my lights off and then on it will show 100 for the state if the previous value was the same. If I switch the lights on with another value it is ok.

Not sure how I should update my rule script now… to be continued.