Help in defining main switches for different devices and rooms


I installed openhab and now I am trying to plan how to define my items and groups.

I have the following configuration:

//Room1 - Floor 1

Switch Light1_Room1 “Light1 Room1” (gRoom1, gLights) {channel="zwave:…}

Switch Light2_Room1 “Light2 Room1” (gRoom1, gLights) {channel="zwave:…}

Switch Fan_Room1 “Fan Room1” (gRoom1, gFans) {channel="zwave:…}

Rollershutter Blind1_Room1 “Blind 1-Room1” (gRoom1, gBlinds) {channel="zwave:…}

Rollershutter Blind2_Room1 “Blind 2-Room1” (gRoom1, gBlinds) {channel="zwave:…}

//Room2 - Floor 1

Switch Light1_Room2 “Light1 Room2” (gRoom2, gLights) {channel="zwave:…}

Switch Light2_Room2 “Light2 Room2” (gRoom2, gLights) {channel="zwave:…}

Switch Fan_Room2 “Fan Room2” (gRoom2, gFans) {channel="zwave:…}

Rollershutter Blind2_Room2 “Blind 2-Room2” (gRoom2, gBlinds) {channel="zwave:…}

Rollershutter Blind2_Room2 “Blind 2-Room2” (gRoom2, gBlinds) {channel="zwave:…}

//Room3 - Floor 2

Switch Light1_Room3 “Light1 Room3” (gRoom3, gLights) {channel="zwave:…}

Switch Light2_Room3 “Light2 Room3” (gRoom3, gLights) {channel="zwave:…}

Switch Fan_Room3 “Fan Room3” (gRoom3, gFans) {channel="zwave:…}

Rollershutter Blind1_Room3 “Blind 1-Room3” (gRoom3, gBlinds) {channel="zwave:…}

Rollershutter Blind2_Room3 “Blind 2-Room3” (gRoom3, gBlinds) {channel="zwave:…}

//Room4 - Floor 2

Switch Light1_Room4 “Light1 Room4” (gRoom4, gLights) {channel="zwave:…}

Switch Light2_Room4 “Light2 Room4” (gRoom4, gLights) {channel="zwave:…}

Switch Fan_Room4 “Fan Room4” (gRoom4, gFans) {channel="zwave:…}

Rollershutter Blind1_Room4 “Blind 1-Room4” (gRoom4, gBlinds) {channel="zwave:…}

Rollershutter Blind2_Room4 “Blind 2-Room4” (gRoom4, gBlinds) {channel="zwave:…}

I want to create a few main switches based on below guidelines:

For each ROOM I want 4 switches:

  1. Turn Off all lights
  2. Turn Off all lights and fan
  3. Up/Down all blinds
  4. Turn Off room – down all blinds and turn off all lights and fan

For each FLOOR I want 3 switches:

  1. Turn Off all lights and fans
  2. Down all blinds
  3. Turn Off floor – down all blinds and turn off all lights and fans

For the HOUSE I also want 3 switches:

  1. Turn Off all lights and fans
  2. Down all blinds
  3. Turn Off House – down all blinds and turn off all lights and fans

I started to have problem when I started to define the groups with the switches. What is the best way to define the groups/switches?


Please How to use code fences

It would be helpful to understand what you’ve tried. All you do is define the Group using Group:Switch and the Group will be a Switch Item. You may want to give it an aggregation function, such as Group:Switch:OR(ON,OFF) which will make the Group’s Item be ON if one or more of the Group’s members are ON.

Sending a command to this Group will forward the command to all of it’s members. But that requires all the members to accept the same commands. You can’t mix Switches and Rollershutters because Rollershutters don’t accept ON/OFF commands.

So you will need to use a Design Pattern: Proxy Item and Rule to change the ON command to a DOWN command for the Rollershutters.

Thanks, I’ll use DP and the aggregation function (and code fences).

Regarding the master switches, if for example I want to group all blinds in the 2nd floor, do i have to create a new group (g2ndFloorBlinds) and add it to all blinds in the 2nd floor, or there is a way to create a new group from subgroups gRoom3, gRoom4 and gBlinds (that will eventually include Blind1_Room3, Blind2_Room3, Blind1_Room4 and Blind2_Room4)?

Thanks again

There is, try it. A Group may be a member of another Group.

Thank, but i want to do intersection and not merge of the groups - JUST elements of group A that also belong to group B

This can be done in rules. Iterate group A and check each member for membership of group B

Here is an example.


GroupA.members.filter[ i | i.groupNames.contains("GroupB") ].forEach[ i | i.sendCommand(DOWN) ]

Python (I’m not 100% on this one):

for i in filter(lambda i: i.groupNames.contains("GroupB"), ir.getItem["GroupA"].members): events.sendCommand(i, DOWN)