Skip to content

Commit

Permalink
### __WORK IN PROGRESS__
Browse files Browse the repository at this point in the history
* (bluefox) Corrected error with "SONOS not found"
  • Loading branch information
GermanBluefox committed Dec 20, 2021
1 parent 6e55580 commit d535c65
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Workaround for text to speech is to use the [SONOS HTTP API](https://github.com/
### __WORK IN PROGRESS__
-->
## Changelog
### 2.1.6 (2021-12-20)
### __WORK IN PROGRESS__
* (bluefox) Corrected error with "SONOS not found"

### 2.1.4 (2021-12-17)
Expand Down
2 changes: 2 additions & 0 deletions io-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@
"readme": "https://github.com/ioBroker/ioBroker.sonos/blob/master/README.md",
"enabled": true,
"compact": true,
"connectionType": "local",
"dataSource": "push",
"icon": "sonos.png",
"dependencies": [
{
Expand Down
29 changes: 22 additions & 7 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,18 @@ function startAdapter(options) {
adapter.setState && aliveIds.forEach(id =>
adapter.setState(id, false, true));

channels && Object.keys(channels).forEach(ip => {
if (channels[ip] && channels[ip].elapsedTimer) {
clearInterval(channels[ip].elapsedTimer);
channels[ip].elapsedTimer = null;
}

if (channels[ip] && channels[ip].timerVolume) {
clearTimeout(channels[ip].timerVolume);
channels[ip].timerVolume = null;
}
});

adapter.log && adapter.log.info && adapter.log.info('terminating');
}

Expand Down Expand Up @@ -1263,12 +1275,13 @@ function takeSonosState(ip, sonosState) {
channels[ip].elapsedTimer = setInterval(ip_ =>{
channels[ip_].elapsed += ((adapter.config.elapsedInterval || 5000) / 1000);

if (channels[ip_].elapsed > channels[ip_].duration) channels[ip_].elapsed = channels[ip_].duration;
if (channels[ip_].elapsed > channels[ip_].duration) {
channels[ip_].elapsed = channels[ip_].duration;
}

adapter.setState({device: 'root', channel: ip, state: 'seek'}, {val: Math.round((channels[ip_].elapsed / channels[ip_].duration) * 1000) / 10, ack: true});
adapter.setState({device: 'root', channel: ip, state: 'current_elapsed'}, {val: channels[ip_].elapsed, ack: true});
adapter.setState({device: 'root', channel: ip, state: 'current_elapsed_s'}, {val: toFormattedTime(channels[ip_].elapsed), ack: true});

}, adapter.config.elapsedInterval || 5000, ip);
}
} else {
Expand Down Expand Up @@ -1708,16 +1721,18 @@ function processSonosEvents(event, data) {
channels[ip].uuid = data.uuid;
adapter.setState({device: 'root', channel: ip, state: 'volume'}, {val: data.newVolume, ack: true});
player._volume = data.newVolume;
adapter.log.debug('volume: Volume for ' + player.baseUrl + ': ' + data.newVolume);
adapter.log.debug(`volume: Volume for ${player.baseUrl}: ${data.newVolume}`);

channels[ip].timerVolume = setTimeout(_ip => {
channels[_ip].timerVolume = null;

setTimeout(() => {
adapter.setState({
device: 'root',
channel: ip,
channel: _ip,
state: 'group_volume'
}, {val: player.groupState.volume, ack: true});
adapter.log.debug('group_volume: groupVolume for ' + player.baseUrl + ': ' + player.groupState.volume);
}, 2000);
adapter.log.debug(`group_volume: groupVolume for ${player.baseUrl}: ${player.groupState.volume}`);
}, 2000, ip);
}
}
} else if (event === 'mute') {
Expand Down
6 changes: 0 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@
],
"author": "bluefox <[email protected]>",
"homepage": "https://github.com/ioBroker/ioBroker.sonos",
"licenses": [
{
"type": "MIT",
"url": "https://github.com/ioBroker/ioBroker.sonos/blob/master/LICENSE"
}
],
"keywords": [
"ioBroker",
"SONOS"
Expand Down

0 comments on commit d535c65

Please sign in to comment.