Using groups with nesting and counting the parent

Have you actually tried your first thought?

Group:Number:SUM with Switch Item members will count the ON states.
And of course a Group:Number:SUM with Group:Number:SUM members will total those up.

I had my nesting wrong, so havent since then. Ill give it a go now :slight_smile:

Sort of! Its giving me numerical values lol!

So when study light goes on, it shows 1.5

openhab> smarthome:status gAllLivingLights
0.00000000
openhab>

Put in de label of the parent group [%d] at the end of the name. Eg. “All lights [%d]”

Now it shows :frowning:

openhab> smarthome:status gAllLivingLights
30.48000000
openhab>

Group:Number:SUM  gAllLivingLights          "All Living Lights [%d]"

Try what it shows when you remove the Dimmer Item from the group.

2 Likes

Oh, Dimmers in the mix. Well, that’s not going to work.

1 Like

Thanks Hans, you’ve got it :wink: Working nicely now! Thanks all!

Great that I could help :+1:

I Spoke too soon!

Combined number is 19 lights on this Living Level, yet the parent shows only 2 of 5.

2 on is correct , 1 in Kitchen and 1 in the study. But who knows where 5 is coming from!


Group:Number:SUM         gAllLivingLights          "All Living Lights [%d]"

/*Group Definitions for Lights on the Living Level*/
Group:Switch:SUM   gLivingLights       "Living Lights"         (gAllLivingLights,gInsideLights,gAllLights)      [ "Lighting" ]

And displayed with:

div ng-repeat="item in itemsInGroup('gAllLivingLights') | filter:query as filteredAllLivingLights"></div>
                    <div class="summary on">ON: {{ ( filteredAllLivingLights | filter: { state: 'ON' } ).length }} of {{filteredAllLivingLights.length}}</div>

It’s got five direct members (the groups).

Which is not what I wanted in the original post.

What I want to display, is the number of lights ON inside that parent group.

Not the number of groups in the parent… :frowning:

Well, exactly. Why then are you choosing to display the “of nn” part?
Your habpanel
.... of {{filteredAllLivingLights.length}}

I’ve been experimenting.
This is just for display, right? That’s to say, you’re not interested in the state of the Group for use in rules or whatever.

The Group formatter includes a bit of magic, as pointed out by @ljsquare
Group:Switch:SUM xxx "some label [%d]
or
Group:Switch:OR(ON,OFF) xxx "some label [%d]"
both work much the same, at first.
This is Switch type, so its state wil be ON/OFF in the ordinary way.
The magic is the [%d] which will display the count of “ons”, just what you want.

If you put Dimmers in such a group, it works as hoped for and counts up non-zero dimmers the same as switches. But, this only works properly with an OR(ON,OFF), which is perhaps sensible, as that forces treatment as switches not percentages.

The [%d] magic extends through a group hierarchy as you would hope.

So, in summary

Group:Switch:OR(ON,OFF)  XX "Totals [%d]"
Group:Switch:OR(ON,OFF)  YY "subs Y [%d]" (XX)
Switch AA "lamp" (YY)
Dimmer BB "lamp" (YY)
Group:Switch:OR(ON,OFF)  ZZ "subs Z [%d]" (XX)
Switch CC "lamp" (ZZ)
Switch DD "lamp" (ZZ)

The important part is the [%d] and I don’t think it works with anything else.

1 Like

Hi rossco

Yes its for display, its a high level summary of how many lights on a particular floor are on. Nothing more, the individual rooms on a floor provide more detail. yes, I wont use the parent group in rules. Ill use the more specific room groups for rules.

So, i had Group:Switch:NUM which seems to add up the parent groups - not what I want.

So if I read that correctly, it’s not going to do what I want basically.

I want group X to total up the members of Z and Y, and tell me if they are ON or OFF

ie: 8 ON of 20

Solution to that in the previous post

This is a new requirement, you will need to find out how to get habpanel to count all submembers of your top level group while ignoring or subtracting ordinary members.

The clonky method is here, adding upeach known subgroup

Of course there is a solution that will work with what you’ve got, flatten the hierarchy.
Just create a new group for counting purposes only and put all your bottom-level switches and dimmers directly in that as well. The hierarchy can stay in place for any other purposes.

rossko57, is there a way that I can group all my room blinds and shutters into 1 group, and display the contents as switches? I need two groups, one for shutters and one for blinds, because sometimes you want all the blinds open and the shutters closed, so placing them into a single group called WindowCoverings won’t work.

I have a room with 4 blinds and 4 shutters.

Group:Switch:OR(ON,OFF)  gAllMasterBedCoverings



/*Group Defintiions for Shutters*/
Group:Switch:SUM gAllShutters          "All Shutters"           (gAllWindowCoverings)
Group:Switch:SUM gMasterBedShutters    "Master Bed Shutters"    (gAllMasterBedCoverings)


/*Group Defintiions for Blinds*/
Group:Switch:SUM gAllBlinds           "All Blinds"            (gAllWindowCoverings)
Group:Switch:SUM gMasterBedBlinds     "Master Bed Blinds"     (gAllMasterBedCoverings)

What this does, is display the subgroups, Master Bed blinds and Master Bed shutters as a group. It does not give me the individual items in each of those subgroups. Is this because I’ve my parent group, gAllMasterBedCoverings?

I want to use that to display the individual items. Not the group items.

Display in what? Guess that is habpanel, don’t know how you set that up.

In a sitemap based UI you would simply write lines to display what you want, and not use default Group widget.

It seems to me that you want here is also a flattened hierarchy: each roller can be a direct member of both local group and summary group.

Never played with RollerShutter type Items as Group Switch type members; does that work like dimmers as well? i.e. non-zero states are considered as ON

HabPanel, displaying the group members of the child group, using the nested group’s name

The rollerShutter type is UP/DOWN/STOP. Theres also a switch type which is on yes.

Im not sending commands to the group yet, just trying to display the contents

The rollershutter state is a percentage, that is what is used to calculate Group state (if it has an aggregation function).

I don’t think you will be able to send UP DOWN to a group of type Switch, no matter what members it might have.

Back to display, I have no idea if you can write a habpanel widget to show members of members.

If you can’t, then flatten the hierachy by adding a new group for display purposes only and adding whatever Items you want directly.