Repository: happyleavesaoc/python-snapcast

Issue:
[discussion] Group friendly name
At the moment the friendly name of a group is either the name (if manually set) or the stream name: `return self.name if self.name != '' else self.stream`
By default there are no names set and multiple groups could have the same stream, thus showing the same friendly name. In my opinion this makes sense only if someone is using exactly one group per stream and in that case one could set the group name manually.
So I would propose to change the fall-back to either the group id or a combination of client names.

Discussion:

Patch:
diff --git a/snapcast/control/group.py b/snapcast/control/group.py
index 47999ea..1000a69 100644
--- a/snapcast/control/group.py
+++ b/snapcast/control/group.py
@@ -105,7 +105,8 @@ class Snapgroup():
     @property
     def friendly_name(self):
         """Get friendly name."""
-        return self.name if self.name != '' else self.stream
+        return self.name if self.name != '' else "+".join(
+            sorted([self._server.client(c).friendly_name for c in self.clients]))
 
     @property
     def clients(self):


Test patch:
diff --git a/tests/test_group.py b/tests/test_group.py
index 3139dca..5c3563b 100644
--- a/tests/test_group.py
+++ b/tests/test_group.py
@@ -27,6 +27,7 @@ class TestSnapgroup(unittest.TestCase):
         client.volume = 50
         client.callback = MagicMock()
         client.update_volume = MagicMock()
+        client.friendly_name = 'A'
         server.streams = [stream]
         server.stream = MagicMock(return_value=stream)
         server.client = MagicMock(return_value=client)
@@ -35,7 +36,7 @@ class TestSnapgroup(unittest.TestCase):
     def test_init(self):
         self.assertEqual(self.group.identifier, 'test')
         self.assertEqual(self.group.name, '')
-        self.assertEqual(self.group.friendly_name, 'test stream')
+        self.assertEqual(self.group.friendly_name, 'A+A')
         self.assertEqual(self.group.stream, 'test stream')
         self.assertEqual(self.group.muted, False)
         self.assertEqual(self.group.volume, 50)