Sonos as Spotify Connect Device (Solved via a detour)

Hi,

there are alot of questions already around this issue, but none seem to solve my problem, i am running OH 2.5 M2 and try to configure Spotify with Sonos as device.
I have the spotify bridge running and configure including the authorization.

Now i want to configure the device according to the documentation liek this
<- snip ->

Bridge spotify:player:user1 "Me" [clientId="<your client id>", clientSecret="<your client secret>"] {
  Things:
    device device1 "Device 1" [deviceName="<spotify device name>"]
    device device2 "Device 2" [deviceName="<spotify device name>"]
}

<- snip ->

however, i only see my laptop and my phone as spotify connect devices, i also see all the sonos speakers and can configure them, only not for spotify

any help ?

Cheers
Soeren

Do you mean it won’t get discovered in PaperUI? It could mean the Sonos devices are not exposed by the Spotify API and than it’s not possible to control them with the binding. This can be found out by seeing what the Spotify API returns. (If you enable TRACE logging on the binding (org.openhab.binding.spotify) it will show the list returned by Spotify).

Hi

thanks for the answer

you are right, i did not do that through TRACE, but directly against the. spotify API, and the sonos is not returned as spotify connect device.

any idea why ?

i will try to investigate that, since i get the sonos as a connect device when i try to play from my phone or laptop

Cheers
Soeren

Even after a factory reset of the sonos speakers and re-adding the spotify account, they still do not show up, i created posts in the forums at sonos and spotify about this.

Do i assume correctly that people do have this up and running ? Any help would be appreciated

Cheers
Soeren

Sonos devices aren’t exposed via Spotify api. This is a problem of the Spotify implementation of Sonos, if I recall correctly.

Hi TimO

i was under the impression that people have this working, though i am not 100% sure.

Can someone confirm, that they have this setup (sonos as spotify connect device) running ? And how did you configure that?

Cheers
Soeren

Hey @smalchow!

I really want this to work, but wasn’t able to figure it out. I stopped looking into it, after I’ve read that: https://github.com/spotify/web-api/issues/525

My use case is: play a song with a given Spotify URI on sonos device.

Hi all,

ok, i went for a different solution - openhab -> spotifyd -> mkchromecast

I documented the installation, here it is, it is not perfect and not finished

  • you can not select different rooms for the output (need more daemons for that) - but following the spotify addon documentation you will see how to do it
  • there is a noticable delay in the output (also volume control)
  • no proper startup for both, spotifyd and mkchromecast

but i think this is a good start


Spotify and Sonos with OpenHAB

Installation of spotifyd to be used as spotify connect client within the OpenHAB spotify addon.
mkchromecast for the audio output to sonos (and if you want to a chromecast)

OpenHAB: 2.5.0 M2 on Fedora 30 installed as a virtual machine
Virtualization: Proxmox 5.4
Audio Server for spotifyd and mkchromecast: Ubuntu Server 18.04.x

All systems should obviously be updated to the latest version.


1. Install mkchromecast and test output to Sonos

https://github.com/muammar/mkchromecast

Install mkchromecast, it is un the repos

#> apt-get install mkchromecast-pulseaudio

Install python dependencies as packages (thats why i chose Ubuntu and not RPM based Distros)

#> apt-get install python3.6 python3-pip python3-pychromecast python3-flask python3-psutil python3-setuptools python3-mutagen python3-gi vorbis-tools sox lame flac faac opus-tools

Install ffmpeg (if not already there)

#> apt-get install ffmpeg

Install PyQt5 (only necessary for GUI - i do not need that)

#> apt-get install python3-pyqt5

Start mkchromecast

#> mkchromecast

should suffice, after that use pavucontrol to select the mkchromecast audio sink, this is NOT necessary on a virtual machine, since there will only be this one audio sink and it is selected already

Test your output with something like

#> mpg123 SOME_MP3.mp3

Audio should play on your sonos.

If you have several devices or sonos and chromecast, you can use "-n" to define your device or "-s" to select interactively.

----

2. Install spotifyd

Just follow the instructions here

https://github.com/Spotifyd/spotifyd/wiki/Installing-on-Ubuntu-%28from-source%29

but install this firstfloor_play3

#> apt-get install libpulse-dev

and use this commandline for use with pulseaudio

#> cargo build --release --features="pulseaudio_backend"

Basically no need to explain more here, the spotifyd documentation is diningroom_pendant_down

----

Known issues

- i can not start mkchromecast in the background, also it does not work with the "-n" flag, i have to use "-s" - Solution: use screen for now
- i can not start spotifyd in the background, it fails - Solution: use screen for now