OH3.1.0.Group aggregate boolean functions do not return count number

It is possible in OH3 to set an item definition like the below either using the main UI or text item configuration.

Group:Contact:OR(OPEN, CLOSED) gDoors “Open Doors”

This will set the Group state correctly to OPEN if any one door is open or to CLOSED if all doors are closed.
How ever the COUNT of the OPEN doors does not appear anywhere …
Am I looking in the wrong place ?

Do you mean UI isn’t offering you a COUNT function setting? You’d need a Number typed Group to hold a count.

According to the manual instructions on Group aggregate functions:

Boolean group state functions additionally return a number representing the count of member Items of value ‘value1’ (see example below).

Group:Switch:OR(ON,OFF)     Lights        "Active Lights [%d]"         // e.g. ON and "2"

I was expecting a string representing the number of open doors

I think right now only possible with a rule workaround.

Yes, in OH2 a little known bit of magic was that formatting the state with [%d] returned a count.
I don’t think that works in OH3

You can approach the effect with Group of type Number and function SUM

Thank you all for your replies and advices.
The rule work around works fine with item labels but what I am trying to do is somewhat different as it has to do with “badges” and not labels.
It is going to be a long post but let me try to explain my problem in case somebody else has tried this already.

As you all know OH3 has a fantastic feature where at the “Locations” tab in the main overview page, you can see little “badges” on the location photo showing at a glance how many lights, or doors, windows etc, are open at any time. (Please don’t mind the Greek language).


All this is all very nice and works very well for the individual locations.

My problem is that I want to have on top of all the individual rooms (locations) a central location, representing the house AS A TOTAL, showing at a glance "all the lights in the house that are currently ON, together with “all doors” , “all windows” etc.

This works very well for LIGHTS, temperatures etc , that in the semantic model do not require a description as “equipment”. It is only necessary to specify “Point” and “Property” and then all these will appear on the “Properties” tab for the “House” location. Off course first you have to create a “House” location and include all your lights in the “House” location (Group) in addition to the individual room groups.


In my screen shot above you can see that in total I have 4 lights ON (in different rooms) and the “Outside temperature” and in the brackets is the “Average temperature” of “All the rooms” in the house. If you click on the temperature group you can then see the temperature in each individual room.
This a all very nice and fantastic work from the designers of OH3.

The problem starts when you want to include other item groups that require to be specified in the model with an equipment type. Like doors, windows, HVAC, blinds, etc.
It would be very nice if you could see with a glance how many windows are open and by clicking on the group, to see which windows are open. All this is trivial and unnecessary for an apartment or a place with only few doors or windows but for a big establishment this would be very helpful, for example if you want to leave the premises and can not activate the alarm because some windows are open.

The problem is that OH3 behaves somewhat arbitrarily when any equipment is included in MORE THAN ONE location.
I understand that physically it is not possible to have a “refrigerator” in two separate rooms at the same time, but in programming it is possible to have a refrigerator in the “Kitchen” location and at the same time in the “House” location.
OH3 allows you to have any equipment in more than one locations (Groups). The problem is that in one location the “Members of the Group” will be all listed as soon as you click on the location photo, where as on the second location “only the group name” will be shown when you click on the location photo, and in order to see all thee individual group members you have to click on the individual group name.
In the screen shot below you can see that the two doors in the dining room are listed as soon as you click on the dining room photo.


But in case of the “House” location only the “Door Group” is listed in the first page and you have to click on the group in order to see al the doors.

This is very important because the badges work only for the items that are shown on the first page and do not take into considerations the state of the items in groups, when only the group name appears in the first page.

Normally the state of any group itself will be NULL irrespective of the state of the individual members of the group, therefore since only the state of the group itself is shown on the first page (which is always NULL) there is nothing shown as a badge.

The work around is to use Group aggregate functions in order to define the state of the Group item itself. In this case it should be:

Group:Contact:OR(OPEN, CLOSED) gDoors “Open Doors”

This will set the state of the Group item to OPEN if any door is open or to CLOSED if all doors are closed.
This is reflected on the badge feature, which will show an open door if any of the doors is open because the state of the Group item is open.


Then you have to open the Group to see which individual door is open.
This is fine and will show when ANY door or window etc are open but will NOT show the number of open doors.
Hence my first question and the creation of this Topic.

This is not a big problem and I could leave with this solution as long as there is a indication of any open doors or windows.

However there is a big problem in the behavior of OH3 because the decision as to which location will show the full list of group members in the first page and which location will show only the group name in the first page, IS ARBITRARY (or at least I could not find out how it works.

Where in the case of doors the behavior is as described above but in other cases (windows, garage doors etc) it is quite the opposite.
The full list on the first page appears on the “House” location and the list with the main Group name only appears on the individual room locations.
Unfortunately this is unpredictable or until now I did not find out when the first or the second case are happening.
To make it even worse, for the same equipment Group (eg Doors) the groups will some time appear as in first case and another time as in the second case and this is driving me crazy…
It appears that there is some connection with the order in which the Groups are defined or included in the model but I have not been able to accurately recreate or predict the behavior. It appears to be arbitrary.

I think your arbitrary effects are because, nope, it doesn’t work with equipment in two locations. Some kind of race or history to determine the single winner.

For your counting thing, you need to determine if the %d magic counter still works in OH3, the last report I saw was No but rather old and not very convincing.

If it works, some enhancement of MainUI widget may be possible to show it in summary in some way.

I’ve tried already the %d magic counter but it returns “Err” as the Group item state.
I can leave without a counter number as long as there is an indication that there is “at least one” open window or door. Then you can click on the group and see which doors on windows are open.
Regarding the arbitrary effect I could keep trying by trial and error until I get everything right. It will take a couple of days of frustration.

A more acceptable solution is to have a second item (for each door or window) linked to the same thing channel. One item of each pair should be a member of the room location and the other should be a member of the house location.
In this way you have everything (badges, counters and all) working properly, but you end up having double the number of items and also under the “equipment” tab you get each door or window twice. One time separated under each room location and a second time for the house group showing all doors together in one list.
I think that this is not so terrible and I can leave with this until a better solution is found.
If anyone has a better idea please let me know.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.