From 8048f6ddb30fc0d8253a445a8181e7a10f6ae33a Mon Sep 17 00:00:00 2001 From: seb2010 <57917445+seb2010@users.noreply.github.com> Date: Wed, 28 Feb 2024 22:17:53 +0100 Subject: [PATCH 1/2] added bass and treble control (only writing, not possible to listen on external bass/treble changes yet) --- main.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/main.js b/main.js index dd2f33f..05cf7aa 100644 --- a/main.js +++ b/main.js @@ -148,6 +148,10 @@ function startAdapter(options) { } } else if (id.state === 'volume') { promise = player.setVolume(state.val); + } else if (id.state === 'treble') { + promise = player.setTreble(state.val); + } else if (id.state === 'bass') { + promise = player.setBass(state.val); } else if (id.state === 'state') { //stop,play,pause,next,previous,mute,unmute if (state.val && typeof state.val === 'string') { @@ -608,6 +612,28 @@ async function createChannel(name, ip, room) { desc: 'State and control of volume', name: 'Player volume' }, + treble: { + // level.treble - treble level (read, write) + type: 'number', + read: true, + write: true, + role: 'level.treble', + min: -10, + max: 10, + desc: 'State and control of treble', + name: 'Player treble' + }, + bass: { + // level.bass - bass level (read, write) + type: 'number', + read: true, + write: true, + role: 'level.bass', + min: -10, + max: 10, + desc: 'State and control of bass', + name: 'Player bass' + }, muted: { // media.muted - is muted (read only) def: false, @@ -1780,6 +1806,12 @@ function processSonosEvents(event, data) { adapter.log.debug(`volume: Volume for ${player.baseUrl}: ${data.newVolume}`); } } + } else if (event === 'treble') { + // node-sonos-discovery is not emitting any events on treble changes yet, so it is not + // possible to get the externally set treble value, yet. + } else if (event === 'bass') { + // node-sonos-discovery is not emitting any events on bass changes yet, so it is not + // possible to get the externally set bass value, yet. } else if (event === 'mute') { // { // uuid: _this.uuid, From 8ddb3c04774eae4b058accb777be7cd1667d3903 Mon Sep 17 00:00:00 2001 From: seb2010 <57917445+seb2010@users.noreply.github.com> Date: Thu, 29 Feb 2024 14:21:53 +0100 Subject: [PATCH 2/2] added Readme comment, change state to write-only --- README.md | 5 +++++ main.js | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 540da64..0688d30 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,11 @@ Please note: highlighting current playing favorite is not supported. ### **WORK IN PROGRESS** --> ## Changelog + +### WORK IN PROGRESS + +(seb2010) Added support to control bass and treble of a player (NO updates of these states on external events!) + ### 3.0.0 (2023-10-09) * (udondan) Added support for the playing Sonos playlists (added new state `playlist_set`) * (bluefox) The minimal node.js version is 16 diff --git a/main.js b/main.js index 05cf7aa..f387add 100644 --- a/main.js +++ b/main.js @@ -613,9 +613,9 @@ async function createChannel(name, ip, room) { name: 'Player volume' }, treble: { - // level.treble - treble level (read, write) + // level.treble - treble level (only write) type: 'number', - read: true, + read: false, write: true, role: 'level.treble', min: -10, @@ -624,9 +624,9 @@ async function createChannel(name, ip, room) { name: 'Player treble' }, bass: { - // level.bass - bass level (read, write) + // level.bass - bass level (only write) type: 'number', - read: true, + read: false, write: true, role: 'level.bass', min: -10,