Running a script from the UI

Hi all.

I can’t find the answer to this question, so please forgive me if I’m repeating an existing question/answer.

I’m new to OpenHab, and thus far I’ve gotten about 24 Philips Hue bulbs and 5 Belkin WeMo devices all controllable through OpenHab with a basic sitemap. What I’m trying to do now is mimic the scene feature of the Hue system in OpenHab: Press one button in the UI and the lights associated with that turn on to a set color.

Near as I can tell, I can accomplish the “turn on these bulbs and set a color” with a script, but I can’t figure out how to run a script from the UI.

What am I missing? Or am I thinking too hard and there’s a better/easier way to do this?


Hello Brian,
first: what you are looking for is called “rule” in openHAB and yes, that’s exactly what will help you do what you desire. The solution consists mainly of two parts: an item and a rule.

  1. Define an extra item that is not linked to a binding, some call this a “virtual item”
Switch Lighting
// or
Number LightingPreset
I actually showed two options here. If you just want a Switch to "switch multiple lights on or off" use the first, if you are looking to define multiple presets, you can represent these by a Number.
  1. Add the new item to your sitemap
Switch item=Lighting
Switch item=LightingPreset mappings=[0="Off", 1="Dim", 2="Party"]
  1. Build a rule to act on this newly created input. I’ll give one example:
rule "Lighting Preset"
  Item LightingPreset received command
    switch (receivedCommand){
        case 0: {
            logInfo("RULE", "Lights off")
            //Group gLights is where all my lamps are in
            gLights.members.forEach(item |
        case 1: {
        case 2: {
    createTimer(now.plusSeconds(3)) [|
        //this will unselect the pressed button in your GUI, which might be something you'll like

Please be aware that these are just examples to show the concepts. You might need to modify things slightly.

Further details:
You can read about items, sitemaps and rules in the openHAB 1.8 wiki and in the openHAB 2 documentation:

1 Like

Thanks so much. The virtual item concept is awesome! Off to the designer to play!

Thanks again!