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.
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
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.