Skip to content

Commit

Permalink
Fix display issue where groups started to appear for no reason
Browse files Browse the repository at this point in the history
  • Loading branch information
tbouron committed Jan 25, 2020
1 parent ab40632 commit 3c175e5
Showing 1 changed file with 32 additions and 29 deletions.
61 changes: 32 additions & 29 deletions MMM-Sonos.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,48 +23,51 @@ Module.register('MMM-Sonos', {

socketNotificationReceived: function (id, payload) {
Log.log(`Notification received: ${id}`, payload);
let currentItem;

switch (id) {
case 'SET_SONOS_GROUPS':
this.items = payload;
this.updateDom(this.config.animationSpeed);
break;
case 'SET_SONOS_CURRENT_TRACK':
currentItem = this.items.hasOwnProperty(payload.group.ID) ? this.items[payload.group.ID] : {};
this.items[payload.group.ID] = {
...currentItem,
group: payload.group,
track: payload.track,
};
this.updateDom(this.config.animationSpeed);
if (this.items.hasOwnProperty(payload.group.ID)) {
this.items[payload.group.ID] = {
...this.items[payload.group.ID],
group: payload.group,
track: payload.track,
};
this.updateDom(this.config.animationSpeed);
}
break;
case 'SET_SONOS_VOLUME':
currentItem = this.items.hasOwnProperty(payload.group.ID) ? this.items[payload.group.ID] : {};
this.items[payload.group.ID] = {
...currentItem,
group: payload.group,
volume: payload.volume
};
this.updateDom();
if (this.items.hasOwnProperty(payload.group.ID)) {
this.items[payload.group.ID] = {
...this.items[payload.group.ID],
group: payload.group,
volume: payload.volume
};
this.updateDom();
}
break;
case 'SET_SONOS_MUTE':
currentItem = this.items.hasOwnProperty(payload.group.ID) ? this.items[payload.group.ID] : {};
this.items[payload.group.ID] = {
...currentItem,
group: payload.group,
isMuted: payload.isMuted
};
this.updateDom();
if (this.items.hasOwnProperty(payload.group.ID)) {
this.items[payload.group.ID] = {
...this.items[payload.group.ID],
group: payload.group,
isMuted: payload.isMuted
};
this.updateDom();
}
break;
case 'SET_SONOS_PLAY_STATE':
currentItem = this.items.hasOwnProperty(payload.group.ID) ? this.items[payload.group.ID] : {};
this.items[payload.group.ID] = {
...currentItem,
group: payload.group,
state: payload.state
};
this.updateDom(this.config.animationSpeed);
if (this.items.hasOwnProperty(payload.group.ID)) {
this.items[payload.group.ID] = {
...this.items[payload.group.ID],
group: payload.group,
state: payload.state
};
this.updateDom(this.config.animationSpeed);
}
break;
default:
Log.info(`Notification with ID "${id}" unsupported. Ignoring...`);
Expand Down

0 comments on commit 3c175e5

Please sign in to comment.