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.83k stars 462 forks source link

New endpoint to show if any speaker is running #781

Open zperee opened 3 years ago

zperee commented 3 years ago

To be able to show if any speaker is running (e.g in Apple Home Kit as a Switch) created a new endpoint which returns true if any speaker has the playBackState === "PLAYING" otherwise return false.

With the new endpoint it is possible together with homebride and the hombridge-http-switch plugin to stop all speakers from Apple Home Kit. The new endpoint is needed to display the state of the button. So if a speaker is running turn switch on otherwise turn switch off.

{
     "accessory": "HTTP-SWITCH",
     "name": "Sonos",
     "switchType": "stateful",
     "timeout": 3000,
     "offUrl": "http://localhost:5005/pauseall",
     "onUrl": "http://localhost:5005/resumeall",
     "statusUrl": "http://localhost:5005/anyplayeron",
     "statusPattern": "{\"anyOn\":true}"
}
jsiegenthaler commented 3 years ago

Excellent, this is exactly what I wanted t do.

I'd also like to have an endpoint that lets me control the speaker LED. It's in the Sonos api but I have not yet found where it could be added in the Sonos-http-api

That would give me a quick visual indication as to the state of the speaker as I'd like to mute it overnight