Goups to control visibility

Guys, i am to stupid to understand really the mechansim behind visibility and groups :frowning: Hopefully you can help me out.

i created a group that is filled dynamically within a rule, so that the group only contains alle items where the batteries are empty. That work pretty well. The group ist defined als follows:

Group:Switch:OR(ON, OFF) gEmptyBatteries "Leere Batterien - Bitte prĂĽfen! [%d]" <measure_battery_0> (gManagement)

As far as i understand the [5d] display the number of iten with state ON in this group - Check, is working in the sitemap, number is displayed.

So i assume i should be able to use the number or the state of the group to control visibility. Vey simple - No empty batteries, no display. This should be done with the following lines in the sitemap:

Group item=gEmptyBatteries visibility=[gEmptyBatteries>0]


Group item=gEmptyBatteries visibility=[gEmptyBatteries==ON]

But this did not work :frowning: Anyone any ideas why? Configuration is Basic UI and OH2 stable


You’re almost there :slight_smile:
You can not get the status from the name, you have to check if there are any members of your group in the wanted state, like so:
gEmptyBatteries.members.filter(s | s.state == ON).size > 0

An excellent source for information on Groups is here; really helped me to understand the concept: