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

Add properties for surround speakers in TV, music and ambient modes #780

Merged
merged 10 commits into from Feb 20, 2022

Conversation

rytilahti
Copy link
Contributor

@rytilahti rytilahti commented Dec 27, 2020

Adds following (setable) properties (see https://support.sonos.com/s/article/4804?language=en_US):

  • surround_mode: surround enabled/disabled (already done in Add sub & surround properties and controls #870)
  • surround_ambient_enabled: ambient/full volume in the music mode (bool)
  • surround_volume_tv: surround volume adjustment [-15,15] for the tv mode (int)
  • surround_volume_music: surround volume adjustment [15,15] for the music mode (int)

Currently missing reseting to defaults, and adjusting the surround speaker balance (which can only be done when trueplay is disabled, see #646 (review)).

Obsoletes #646. Fixes #461.

@rytilahti
Copy link
Contributor Author

Just a side note, after doing some testing (and XML checking), it looks like that changes to the audio input format is not sending events -> requires polling to get this information :-(

@rytilahti
Copy link
Contributor Author

@pwt do you mind giving this one a quick review? What do you think should be done to get this closer to get merged? Something besides fixing the docstrings & separating the soundbar_audio_input_format?

@pwt pwt self-assigned this May 16, 2021
soco/core.py Outdated Show resolved Hide resolved
soco/core.py Outdated Show resolved Hide resolved
@pwt
Copy link
Contributor

pwt commented May 18, 2021

@pwt do you mind giving this one a quick review? What do you think should be done to get this closer to get merged? Something besides fixing the docstrings & separating the soundbar_audio_input_format?

This is a great. I've made a couple of comments: if you can push a new commit with the f-string replaced, that should initiate a check job run to spot any hygiene issues.

One problem I have is that I'm not able to test this code, since none of my Sonos equipment is set up in HT configs, so I'd love to get a some other folks to try it out.

soco/core.py Outdated Show resolved Hide resolved
soco/core.py Outdated Show resolved Hide resolved
soco/services.py Outdated Show resolved Hide resolved
@rytilahti
Copy link
Contributor Author

Thanks @pwt! I added some responses in the comments, and also created a separate PR (#832) for the audio input format so that's why I force-pushed this branch.

I was working to add tests to the functionality when I realized that the helper methods I introduced makes testing the API interface more complicated thanks to indirection. I'll have to look for a suitable solution for that, I'm open for suggestions!

@coveralls
Copy link

coveralls commented May 18, 2021

Coverage Status

Coverage increased (+0.08%) to 54.254% when pulling 1b34036 on rytilahti:feat/add_surround_options into d1744f8 on SoCo:master.

@pwt pwt modified the milestones: 0.23.0, 0.24.0 Jul 6, 2021
@pwt
Copy link
Contributor

pwt commented Jul 8, 2021

I was working to add tests to the functionality when I realized that the helper methods I introduced makes testing the API interface more complicated thanks to indirection. I'll have to look for a suitable solution for that, I'm open for suggestions!

I may not have understood this fully, but I'd be minded to keep the unit tests simple and just pattern them after the existing tests for simple getters/setters.

@pwt pwt modified the milestones: 0.24.0, 0.25.0 Sep 1, 2021
@pwt pwt modified the milestones: 0.25.0, 0.26.0 Dec 3, 2021
@pwt pwt modified the milestones: 0.26.0, 0.27.0 Jan 23, 2022
Adds following (setable) properties (see https://support.sonos.com/s/article/4804?language=en_US):
* surround_mode: surround enabled/disabled
* surround_mode_music_playback: ambient/full volume in the music mode
* surround_volume_tv: surround volume adjustment [-15,15] for the tv mode
* surround_volume_music: surround volume adjustment [15,15] for the music mode

Missing settings for reseting to defaults, and adjusting the surround speaker balance (which can only be done when trueplay is disabled)
@rytilahti rytilahti changed the title [WIP/RFC] Improve soundbar support Improve soundbar support Feb 16, 2022
@rytilahti
Copy link
Contributor Author

Oops, looks like I forgot to push this earlier, but I think this should be good to go now. Mind taking a look @pwt & @jjlawren?

I added tests to all surround properties (including the already existing surround_enabled) and renamed the surround_music_playback to surround_ambient_enabled.

edit: pre-commit config pins down to a version that's different from what's used by the CI, that's why all the hassle with force pushes, sorry for that. pre-commit autoupdate should be run to pin the version to the newest, opinions on whether it should be done in this PR or in a separate one?

@pwt
Copy link
Contributor

pwt commented Feb 17, 2022

Thanks for following up on this. I'll take a look in the next day or two.

@pwt
Copy link
Contributor

pwt commented Feb 19, 2022

Hi @rytilahti . I've reviewed the code and it looks good. I've also pushed a couple of suggested commits that:

  1. Fix a docstring reference error and tidy up some of the doctstring text.
  2. Remove the type hints. (I'm an advocate of using typing, but I think we should maintain consistency with the rest of the SoCo codebase until such time as we decide to add typing more universally.)

Please review and check that the changes look OK to you.

Unfortunately, I'm not able to test this PR properly as I don't have any Sonos HT setups, so I'll have to depend on the testing that you and others are able to do.

@rytilahti
Copy link
Contributor Author

Hi @pwt and thanks for the review and the changes you made, looks good to me! I re-tested all the new settings on my Beam setup with the most current software and they work as expected.

@pwt pwt changed the title Improve soundbar support Add properties for surround speakers in TV, music and ambient modes Feb 20, 2022
@pwt
Copy link
Contributor

pwt commented Feb 20, 2022

@rytilahti Great! Thanks for the contribution.

@pwt pwt merged commit 52b798f into SoCo:master Feb 20, 2022
@rytilahti rytilahti deleted the feat/add_surround_options branch February 20, 2022 18:15
@surround_ambient_enabled.setter
@only_on_soundbars
def surround_ambient_enabled(self, value):
"""Toggle surround music playback mode. True = ambient mode.
Copy link
Contributor Author

@rytilahti rytilahti Feb 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized that having the ambient mode as True makes using the eventing API awkward (ambient mode is report as 0), so this may need to be changed to be other way around. IIRC I didn't do it previously as I couldn't think of a good name for the "full mode". Maybe surround_full_volume_enabled?

Comment on lines +1379 to +1380
if variable == "SurroundMode": # negate desired value for surround mode
desired_value = not value
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be removed if the surround mode would be reversed.

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

Successfully merging this pull request may close these issues.

Surround Sound Mode
3 participants