Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distribute volume adjustments in partymode #13

Open
petteraas opened this issue Apr 13, 2014 · 4 comments
Open

Distribute volume adjustments in partymode #13

petteraas opened this issue Apr 13, 2014 · 4 comments

Comments

@petteraas
Copy link
Member

Wasn't entirely sure how to name this, but I tend to keep my speakers in partymode, and then when I adjust the volume, I usually want to keep the same volume across the 'party', today this implies running the same command again per speaker.

There are of course multiple ways this can functionally work, I like the way it's done in the official Android app where the default in partymode is to adjust all speakers, while you still can adjust them individually.

I think we can either add a separate 'partyVolume' command or change behaviour of volume based on a boolean partymode state, but if we change this behaviour, should it then somehow still be possible to adjust only one specified speaker?

I believe any solution we end up with involves checking the topologies to find the master node and all the slaves, then adjust them all with the given factor?

@DPH
Copy link
Member

DPH commented Apr 13, 2014

Hi, in GroupRenderingControl there is the upnp command to SetGroupVolume. This has to be used on the master of the group but then adjusts the volume on all zones in that group. It woks like the controller does - however if you read formums lots of people are confused by how it works! http://forums.sonos.com/showthread.php?t=36960

Cheers David

@petteraas
Copy link
Member Author

SetGroupVolume is probably the way to go, but for volume,bass and treble this seems to work quite nice

diff --git i/socos/mixer.py w/socos/mixer.py
index 7b356fe..90767be 100644
--- i/socos/mixer.py
+++ w/socos/mixer.py
@@ -8,10 +8,18 @@ def _adjust_setting(soco, attr, operator, min_val, max_val):
     val = getattr(soco, attr)
     newval = in_range(val + factor, min_val, max_val)
     setattr(soco, attr, newval)
+    _distribute_setting(soco, attr, newval)

     return getattr(soco, attr)


+def _distribute_setting(soco, attr, newval):
+    if soco.group.coordinator.ip_address == soco.ip_address:
+        for speaker in soco.visible_zones:
+            if speaker.ip_address != soco.ip_address:
+                setattr(speaker, attr, newval)
+
+
 def adjust_volume(soco, operator):
     """ Adjust the volume up or down with a factor from 1 to 100 """
     return _adjust_setting(soco, 'volume', operator, 0, 100)

it should probably be a separate command though, as you might not always want to distribute it, and I guess the 'if soco.group.coordinator.ip_address == soco.ip_address:' isn't really needed as you can also find members from a slave. I'll ponder a bit more on it before pushing any changes.

@lawrenceakka
Copy link

You don't need to compare IP addresses. Just compare the instances:

If soco.group.coordinator is soco:
    # do stuff

@petteraas
Copy link
Member Author

@lawrenceakka thanx :)

looks like I can also do the negation with if speaker is not soco: to find slaves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants