jishi / node-sonos-http-api

An HTTP API bridge for Sonos easing automation. Hostable on any node.js capable device, like a raspberry pi or similar.
http://jishi.github.io/node-sonos-http-api/
MIT License
1.84k stars 462 forks source link

Sockets!! I'm trying to recieve the state of the sonos system when something changes. #810

Open dennisfrijlink opened 2 years ago

dennisfrijlink commented 2 years ago

Hi I'm trying to recieve the state from the http-api when someone makes changes like volume + 1 or play/pause. I saw the Sonos Push Server (JS) but that didn't work/helped me. Hopefully someone can help me with this problem :).

jishi commented 2 years ago

Did you look at the webhook implementation?

https://github.com/jishi/node-sonos-http-api#webhook

But if you want to use something like websockets, you'd be better off implementing the sonos-discovery package directly. I built a web controller around that one, you can look at that to get some inspiration.

https://github.com/jishi/node-sonos-web-controller

dennisfrijlink commented 2 years ago

Hi @jishi thnx for your answer! I tried to use that webhook but it won't work. Thne while the sonos-http-api connects with the push server the Sonos push server doesn't recieve requests??

dennisfrijlink commented 2 years ago

I edited the settings.json but that didn't work.

// current settings.json
{
    "webhook": "http://localhost:5007/"
}
jishi commented 2 years ago

Are you running the latest Master? Can't help with someone elses code. Webhook -> websocket server is kind of a dumb setup, it's pretty trivial to write a wrapper around the sonos-discovery lib like I did with the web-controller. You could even use that directly and just connect from whatever web page you want.

On Sun, 24 Oct 2021, 00:27 Dennis Frijlink, @.***> wrote:

I edited the settings.json but that didn't work.

// current settings.json{ "webhook": "http://localhost:5007/"}

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jishi/node-sonos-http-api/issues/810#issuecomment-950226202, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYE2I3JJZ4CME6NVAKLRWLUIMZFJANCNFSM5GSSXPQA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

dennisfrijlink commented 2 years ago

Yeah took a blink at the Sonos discovery library but could not directly find how it is structured/how it works.

jishi commented 2 years ago

You could also look at this stub I wrote a while back, it was built for keeping track of playback status, so it tracks if the state changes. Maybe you can adapt that into what you need:

https://github.com/jishi/sonos-event-stub