svrooij / node-sonos-ts

:speaker: Sonos control library, use this library in your own appliction.
https://sonos-ts.svrooij.io/
MIT License
81 stars 18 forks source link

new api - additional endpoint: playbackSession.suspend #178

Closed hklages closed 5 months ago

hklages commented 1 year ago

Is your feature request related to a problem? Please describe

No.

Describe the solution you'd like

just add "playbackSession.suspend" similiar to play clip.

Describe alternatives you've considered

No idea

Additional context

see

svrooij commented 1 year ago

At the moment this library only supports local control. as in

flowchart LR
    A[NodeRED] -->|Invoke| B(node-sonos-ts)
    B -->|Soap mostly or HTTP| C{Sonos Speaker}

All the endpoints in the Control API are cloud based like the suspend command.

flowchart LR
    A[NodeRED] -->|Invoke| B(node-sonos-ts)
    B --> |1. Get token with user interaction| Cloud{Sonos Cloud}
    Cloud -->|2. Access token| B
    B --> |3. Keep token| B
    B --> |4. Control api| Cloud
    Cloud -->|Https| Speaker

Issues with control api:

  1. User interaction is needed to get a token.
  2. The library needs to keep state (access token, refresh token, client id, secret), where it used to be completely stateless.
  3. The controls will go through the cloud, which leads to slower control

Until now everything was possible by talking directly to the sonos speakers, which is something I really prefer. But I'm open for discussion.

Apart from that, the most recent commit in the beta branch contains code to *locally talk to the control API directly on the speaker. This might be your entry point. See https://github.com/svrooij/node-sonos-ts/commit/2a88a897f6e284ed84b1907468858dff2633d884

Any maybe even this comment

Care to give it a go @nficano

svrooij commented 7 months ago

@hklages I'm currently checking this out. And I seem to get some of the details working.

But for the suspend command, you seem to need the sessionId and this can only be retrieved whedn creating a sessions (so it seems.

https://docs.sonos.com/reference/playbacksession-suspend-sessionid image

svrooij commented 5 months ago

I'm closing this issue since, I cannot access the sessionId. If you know a way on how to get this, I'm happy to create this feature.

hklages commented 5 months ago

Yeah. Thanks for your effort. Session id is difficult to handle