Skip to content

fix: SonosDevice.GroupId never updates after initial group setup - #225

Merged
svrooij merged 1 commit into
svrooij:mainfrom
rocklobster42195:fix/group-id-typo
Jul 6, 2026
Merged

fix: SonosDevice.GroupId never updates after initial group setup#225
svrooij merged 1 commit into
svrooij:mainfrom
rocklobster42195:fix/group-id-typo

Conversation

@rocklobster42195

Copy link
Copy Markdown
Contributor

Problem

SonosDevice.handleGroupUpdate() checks data.groupdId (typo, extra "d"), but SonosManager emits the field as groupId everywhere it builds the group-update payload. The condition is therefore always false, so GroupId stays frozen at whatever value was passed into the constructor at InitializeWithGroups() time and never reflects a later regroup or coordinator change - unlike .Coordinator, .GroupName and .IsCoordinator, which all update correctly via the same event path.

Fix

Corrected the property name in handleGroupUpdate's parameter type and body so it reads data.groupId, matching what SonosManager actually sends.

Testing

Added a test under "Group options in constructor" mirroring the existing "Updates group name" test, verifying GroupId is set from the constructor and updates when the manager emits a new value.

Not a breaking change - this only makes an already-documented property behave as intended.

handleGroupUpdate() checked data.groupdId (typo) while SonosManager
emits the field as groupId, so the condition was always false and
GroupId stayed frozen at its initial value after any regroup or
coordinator change, unlike Coordinator/GroupName/IsCoordinator which
update correctly via the same event path.
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 28782159916

Coverage increased (+0.2%) to 73.564%

Details

  • Coverage increased (+0.2%) from the base build.
  • Patch coverage: 2 of 2 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 2171
Covered Lines: 1619
Line Coverage: 74.57%
Relevant Branches: 1207
Covered Branches: 866
Branch Coverage: 71.75%
Branches in Coverage %: Yes
Coverage Strength: 67.86 hits per line

💛 - Coveralls

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes SonosDevice.GroupId not updating after initial construction by correcting a payload property typo in the group-update handler, and adds a regression test to ensure GroupId updates when the manager emits new group data.

Changes:

  • Fix handleGroupUpdate to read data.groupId (instead of data.groupdId) so GroupId updates correctly.
  • Add a unit test verifying GroupId is set from constructor options and updates on subsequent group-update events.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/sonos-device.ts Fixes group update handler to consume groupId, enabling GroupId to change after regroup/coordinator changes.
src/tests/sonos-device.test.ts Adds regression coverage ensuring GroupId updates via the manager event path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/sonos-device.ts
private boundHandleGroupUpdate = this.handleGroupUpdate.bind(this);

private handleGroupUpdate(data: { coordinator: SonosDevice | undefined; name: string; groupdId: string | undefined }): void {
private handleGroupUpdate(data: { coordinator: SonosDevice | undefined; name: string; groupId: string | undefined }): void {
@svrooij
svrooij merged commit 31a13f5 into svrooij:main Jul 6, 2026
6 checks passed
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.

4 participants