fix: SonosDevice.GroupId never updates after initial group setup - #225
Merged
Conversation
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.
Coverage Report for CI Build 28782159916Coverage increased (+0.2%) to 73.564%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
There was a problem hiding this comment.
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
handleGroupUpdateto readdata.groupId(instead ofdata.groupdId) soGroupIdupdates correctly. - Add a unit test verifying
GroupIdis 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.
| 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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
SonosDevice.handleGroupUpdate()checksdata.groupdId(typo, extra "d"), butSonosManageremits the field asgroupIdeverywhere it builds the group-update payload. The condition is therefore alwaysfalse, soGroupIdstays frozen at whatever value was passed into the constructor atInitializeWithGroups()time and never reflects a later regroup or coordinator change - unlike.Coordinator,.GroupNameand.IsCoordinator, which all update correctly via the same event path.Fix
Corrected the property name in
handleGroupUpdate's parameter type and body so it readsdata.groupId, matching whatSonosManageractually sends.Testing
Added a test under "Group options in constructor" mirroring the existing "Updates group name" test, verifying
GroupIdis 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.