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 support for favorites #37

Open
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

archiconda1976
Copy link

Updated to add a favorites class.
Updated to allow for json responses, which is needed for Russound Media Management menu responses.

@noahhusby
Copy link
Owner

Thanks for your contribution 🎉

Just a few notes on initial review:

  1. Let's keep the PR to just one topic, favorites in this case. Please remove the Media Management implementation. This will work out anyways since I'm currently writing a full media management implementation anyways.
  2. Remove the .vscode files from your commit. Feel free to create another PR to add the .vscode folder to .gitignore to prevent it from being tracked in the future.

Let's go from there and then I can re-review.

@noahhusby
Copy link
Owner

Also, out of curiosity, which controller are you testing with?

.vs/aiorussound/v16/.suo Outdated Show resolved Hide resolved
@noahhusby noahhusby marked this pull request as draft September 23, 2024 01:02
@archiconda1976
Copy link
Author

archiconda1976 commented Sep 23, 2024

Also, out of curiosity, which controller are you testing with?

Running a MCA-88X and 2 MCA-88s along with 2 MBX-PRE and a ST-1 AM/FM tuner as Russound sources (amongst some other analog sources).

I have also been testing media_player.py code updates on the HA end that implements the "Browse Media" and the Russound Media Management menu system. I've been planning on cleaning that code up and doing some pull requests once this library had all the needed feature additions. I'd like to help out in the media management support if you need coding or testing help.

Committed in error
Rollback json field added to RussoundMessage class
Rollback json handling addition
Rollback message json addition
Clean up unneeded whitespace changes
More whitespace corrections
@archiconda1976 archiconda1976 marked this pull request as ready for review September 23, 2024 02:24
aiorussound/models.py Outdated Show resolved Hide resolved
aiorussound/models.py Outdated Show resolved Hide resolved
ZONE_PROPERTIES: list[str] = ["currentSource"]
ZONE_PROPERTIES: list[str] = [
"currentSource",
"favorite[1].valid",
Copy link
Owner

Choose a reason for hiding this comment

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

Why are we loading these values into the cache on connection? The enumerate command will typically fetch these values directly instead of grabbing them from the cache.

How we handle this is completely up for debate, just trying to understand it better.

Copy link
Author

Choose a reason for hiding this comment

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

No compelling reason other than it would happen during startup regardless. Since this is dependent on controller type, it doesn't make sense to pre-fetch these.

aiorussound/const.py Outdated Show resolved Hide resolved
aiorussound/rio.py Outdated Show resolved Hide resolved
aiorussound/rio.py Outdated Show resolved Hide resolved
@noahhusby noahhusby marked this pull request as draft September 23, 2024 02:38
@noahhusby
Copy link
Owner

It's looking pretty good, just a few additional changes / clarifications. I'll review again tomorrow and we should have no issue getting this merged ✅

@noahhusby noahhusby changed the title Updated to support favorites implementation Add support for favorites Sep 23, 2024
Andy Archibald and others added 3 commits September 23, 2024 18:11
@archiconda1976 archiconda1976 marked this pull request as ready for review September 23, 2024 23:19
@@ -232,6 +237,95 @@ async def init_sources(self) -> None:
except CommandError:
break

async def enumerate_zone_favorites(self, zone: Zone) -> list[Favorite]:
Copy link
Owner

Choose a reason for hiding this comment

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

To maintain the object paradigm, let's move this method to the zone class and rename it enumerate_favorites, and remove the zone parameter. It will just return the favorites for that zone.

@@ -69,3 +69,12 @@ def get_max_zones(model: str) -> int:
if model in ("MCA-66", "MCA-C3"):
return 6
return 1


def get_max_zones_favorites(model: str) -> int:
Copy link
Owner

Choose a reason for hiding this comment

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

This looks good, please add appropriate tests. Pretty identical to the method above so you can copy the test from there.

https://github.com/noahhusby/aiorussound/blob/master/tests/test_util.py

Copy link
Author

Choose a reason for hiding this comment

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

Noticed I missed the MBX models, so I added those here and in the new util test method

Andy Archibald added 2 commits September 24, 2024 17:46
@noahhusby
Copy link
Owner

@archiconda1976 Please run pre-commit run after adding the files to git to format the code (so you don't have to manually handle whitespace). If you don't have pre-commit, then do pip install pre-commit

@noahhusby
Copy link
Owner

@archiconda1976 Can you show an example of the media browser implementation of your changes on the Home Assistant side? I'm trying to plan ahead to account for presets and such and want to see how if there's a better way to store the state.

@archiconda1976
Copy link
Author

@archiconda1976 Can you show an example of the media browser implementation of your changes on the Home Assistant side? I'm trying to plan ahead to account for presets and such and want to see how if there's a better way to store the state.

Here is an example: https://github.com/archiconda1976/core/tree/feat/favorites/homeassistant/components/russound_rio for the favorite browsing and playing. I removed my media browsing code from this commit, but did not have a chance to verify it with my system tonight before pushing up. I may have time tomorrow to test it, let me know if you have any issues if you try to run it.

@noahhusby
Copy link
Owner

@archiconda1976 Awesome, this helps explain the full picture.

Can you add methods to the ZoneControlSurface for adding, deleting, and recalling favorites? (these are just wrapper methods for SendEvent). That way, you can do the validation on the library side (like the 1 < f_id < 32, and raise a RussoundError if it's outside the range.

The less validation we have to do on the HA side the better. The other way to look at it is we want to make sure this library only send safe data to the unit even if it was used independently of HA, so all calls should validate custom info.

@archiconda1976
Copy link
Author

I've added the 6 methods and also updated and did some brief testing of the HA side to use the new methods.

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.

2 participants