Sonos identify existing Zone Group

Hi there,

I am thinking about automatically creating zone-groups or add players to existing ones. The process itself is quite simple to describe, but I am a little stuck in understanding the grouping-functions for Sonos:

  • A trigger for a player that is not in state “playing” is executed
  • If there is allready a group: add this player to the group
  • If there is no group but a single player is playing, create a group.
  • If no player is playing anything, do nothing.

My setup consists of three players and I assume that there will never be two players playing different things at the same time. So this situation does not have to be handled for the moment.

I think that I will need a function that determines the preconditions and returns the name of the ZonePlayer to add the new player to. But how to determine the preconditions? And how to determine if a player is member of a group?

Thanks in advance for any kind of help!

Kind regards