Using groups with nesting and counting the parent

Hi All,

I have a number of lights distributed across some groups, they all roll up into a parent group, gAllLivingLights.

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

I have the following.

Can I use

Group:Number:SUM	

Would just displaying all of them, either ON or OFF. Not ideal.

My current nested group code is:

Group gAllLivingLights       (gLivingLights,gLivingDimmers,gKitchenLights,gStudyLights,gKitchenLights)

With my childs:

/*Group Definitions for Lights on the Living Level*/
Group:Switch:SUM   gLivingLights       "Living Lights"         [ "Lighting" ]
Group:Switch:SUM   gLivingDimmers      "Living Level Dimmers"  [ "Lighting" ]
Group:Switch:SUM   gKitchenLights      "Kitchen Lights"        [ "Lighting" ]
Group:Switch:SUM   gStudyLights        "Study Lights"          [ "Lighting" ]

Thank you wise ones!

I think this is what you want:

Group:Switch:OR(ON,OFF) Lights “Active Lights [%d]”

https://www.openhab.org/docs/configuration/items.html#group-type-and-state

Yes, for an individual group, but for a nested? I’ll try it

No joy :frowning:

But I’ve I read your code right, this is the wrong way. The parent group is not supposed to belong to any group. The child groups are supposed to belong to the parent group.

Group:Switch:OR(ON,OFF) gAllLivingLights

Group:Switch:OR(ON,OFF) gLivingLights       "Living Lights"    (gAllLivingLights)    [ "Lighting" ]
Group:Switch:OR(ON,OFF) gLivingDimmers      "Living Level Dimmers"  (gAllLivingLights) [ "Lighting" ]
Group:Switch:OR(ON,OFF) gKitchenLights      "Kitchen Lights"    (gAllLivingLights)    [ "Lighting" ]
Group:Switch:OR(ON,OFF) gStudyLights        "Study Lights"  (gAllLivingLights)        [ "Lighting" ]

This supposed to work

1 Like

Thanks Laurens! ill give this a go :slight_smile:

So absolutely, it now displays ON or OFF in the nested group, but I need to know the number of ONs in the nested group :slight_smile:

A bit closer!

I don’t believe it is possible to SUM ON and OF states. I think you will have to resort to an item that is updated by a rule whenever any item within the group changes its state, and in that rule count the number of items in the group that are ON.

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: