text: Group Items and aggregation - Items & Sitemaps - openHAB Community
  Group Items and aggregation
  Dennis1984120 (Dennis) July 14, 2021, 10:35am #1
  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.
  openhab-1739×315 7.73 KB
  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).
  openhab-2734×603 9.06 KB
  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:
  openhab-3730×603 8.1 KB
  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.
  rossko57 (Rossko57) July 14, 2021, 11:44am #2
  Dennis1984120:
  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.
  Dennis1984120 (Dennis) July 14, 2021, 12:21pm #3
  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 .
  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'.