[SOLVED] One slider to control them all (hue lights)

I’m trying to use one slider to control the brightness of different hue lights seperately. So I have 5 lights for instance. I have a slider on the left, and I added 5 buttons, representing each light.

What I’d like, is to be able to select a light using one of those buttons, and then use the slider to contorl the brightness.

    Dimmer   LR_Light1_Brightness "Brightness" ({channel="hue:0220:00178812ef2f:1:brightness"}
    Dimmer   LR_Light2_Brightness "Brightness" ({channel="hue:0220:00178812ef2f:2:brightness"}

I tried to use a string item LightName

String LightName "LR_Light1_Brightness "

to store the selected dimmer items name (e.g. ‘LR_Light1_Brightness’) when the button for light 1 is selected. This part works.

Then I used the string item as the item to be controlled from the slider. This part doesn’t work. It’s probably not possible to do it like this, but has anybody got an idea that could work?

To be clear: I don’t want a slider that works on a group of lights; I want to be able to control 5 lights seperately, with one slider, depending on the selected light.

Ok, you need a dummy item linked to the dimmer on the UI

Dimmer myDimmer

Then a rule:

rule "DImmer command to selected light"
when
    item myDimmer changed
then
    if (LightName != NULL) {
        sendCommand(LightName.state.toString, myDimmer.state.toString)
    }
end

This sounds like a good use case for dynamic Group membership.

You can change an Item’s Group membership through Rules.

Given:

Group:Dimmer ControlLights
Group:Switch EnableControl
Dimmer   LR_Light1_Brightness "Brightness" {channel="hue:0220:00178812ef2f:1:brightness"}
Switch LR_Light1_Brightness_Enable (EnableControl)
...
import org.eclipse.smarthome.model.script.ScriptServiceUtil

rule "Light enabled/disabled"
when
    Member of EnableControl received command
then
    val light = ScriptServiceUtil.getItemRegistry.getItem(triggeringItem.name.replace("_Enable", "")
    if(receivedCommand == ON) ControlLights.addMember(light)
    else ControlLights.removeMember(light)
end

Put ControlLights on your sitemap or HABPanel as a Dimmer/Slider/Whatever is appropriate and all of the Switches. As you toggle the Switches the Items will be added/removed from ControlLights and they will respond to the commands sent to ControlLights.

Thanks @vzorglub! I didn’t know that you could have dummy objects, thats very helpfull.

@rlkoshak this suits my needs even better. I’ll have a go at this one, thanks!