Is there a simple to get a count of the currently active children in a Universal Media Player entity?
For a group of Sonos speakers containing several which are playing, with the template:
active_child: {{ (state_attr('media_player.sonos_all_inside', 'active_child')) }}
group_members: {{ (state_attr('media_player.sonos_all_inside', 'group_members')) }}
I get:
active_child: media_player.dining_room
group_members: None
As an indirect workaround, I’m instead counting the Sonos group members of the Universal active_child
. That works; It just seems like there should be a more straightforward way.
group_members list: {{ (state_attr((state_attr('media_player.sonos_all_inside', 'active_child')), 'group_members'))|list }}
group_members count: {{ (state_attr((state_attr('media_player.sonos_all_inside', 'active_child')), 'group_members'))|list|count }}
Which results in:
group_members list: ['media_player.dining_room', 'media_player.living_room', 'media_player.master_bedroom', 'media_player.study', 'media_player.guest_room', 'media_player.library', 'media_player.kitchen']
group_members count: 7