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

Fix secondary russound controller discovery failure #123590

Merged
merged 2 commits into from
Aug 12, 2024

Conversation

noahhusby
Copy link
Contributor

@noahhusby noahhusby commented Aug 11, 2024

Proposed change

⚠️ This bug fix should be included in patch release 2024.8.2.

One of the supported configurations for Russound is to have a primary controller linked to Home Assistant over LAN with secondary controllers linked to the primary via serial. The current code uses the mac address of each controller to create the device info for each unit. Unfortunately, the mac address can only be retrieved for the primary controller in a stack, so the current system won't work.

This change makes it so that the unique ID of the linked controllers is comprised of {primary-controller-mac-addr}-{linked-controller-id} so that the linked controllers can still be listed as devices.

Explanation of changes:

  • The primary_mac_address variable represents the mac_address of the primary controller. When mac_address of the controller object is None, then the parent_controller.mac_address variable will be non-null. (The library ensures that this is the case, so primary_mac_address will always be non-null).
  • The attr_unique_id variable is immune to the changes since the zone.device_str() includes both the controller id and zone id.
    • For example: Controller 1, Zone 1 will be {primary_mac_addr}-{C[1].Z[1]} and Controller 2, Zone 1 will be {primary_mac_addr}-{C[2].Z[1]}
  • The device_identifier variable is set to the mac_address if it's the primary controller, otherwise it's set to {primary_mac_addr}-{linked_controller_id}
  • The device_info connections assignment is set only if it's the primary controller. (We know if a controller is primary if self._controller.parent_controller is None).

How this functions if the stack-up changes:

This theoretically introduces issues if the order of the controllers were to be updated. In the case of the Russound stack-up, most of the configuration options are on the primary controller and are propagated to the linked controllers. No matter whether the linked devices were able to be identified by mac address, there is going to be some amount of clean up to do if the Russound configuration changes.

Diff: noahhusby/aiorussound@2.2.2...2.2.3

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

@noahhusby noahhusby force-pushed the fix/russound-linked-controllers branch from 07a2527 to 6b5a690 Compare August 11, 2024 19:32
@noahhusby noahhusby marked this pull request as ready for review August 11, 2024 19:32
Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

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

Thanks for bumping the dependency! However, could you please update the PR description to contain at least one (or multiple) of the following:

  • A link to the release notes of this package version, and all versions in between.
  • A link to the changelog of this package.
  • A link to a Git(Hub) diff/compare view from the current version to the bumped version.

This allows us to review upstream changes, which is needed to decide this change is working as intended and/or if we can include it in, for example, a patch release of Home Assistant.

Thanks already! 👍

@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant home-assistant bot marked this pull request as draft August 12, 2024 19:36
@noahhusby
Copy link
Contributor Author

Completely thought I linked that. Here's the diff: noahhusby/aiorussound@2.2.2...2.2.3

@noahhusby noahhusby marked this pull request as ready for review August 12, 2024 19:41
@home-assistant home-assistant bot requested a review from frenck August 12, 2024 19:41
Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

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

Thanks, @noahhusby 👍

../Frenck

@frenck frenck added this to the 2024.8.2 milestone Aug 12, 2024
@frenck frenck merged commit 7cf5d12 into home-assistant:dev Aug 12, 2024
39 of 40 checks passed
@noahhusby noahhusby deleted the fix/russound-linked-controllers branch August 12, 2024 19:47
@github-actions github-actions bot locked and limited conversation to collaborators Aug 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants