Skip to content

Commit

Permalink
Added support for the new default grouping functionality & support_ma…
Browse files Browse the repository at this point in the history
…ster option (#525)

* Added support for the new deafult grouping functionality of Home Assistant.
* Added a new config entry for support_master.
  • Loading branch information
micha91 authored Jul 4, 2021
1 parent 696cbff commit a3a4a69
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ See [Speaker group management](#speaker-group-management) for example usage.
- snapcast<sup>[2](#speaker_foot2)</sup>
- musiccast_yamaha<sup>[1](#speaker_foot1)</sup>
- linkplay<sup>[3](#speaker_foot3)</sup>
- media_player<sup>[4](#speaker_foot4)</sup>

| Name | Type | Default | Description |
|------|------|---------|-------------|
Expand All @@ -149,13 +150,16 @@ See [Speaker group management](#speaker-group-management) for example usage.
| show_group_count | boolean | true | Have the number of grouped speakers displayed (if any) in the card name.
| icon | string | optional | Override default group button icon *(any mdi icon)*.
| group_mgmt_entity | string | optional | Override the player entity for the group management (Useful if you use a universal media_player as your entity but still want to use the grouping feature)
| support_master | boolean | optional | Set to false if your multiroom system does not define one of the media players as master. Defaults to `true` and has not to be set to false for `squeezebox` for backward compatibility.

<a name="speaker_foot1"><sup>1</sup></a> Requires [custom component](https://github.com/ppanagiotis/pymusiccast), available in HACS.

<a name="speaker_foot2"><sup>2</sup></a> All features are not yet supported.

<a name="speaker_foot3"><sup>3</sup></a> Requires [custom component](https://github.com/nagyrobi/home-assistant-custom-components-linkplay#multiroom) for sound devices based on Linkplay chipset, available in HACS.

<a name="speaker_foot4"><sup>4</sup></a> HomeAssistant added join/unjoin services to the media_player. Future official integrations will implement these services (which are slightly different from the ones, which are already supported by this card) instead of implementing them in their own domain.

#### Speaker entity object
| Name | Type | Default | Description |
|------|------|---------|-------------|
Expand Down
1 change: 1 addition & 0 deletions src/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const PLATFORM = {
SQUEEZEBOX: 'squeezebox',
BLUESOUND: 'bluesound',
SOUNDTOUCH: 'soundtouch',
MEDIAPLAYER: 'media_player',
};

const CONTRAST_RATIO = 4.5;
Expand Down
14 changes: 13 additions & 1 deletion src/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ export default class MediaPlayerObject {
if (this.platform === PLATFORM.SQUEEZEBOX) {
return this.attr.sync_group || [];
}
if (this.platform === PLATFORM.MEDIAPLAYER) {
return this.attr.group_members || [];
}
return this.attr[`${this.platform}_group`] || [];
}

Expand Down Expand Up @@ -215,7 +218,7 @@ export default class MediaPlayerObject {
}

get supportsMaster() {
return this.platform !== PLATFORM.SQUEEZEBOX;
return this.platform !== PLATFORM.SQUEEZEBOX && this.config.speaker_group.supports_master;
}

async fetchArtwork() {
Expand Down Expand Up @@ -356,6 +359,11 @@ export default class MediaPlayerObject {
entity_id: this.entityId,
other_player: entity,
}, PLATFORM.SQUEEZEBOX);
case PLATFORM.MEDIAPLAYER:
return this.callService(e, 'join', {
entity_id: this.entityId,
group_members: entity,
}, platform);
default:
return this.callService(e, 'join', options, platform);
}
Expand All @@ -365,6 +373,10 @@ export default class MediaPlayerObject {
return this.handleSoundtouch(e, 'REMOVE_ZONE_SLAVE', entity);
case PLATFORM.SQUEEZEBOX:
return this.callService(e, 'unsync', options, PLATFORM.SQUEEZEBOX);
case PLATFORM.MEDIAPLAYER:
return this.callService(e, 'unjoin', {
entity_id: entity,
}, platform);
default:
return this.callService(e, 'unjoin', options, platform);
}
Expand Down
1 change: 1 addition & 0 deletions src/utils/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const generateConfig = (config) => {
speaker_group: {
show_group_count: true,
platform: 'sonos',
supports_master: true,
...config.sonos,
...config.speaker_group,
},
Expand Down

0 comments on commit a3a4a69

Please sign in to comment.