I would like to count the number of players in a group that have the state PLAY. I tried two different ways, but none of them worked:
rule "Anzahl der eingeschalteten Radios"
when
Item GroupRadioControl changed
then
ItemRadioPlayerCount.postUpdate(GroupRadioControl.members.filter[state == PLAY].length)
end
or
Group:Player:COUNT(PLAY) GroupRadioControl
Is there a way to achieve this - or do I approach this from a wrong angle?
I’m using OH 2.5 with the Sonos binding.
Just for the record: You could also use a rule rule for this, but it’s slightly different:
rule "Anzahl der eingeschalteten Radios"
when
Member of GroupRadioControl changed
then
ItemRadioPlayerCount.postUpdate(GroupRadioControl.members.filter[i|i.state == PLAY].size)
end
So, it’s another trigger, the filter needs to use an object and as the result of the filtering of a list is a list, you need the size of the list, not the length.