Group Items and aggregation

Hi,

I’m having some problems with creating groups and how they aggregate. I’m trying to report in my UI how many lights are currently on. Now, that seems easy and it is indeed. But my difficulty is that I have multiple lights in one lamp. And I want to count those lights combined as 1.

Here you can see my 5 items. There are 4 lights (hue binding switch item) and a group item.

The group item has the same base type as the individual items and it is grouped with an aggregation function "if one is on, then the status of the group item is ON (else OFF).

So far, so good. The 4 individual items belong to the group of course. This all functions as it should.

Now I have a final group item which has a number base type to report the number of lamps that are on. In this group I have put the group item of the lamp as seen above. Please see my config:

Now what I expected how it would work is that when the group item of the lamp is ON it counts ‘1’. Instead, OpenHAB seems to ‘deep dive’ into the group item which is in the ‘count’ group item and reports ‘4’.

Is this behaviour by design? Workaround that comes to mind is create a rule which counts the group items as 1 but maybe I misconfigured something and need to think different. That’s why I created this topic.

Thank you all for your replies.

I think so. openHAB has to do one or the other consistently, either follow the tree to the roots or not, and they chose to follow the tree back in OH1 days. People more often want to see “How many windows are open in total?” etc.

Your surprise probably comes from a magical hidden property of Groups with subtype Switch, which counts member states even while presenting an apparent state of just ON/OFF

I’d be inclined to represent your sub-group of lights with a dummy Item as you suggest.

Thank you @rossko57 for your reply. Indeed it’s that magical hidden property I did not expect. I assume this design choice of OpenHAB has many advantages as well but in this specific case for me it’s a disadvantage. I’ll go see if I’m going to make a rule for this :slight_smile:.

You mention the windows btw but I have the problem there too! I have a double door with 2 sensors (each door one) which I also want to count as one (to not confuse myself). But the solution may be more simple there as the ‘passive’ door can only in theory be open while the ‘active’ door is closed, which means I could easily just count the active door only. I can imagine however that with windows old houses may have a real ‘double window’.