Hue Binding control group of lights

I want to turn on all of my lights in a certain room. When I arrange those lights in a group and set this group to ON, the lights turn on sequently with some millis delay.

When i turn this group on via my hardware hue switch the all turn on together since a request is send to a hue group.

Is there a way to do this via the binding?

I’ll let a Hue expert chime in but I’m going to guess the answer is no based on my understanding of how OH works.

I’m not an expert, but you could try to look into the API to control groups:

http://www.developers.meethue.com/documentation/getting-started

I actually just thought of something that may work but I’m sure and I’m also not sure it would meet your needs.

But if you create a timer to trigger the lights 10-100 msec into the future for each of the lights maybe they will execute a little closer to the same time.

myLights.members.forEach[light|createTimer(now.plsuMilliseconds(50 | light.sendCommand(OFF)))]

NOTE, double check above, I just typed it in and it probably has errors.

Yes i saw in the API that there is a way just dont know if its implemented

rlkoshak thanks for your code, there were some typos so here a update if someone wants to use it. Indeed it improved the situation, but still the lights won’t switch on in perfect synchro :wink:

gLights.members.forEach[light| createTimer( now.plusMillis(10) )[ | light.sendCommand(OFF) ]]

So I think a update of the hue binding to set command to the API for a group would be perfect

That is very likely easier said than done. Groups are managed and maintained by the core, not the Hue binding. There may be a way for the Hue binding to allow one to create an Item that represents a group of lights, but the Hue binding has no control over how Groups are processed.

Yes thats how i meant the implementation in thw hue binding. To be able to define a new item type huegroup.

I also think this would be very useful. I dont have any need for individual lights in OpenHab as I dont control them individually on a day by day basis. Id rather define scenes and then call upon Hue Groups to active different scenes. I wish it could be done with the Hue binding… A manual hack could be to get your API key from Hue Bridge and use the exec binding to perform calls directly to the RESTful interface… I do this now to turn off and on all lights.

Yes thats how i do it currently too: Send a request via curl to the hue api.

It looks way smoother when all lights turn on in synchro when the door is opened

I’m baffled that this isn’t already implemented. Although I understand supporting groups in addition to individual lights might be a tad complex, considering their connection.

I might quickly look into modifying the Hue binding to deal with groups instead of lights. That would mostly resolve it on my part. I have no need for individual control over bulbs, since all my bulbs are part of groups.

@bjornha Did you make some progress?

Just setting up my hom automation again in the flat and getting to the same point where i want to switch on and off a group of lights.

Since I don’t like the sequential on/off when using openhab group: Is there any progress on the binding with added group support? Or should I write a function to send a put request to HUE Api for the group?

I’m on the same issue. Does anyone have a solution on that? I want to control groups of bulbs as well.

I solved this one by setting a switch for each room. Based on this switch status I sent my own request to the Hue API. All you have to find is your group id in the hue api. In the example below 7

var String hueApiCall = "curl@@-X@@PUT@@-d@@{\"on\": %s}@@http://192.168.0.11/api/your api key/groups/%d/action"

rule "Light Kitchen" when
	Item Lights_kitchen received command 
	then
		if( Lights_kitchen.state == ON ){
			// Turn group on
			executeCommandLine(String::format(hueApiCall,"true",7))			
		}
		else{
			executeCommandLine(String::format(hueApiCall,"false",7))			
		}
end

To keep track of the status if the group I have another openhab group and change the status of the switch accordingly


Group:Switch:OR(ON,OFF)  gLights_livingroom
Group:Switch:OR(ON,OFF)  gLights_bedroom
Group:Switch:OR(ON,OFF)  gLights_kitchen
Group:Switch:OR(ON,OFF)  gLights_guestroom
Group:Switch:OR(ON,OFF)  gLights_auto

[....]

// Switches to turn off/on all lights in Room
Switch Lights_guestroom	 "Guestroom Light"
Switch Lights_livingroom "Livingroom Light"
Switch Lights_kitchen "Kitchen Light"
Switch Lights_Bedroom "Bedroom Light"

[...]


rule "Update Light Switches" when
	Item gLights_livingroom changed or Item gLights_kitchen changed or Item gLights_guestroom changed or Item gLights_bedroom changed
	then
		Lights_guestroom.postUpdate( gLights_guestroom.state )
		Lights_Bedroom.postUpdate( gLights_guestroom.state )
		Lights_livingroom.postUpdate( gLights_livingroom.state )
		Lights_kitchen.postUpdate( gLights_kitchen.state )	
end

Thanks for that. The rule generally works, but i am still experiencing that the group of lights is not being updated correctly. But there is no error in the log. When i switch of the lights via openhab app on my mobile, it is going back to “on” a few seconds later.
any idea what might cause this?

Thanks,

Discovered today it’s possible to define a single item and assign multiple Things to it.

Dimmer hue_group1 "3 spots as one" { channel="hue:0220:0017880a91a9:10:brightness,hue:0220:0017880a91a9:11:brightness,hue:0220:0017880a91a9:12:brightness" }

Then with a single Slider you can control all the lights as one :slight_smile:

2 Likes

Does this also works when you’ve already defined the individual items (as ‘stand-alone’ units)?
Would be interesting to prevent the default group-behaviour.