[SOLVED] Drop down list for switch items

Hi everyone, new user questions

I have some questions regarding habpanel.

I would like to have a button, if pressed, make a dropdown list of my scenes and when I select one of the scenes, this scene will turn on, my scenes are made as switch items.

I’ve tried using the selection widget but I can only make it work with an item that is linked to a thing where the developer of the binding provides the options via the thing channel definition.

Are there any alternatives to the selection widget that can do what I am looking for?

Thanks in advance
Anders

Why don’t you use a proxy (String/Number) item? Then create a rule, based on what the item contains.
eg.
Item:

Number   SceneSelector

rule:

Rule "Scene Selector"
when
    Item SceneSelector received update
then
  switch (SceneSelector){
  case 1:  //rule for scene 1
  case 2: //rule for scene 2
  //etc etc etc
  }
end

sitemap:

Selection item=SceneSelector label="Select scene" mappings=[1=Scene 1, 2=Scene 2]

Hi thanks for taking the time to help :slightly_smiling_face:

I just tried your instructions, but I must have done something wrong because I can’t make it work.

I made a number item as described: Number SceneSelector

and a rule

Rule “Scene Selector”
when
Item SceneSelector received update
then
switch (SceneSelector){
case 1: sendCommad(Kontor_Spot,OFF)//rule for scene 1
case 2: //rule for scene 2
//etc etc etc
}
end

and in the selection widget

Did you get any error in de log?
Oh wait, I see my mistake:
The switch command in the rule must be

switch (SceneSelector.state)

Mind the .state
Secondly I see a typo in your rule sendCommad(Kontor_Spot,OFF) must be sendCommand(Kontor_Spot,OFF). Or as I prefer Kontor_Spot.sendCommand(OFF). You can read here why :wink:

The UI sends commands (although autoupdate usually turns those into state updates later)

A more direct way would be to have the rule triggered by received command in the ‘when’ section, and to use receivedCommand implicit variable in the ‘then’ section as the switch statement selector

Or forgo the switches completely and change the rules to be triggered by the value of your number item.

rule „Scene 1“
when
     Item Selector changed to 1
then
    // do your thing
end

Hi guys

I just had some time to mess with the rules and I made it work.

thanks for the help.

Anders :slightly_smiling_face:

1 Like