How to create a multiselection to use in rules

Hi There,

does anyone out there has an idea how to create a multi selection in the sitemap. Inmy mind i have currently something linke check marks and from these are values generated.

I need this for my notification rule. Any participant should habe the option to set the level of information he/she will get. I defined following levels: Info, Action, Warning, Alert

The user should be able to select which of the he/she will receive.

Any ideas?


Switch item=Szene icon=“color” label=“Szene” mappings=[1=“morgens”, 2=“tags”, 3=“abends”, 4=“Nacht”, 100=“TV”, 0=“Aus”]

The item can be defined in items file to be of Number or String type

Not that way. I would like to select “morgens” und “abends” or “abends” and “tag” or all three. so with any combination it is complicated.


That’s not what you asked for. Use multiple switch items then, one per level?
Also, for notifications, it doesn’t make sense to select e.g. ‘Action’ and ‘Alert’ only (and deselect ‘Warning’) because if you select ‘Action’ level logging, you (commonly) want to see all higher level messages, including ‘Warning’ (i.e. Action, Warning, Alert).

Thats your idea. For me warning are interesting for my wife not, but she is interested in Alerts and Action messages. To create switches is a huge effort if i have more recipients that should receive different messages


one line per switch is huge effort?

I’m afraid you will need to use switches. Any special logic (e.g. if you select Alert you can’t select Warning) will be implemented in rules.

You can make the “huge effort” easier by using groups.


// Group and switches which control who gets what notifications
Group gNotificationSettings
Switch Me_Info    (gNotificationSettings)
Switch Me_Action  (gNotificationSettings)
Switch Me_Warning (gNotificationSettings)
Switch Me_Alert   (gNotificationSettings)

Switch Wife_Info    (gNotificationSettings)
Switch Wife_Action  (gNotificationSettings)
Switch Wife_Warning (gNotificationSettings)
Switch Wife_Alert   (gNotificationSettings)

// Items which act as proxies for alerts that get sent
String Info
String Action
String Warning
String Alert

// Items which act as a proxy for sending an alert to indicated people
String NotifyMe
String NotifyWife


import org.eclipse.xtext.xbase.lib.*
import org.openhab.core.items.*
import org.openhab.core.library.items.*

val Functions$Function3 send = [ String level, String message, GroupItem params |
   val flags = params.members.filter[s|]
   flags.forEach[ s |
        if(s.state == ON) {
            val who ="_").get(0)
            sendCommand("Notify"+who, Info.state.toString)

rule "Notify Me"
    Item NotifyMe received command
    // code to send NotifyMe.state.toString to Me

rule "Nofity Wife"
    Item NotifyWife received command
    // code to send NotifyWife.state.toString to Wife

rule "Info"
    Item Info received command
    send.apply("Info", Info.state.toString, gNotificationSettings)

rule "Action"
    Item Info received command
    send.apply("Action", Info.state.toString, gNotificationSettings)

rule "Warning"
    Item Info received command
    send.apply("Warning", Info.state.toString, gNotificationSettings)

rule "Alert"
    Item Info received command
    send.apply("Alert", Info.state.toString, gNotificationSettings)

// Example: To send an Info message Info.sendCommand("message")

Theory of operation:

To send a notification sendCommand the message to one of the alerts proxy String Items (e.g. Info).

This causes a rule to trigger which calls a lambda called send.

This lambda is where the magic happens. It filters gNotificationSettings to get all Items that end in the logging level (e.g. the Info rule passes “Info” as the logging level so the result of the filter will be those two switches which end in “Info”. It then loops through all of those and extracts the first part of the Switch’s name. This is then used to construct the name of the Notification proxy Item associated with that person (e.g. NotifyMe) and the message is sendCommand to that Item. This triggers the Notify rule which actually implements the code to pass the message on to you.

To add a new person you just need to create new Name_Info et al Items and make them part of the gNotificaitonsSettings group.


  • I just typed this in, there may be errors.