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.
Maybe you have a better idea for my use-case?
I have an equipment defined as a power outlet in my semantic model. If I switch on “Christmas Mode” this power outlet should be removed from my semantic model (not visible in the UI anymore) and a new Item should be created as a light (same channel as the removed power outlet), added to the semantic model and additionally into the group “all living room lights”.
As a result: it’s not only about visualization in the UI, during christmas the power outlet is switched by the the light group, the rest of the year the power outlet is just switched on it’s own.
Of course if christmas mode is switched off, it goes the other way around.
Would it be possible somehow with tags/metadata?
I have a similar use case. During Christmas I’ve a could of almost plus that control lights. The rest of the year the same plugs control humidifers.
So first of all, it’s not the what plug that is being controlled, it’s the humidifier or lights. So I have two items, one for each device. Both items are linked to the same channel. Both Items have appropriate semantic tagging.
I have a separate Switch Item called “TisTheSeason” which I flip ON when the lights are set up and OFF the rest of the year.
The behavior of the two Items is controlled by separate rules from everything else. So, for example, instead of having the light Item be a member of a Lights Group, I’ve a rule that triggers when the lights group receives a command and forward that command to the light. There is another set of rules to control the switch based on the measured humidity.
When TisTheSeason changes to ON, the humidifier rules are disabled and the light rules are enabled. When it changes to OFF the light rules are disabled and the humidifier rules are enabled.
Both Items have custom default list item widget metadata so that the light Item is only visible when TisTheSeason is ON and the humidifier Item is only visible when it’s OFF.
everything about this smart plug flips when it’s put to a new purpose over the holidays, the rules, the UI, etc.