lukasroegner / homebridge-sonos-multiroom

Plugin for real Sonos multiroom experience in homebridge.
MIT License
35 stars 3 forks source link

Passing URI using API #17

Closed twynne closed 2 years ago

twynne commented 2 years ago

Hi there

I've been trying to set up this plugin for last few days. Whilst it's configured and working, and I can communicate using the API via iOS shortcuts (set volume works), I can't seem to get the ability to pay something back via API working.

I submitted the request to pull back configured playlists, and for the test item I want to play, I get the following:

{"title":"Piano Chill","album":null,"uri":"x-rincon-cpcontainer:1006206cplaylist%3apl.cb4d1c09a2df4230a78d0395fe1f8fde?sid=204&flags=8300&sn=9","artist":null}

I've then tried, via iOS shortcuts, passing in the full URI string as above. I've tried with quotes, without quotes, every subset and variation on the above string. Which part should I be using? And are quotes required?

Many thanks for any insight.

lukasroegner commented 2 years ago

It should work by just providing the value in the uri property. However, I've already noticed that behavior may differ based on the music provider that you want to use. Which provider are you trying to use? I could try it out with Apple Music and Spotify.

twynne commented 2 years ago

Thanks for getting back to me. This particular playlist is on Apple Music, but I chose that somewhat arbitrarily.

image

lukasroegner commented 2 years ago

I played around for a while, but didn't get it to work. While it works with Apple Music Radio, playlists won't start.

The plugin uses node-sonos for communicating with the Sonos system. I went through the issues there and tried to find a hint. There are many closed issues regarding starting a playlist (most of them use Spotify), none of the proposed solutions work.

twynne commented 2 years ago

Thank you for trying. I've managed to find another way... An iOS app called Soro. May still use the plugin for other purposes though.

lukasroegner commented 2 years ago

There is a project called sonos-http-api, which offers an extensive HTTP API for controlling the Sonos system. Maybe also worth a try, as the implementation of this project is really simple and may not cover all use cases.

jackc94 commented 2 years ago

Hey @lukasroegner,

Firstly, awesome plugin. However, like @twynne I too would like to make use of your http api functionality with Sonos. I can consistently run GET commands but have no luck with POST commands… there are not errors in the Homebridge logs and I have purposefully made errors to confirm it is erroring. Would love it if you can get this going as the HTTP API controller you mentioned has loads of npm dependency vulnerabilities including DoS!

lukasroegner commented 2 years ago

Can you post an example of the POST request that you are executing (e.g. the cURL command)? Make sure you send the JSON in the body of the request, not as form data or query parameters.

jackc94 commented 2 years ago

Sure… I’ve been using automaton within the Home app and created the following: 3445F118-AF5B-44C9-8AE2-F98154CB622E The full contents of the json is:

{
“current-track-uri”: x-rincon-stream:RINCON_949F3E55747C01400
}

Would you expect this to work? Like I say, GET commands are working as expected.

lukasroegner commented 2 years ago

In an automation, you have to add the properties in the JSON as key-value-pairs. In your example, add current-track-uri into the text field that says "Key" and x-rincon-stream:RINCON_949F3E55747C01400 into the "Value" field.

jackc94 commented 2 years ago

Oh I get you… that makes sense! Thanks so much for such a speedy response!