I know that It has been a while for this thread, but I’m using OH3.4.0.M1 and this is working fine without creating additional groups.
My use case is that I want to count how many alerts are active at any given time. By alerts, I mean count failed services marked by OFF or OFFLINE, OPEN contacts, UNLOCKED doors, OPEN gates or any OPEN Alarm zones in my DSCAlarm system, etc.
For my DSC Alarm system, I created a group DSCPartition1Zones with a Base Type of ‘Contact’ and an Aggregation Function of ‘One OPEN then OPEN else CLOSED’, then I added all the Zone Things to this group. I did the same for contact sensor equipment such as my outside gate contact sensors and my garage door contact sensor.
For my door lock equipments and monitored services (i.e. monitoring HTTP Service on BlueIris), or any equipment or thing that uses switch items that should be normally ON, I modified each to a Base Type of ‘Switch’ and an Aggregation Function of ‘One OFF then OFF else ON’,
If it’s equipment that should be normally OFF, then set the Aggregation Function of ‘One ON then ON else OFF’.
Then created a group(equipment) called “Alerts” with a Base Type of ‘Number’ and an Aggregation Function of ‘SUM’. Then I added each of the groups or equipments mentioned above to the Alerts group.
This works for both sitemaps and label cards. In both cases, it shows in REAL TIME how many items are in an undesirable state. The label card is very straight forward:
And the sitemap code is also straight forward:
Text item=Alerts label="Alerts [%d]" icon=alarm
Default item=Alerts label="Alerts [%d]" icon=alarm
Group item=Alerts label="Alerts [%d]" icon=alarm
For sitemap, I use the visibility tag with the Group item, so that when I click on it, it only shows the
the active alerts. If there are no active alerts, it doesn’t show up at all in the site map.