pub struct Group {
pub id: GroupId,
pub coordinator_id: SpeakerId,
pub member_ids: Vec<SpeakerId>,
pub volume: GroupVolumeHandle,
pub mute: GroupMuteHandle,
pub volume_changeable: GroupVolumeChangeableHandle,
/* private fields */
}Expand description
Group handle with access to coordinator and members
Provides access to group information and member speakers. All speakers are always in a group - a single speaker forms a group of one.
§Example
// Get all groups
for group in system.groups() {
println!("Group: {} ({} members)", group.id, group.member_count());
if let Some(coordinator) = group.coordinator() {
println!(" Coordinator: {}", coordinator.name);
}
for member in group.members() {
let role = if group.is_coordinator(&member.id) { "coordinator" } else { "member" };
println!(" - {} ({})", member.name, role);
}
}Fields§
§id: GroupIdUnique group identifier
coordinator_id: SpeakerIdCoordinator speaker ID
member_ids: Vec<SpeakerId>All member speaker IDs (including coordinator)
volume: GroupVolumeHandleGroup volume (0-100)
mute: GroupMuteHandleGroup mute state
volume_changeable: GroupVolumeChangeableHandleWhether group volume can be changed (event-only, no fetch)
Implementations§
Source§impl Group
impl Group
Sourcepub fn coordinator(&self) -> Option<Speaker>
pub fn coordinator(&self) -> Option<Speaker>
Get the coordinator speaker
Returns the Speaker handle for the group’s coordinator.
Returns None if the coordinator speaker is not found in state.
§Example
if let Some(coordinator) = group.coordinator() {
println!("Coordinator: {}", coordinator.name);
// Control playback via coordinator
let state = coordinator.playback_state.get();
}Sourcepub fn is_coordinator(&self, speaker_id: &SpeakerId) -> bool
pub fn is_coordinator(&self, speaker_id: &SpeakerId) -> bool
Sourcepub fn member_count(&self) -> usize
pub fn member_count(&self) -> usize
Sourcepub fn is_standalone(&self) -> bool
pub fn is_standalone(&self) -> bool
Sourcepub fn add_speaker(&self, speaker: &Speaker) -> Result<(), SdkError>
pub fn add_speaker(&self, speaker: &Speaker) -> Result<(), SdkError>
Add a speaker to this group
Sends SetAVTransportURI to the member speaker with x-rincon:{coordinator_id}
to join the coordinator’s audio stream. This is the standard Sonos grouping mechanism.
After calling this, re-fetch groups via system.groups() to see updated membership.
Sourcepub fn remove_speaker(&self, speaker: &Speaker) -> Result<(), SdkError>
pub fn remove_speaker(&self, speaker: &Speaker) -> Result<(), SdkError>
Remove a speaker from this group
Sends BecomeCoordinatorOfStandaloneGroup to the member speaker, causing it
to leave the group and become standalone. Cannot remove the coordinator.
Sourcepub fn dissolve(&self) -> GroupChangeResult
pub fn dissolve(&self) -> GroupChangeResult
Dissolve this group by removing all non-coordinator members
Attempts to remove every non-coordinator member, even if some fail.
Returns a GroupChangeResult showing which speakers were successfully
removed and which failed. For standalone groups, returns an empty result.
Sourcepub fn set_volume(&self, volume: u16) -> Result<(), SdkError>
pub fn set_volume(&self, volume: u16) -> Result<(), SdkError>
Set group volume (0-100)
Updates the state cache to the new GroupVolume on success.
Sourcepub fn set_relative_volume(
&self,
adjustment: i16,
) -> Result<SetRelativeGroupVolumeResponse, SdkError>
pub fn set_relative_volume( &self, adjustment: i16, ) -> Result<SetRelativeGroupVolumeResponse, SdkError>
Adjust group volume relative to current level
Returns the new absolute volume.
Sourcepub fn set_mute(&self, muted: bool) -> Result<(), SdkError>
pub fn set_mute(&self, muted: bool) -> Result<(), SdkError>
Set group mute state
Updates the state cache to the new GroupMute value on success.
Sourcepub fn snapshot_volume(&self) -> Result<(), SdkError>
pub fn snapshot_volume(&self) -> Result<(), SdkError>
Snapshot the current group volume (for later restore)