ioBroker / ioBroker.sonos

Control and monitor SONOS player from ioBroker
MIT License
37 stars 19 forks source link

Fix sayit adapter compatibility #176

Open Marty56 opened 2 years ago

Marty56 commented 2 years ago

The sonos adapter does not work with the Sayit Adapter. This is an open issue for at least 4 years and has been documented extensively in the past. So I will refrain from doing this again.

The proposed workaround using HTTP Sonos API has several draw backs and is not really a good solution.

  1. The HTTP Sonos API module is not maintained anymore and contains various severe security flaws. Thereby, it compromises overall security of any system installing this module.
  2. It is also complicated to use and install.

It would be really appreciated if the sonos Adapter could fix the compatibility issues with the sayit adapter.

Marty56 commented 2 years ago

Since I have a samba server running on my server anyway, I have created a workaround not having to use the HTTP Sonos API. Preparation

  1. first configured the samba server to point to the folder "/opt/iobroker/iobroker-data/sayit" and created a samba user "iobroker"
  2. then I added this newly created SMB share to the Sonos music library
  3. after Sonos has parsed this new music library, I created sonos favourites referencing the file "sayit.0.say.mp3"
  4. then I configured the sayit adapter to play on "Browser". Since I have no sound device attached to my server, this only creates the sound file but no sound. The sayit Adapter has to be in instance "0".

in the Javascript

//--- Sonos workaround
var sonos_fav_play = false
var sonos_prev_vol = 10
function play_sonos_fav(fav,vol) {
    sonos_fav_play = true
    sonos_prev_vol = getState('sonos.0.root.192_168_10_32.volume').val
    setStateDelayed('sonos.0.root.192_168_10_32.volume',vol,2000 )
    setStateDelayed('sonos.0.root.192_168_10_32.favorites_set',fav,3000)
}

// restore old volume
on({ id: "sonos.0.root.192_168_10_32.state_simple", change: "lt" }, function (obj) {
    if (sonos_fav_play == true) {
        setState('sonos.0.root.192_168_10_32.volume',sonos_prev_vol)
        sonos_fav_play = false
    } 
})
/* Example how to call the workaround
setState('sayit.0.tts.text',"this is a test" )
play_sonos_fav('sayit.0.say.mp3',80)
*/

For other sound files, like the doorbell or an alarm bell, I copied those files to the "/opt/iobroker/iobroker-data/sayit" and created favourites for each of those sound files. e.g. playing the sound file 'alarm.mp3'

play_sonos_fav('alarm.mp3',100)

This is a really bloody workaround but it avoids using the outdated and insecure HTTP Sonos API Server. Please note: If you using Redis, this will not work because the sayit sound file will not be updated in the folder. Also note: If your sonos is a playbar and was used for playing the sound of a TV attached via the TOSLINK, the TV volume is muted after using this workaround. You have to use the volume rocker on the TV remote to bring TV sound back. Unfortunately the sonos adapter does not support the enabling of the TV input of the sonos playbar.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 7 days. Please check if the issue is still relevant in the most current version of the adapter and tell us. Also check that all relevant details, logs and reproduction steps are included and update them if needed. Thank you for your contributions. Dieses Problem wurde automatisch als veraltet markiert, da es in letzter Zeit keine Aktivitäten gab. Es wird geschlossen, wenn nicht innerhalb der nächsten 7 Tage weitere Aktivitäten stattfinden. Bitte überprüft, ob das Problem auch in der aktuellsten Version des Adapters noch relevant ist, und teilt uns dies mit. Überprüft auch, ob alle relevanten Details, Logs und Reproduktionsschritte enthalten sind bzw. aktualisiert diese. Vielen Dank für Eure Unterstützung.