Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
    nevermind! had made a couple of syntax errors! got it up and running
    Owain Williams
    Is this room actually used anymore?
    Yes i had the opportunity to get some help from @jishi a couple of days aga
    Owain Williams
    @John-Jood Did you manage to solve the 500 status error? I'm having something similar.
    @OwainWilliams Yes i did. To be honest i'm totally sure that what i did change anything but now it works.
    I just had to set environment variables for Spotipy on my Rasperrby PI see : https://spotipy.readthedocs.io/en/latest/#authorization-code-flow
    Thank you for the project. Work fine ! :)

    I'm using this project (which is awesome) to do voice announcements from a home automation system. It issues commands like I set a preset firstfloor.json file as below:

      "players": [
          "roomName": "1. Family Room",
          "volume": 50
          "roomName": "1. Library",
          "volume": 50
          "roomName": "0. Ruff Playroom",
          "volume": 50
      "pauseOthers": false,

    What is strange is that regardless of setting on "pauseOthers", either true or false, it always pauses the other players in the house. So, as the voice announcement plays, the other zones, if they're playing something, pause and then resume after the announcement. It seems that /saypreset/ doesn't respect the pauseOthers flag. I looked through the code, and don't see how it works exactly. I was wondering if this is a known thing?

    1 reply
    To start with: Thanks for a great job. This has really made communicating with my Sonos devices a whole lot easier. For example I'm now using this to play vinyl records on my sonos speakers by the click of a smart button attached to the vinyl player.
    However, I am having some problems with getting the info of what is being played on my speakers (I am talking about songs from Spotify here, obviously I understand I can't get track data when playing line-in vinyl...). When I call "state" I get an almost empty "currentTrack" where only the uri is set (to "x-rincon:...."). Other variables (such as elapsedTime, which always seem to return "24") are also giving incorrect values.
    3 replies
    I've just setup a new rasp pi, and cant get the text to speech to work. I've updates settings.json with my voicerss api key. The browser returns success from the request, but nothing comes out of the sonos and the terminal log shows 2021-01-16T16:24:16.816Z ERROR
    { error: 'action \'tts\' not found' }
    My old PI does this ok with the same voicerss api key. Any ideas? Thanks
    29 replies
    Hey y’all, having a weird response time issue. I’m using some clips I made to function as ‘bells’ for my kid’s virtual school. So ive set up an automation to run a shortcut on my phone a minute or two before she needs to log back on. Shortcut just calls the URL to play the clip. It used to be quite quick, but things have slowed down and now it’ll be 2-3 minutes before the clip will play. This morning i even had a request time out, according to shortcuts, and then a minute later the clip played.
    5 replies
    Anyone experience this before or have thoughts on what could be causing this?
    Øystein Blixhavn

    Hey, I'm having some weird problems with my API, and especially attempting to play/queue Spotify playlists and albums. Adding them to the queue seems to work (in that their contents appear in /queue), but I can't access/play them. I think maybe Sonos is hung up in my connection through the Spotify app on my phone? It continues on my playlist there at least, and /state lists songs from there as current/next.

    Also, if I try to play the playlist/album directly, I get some obscure errors:

    Can anyone see what's going on?

    1 reply
    Hey all, any thoughts on why I'm not able to get the remove command to work for my sonos node instance? I am typing "" into my web browser but am getting "{"status":"error"}" when I try. The "add" command with the same syntax works perfectly every time.
    H. Klages
    Hi. For your information: Stephan has created a great SONOS documentation. Feel free to just use it or submit PR to improve. Location: https://svrooij.io/sonos-api-docs/services/

    Hi, I'm new to the sonos-http-api and I want to get the webhooks up an running.
    But there is always an issue coming up:

    > sonos-http-api@1.6.9 start
    > node server.js
    { "webhook": "https://localhost:8384" }
    SyntaxError: Unexpected token ':'
        at Object.compileFunction (node:vm:352:18)
        at wrapSafe (node:internal/modules/cjs/loader:1031:15)
        at Module._compile (node:internal/modules/cjs/loader:1065:27)
        at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
        at Module.load (node:internal/modules/cjs/loader:981:32)
        at Function.Module._load (node:internal/modules/cjs/loader:822:12)
        at Module.require (node:internal/modules/cjs/loader:1005:19)
        at require (node:internal/modules/cjs/helpers:102:18)
        at Object.<anonymous> (/home/smarthome/node-sonos-http-api/server.js:10:18)
        at Module._compile (node:internal/modules/cjs/loader:1101:14)

    Can anybody help and that?

    Jimmy Shimizu
    @sisamiwe line 48 doesn't exist in thst file. Did you just add some json to the end of the settings.js file? You are supposed to create a settings.json file and add that content. (note the file ending)
    @jishi THX

    Maybe another question. I try to use the "say" function standard goole withüronos/say/Hallo/de

    This fails with report: Error ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

    How to do it right?

    Jimmy Shimizu
    @sisamiwe I haven't tried the google tts in a long time, they might have discontinued it? It was piggy-backing on their translate system.
    Hm, tried the targeted url in my browser and it is still there though.
    Hey folks, for whatever reason, since today i'm facing the problem that my sonos-api doesnt recognise my sonos system. We're running two Households in the same network. The "other" sonos setup is found, mine is not. I followed the docu in https://github.com/jishi/node-sonos-http-api/blob/07b5e12143e7f6a06d7b524e5a6b37cff40e7af3/README.md#settingsjson -
    It states that i can find the "id" for my dedicated household/sonos system, but i have no clue on how to set it up in the settings.js file. Any ideas? Thanks in advance!
    Hello. I am very new to all of this. So can someone please provide basic but detailed instructions on how to build this?
    Meaning, I’m sitting with my computer looking at my desktop screen.
    What/where/which code do I need to insert and to which application/program on ky computer? Ive downloaded node.js and i assumed I would open terminal and follow the README, but when I type in “npm install —productions” it says it can’t find the directory. I’m not sure where to go from here. Thank you.
    is anyone else seeing an issue with shuffle command?
    {"status":"error","error":"mode is not defined","stack":"ReferenceError: mode is not defined\n at /home/pi/node-sonos-http-api/lib/actions/playmode.js:26:42\n at processTicksAndRejections (internal/process/task_queues.js:95:5)"}
    using command:
    Gee-sh. That's some unedited stream of consciousness garble. To sum it up. gpiozero button and encoder +1,-1 integration to execute preset local api commands. and point one button action to internal wav file. Again thanks and I hope you are interested enough in this tweak to explore a solution. If not, I understand. I'm beginning to realize the universe doesn't revolve around back-filling my ignorance.

    from gpiozero import Button, RotaryEncoder
    import requests
    from signal import pause

    btn = Button(4)
    volume = RotaryEncoder(20, 21, bounce_time = 0.05)

    def hello():

    def vol_up():

    def vol_down():

    btn.when_pressed = hello
    volume.when_rotated_clockwise = vol_up
    volume.when_rotated_counter_clockwise = vol_down


    Has anyone been able to get node-sonos-http-api working on a network that has a Ubiquiti Dream Machine Pro router and the Sonos amps on a different VLAN from the one where the node-sonos software is running? Apparently there's an issue in the Dream Machine Pro (UDM Pro) implementation of avahi and some apps don't work across VLANs. The Sonos S1 Controller app on my iMac does work in this setup, but node-sonos hangs after the "server listening on port 5005" message. There's a github project that replaces avahi with a custom multicast-relay on the UDM Pro, but it has some issues that prevent me from running it long term, so it would be nice to figure out where node-sonos is failing so I can see if there's a workaround within the node-sonos code.
    The networks in question are:

    br0 Link encap:Ethernet HWaddr 72:A7:41:95:6A:16
    inet addr: Bcast: Mask:
    inet6 addr: fe80::70a7:41ff:fe95:6a16/64 Scope:Link
    RX packets:22395 errors:0 dropped:0 overruns:0 frame:0
    TX packets:26832 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:5919689 (5.6 MiB) TX bytes:36511212 (34.8 MiB)

    br2 Link encap:Ethernet HWaddr 70:A7:41:95:6A:1F
    inet addr: Bcast: Mask:
    inet6 addr: fe80::f09a:acff:fe53:c939/64 Scope:Link
    RX packets:2254 errors:0 dropped:0 overruns:0 frame:0
    TX packets:3509 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:194428 (189.8 KiB) TX bytes:5444302 (5.1 MiB)

    My Sonos amps all have static IP addresses, so if there's some way to hard code node-sonos to see the amps at these addresses and eliminate the need for multicast messages to discover them, that would likely solve my problem. Traffic does flow across my VLANs, so I think it's only the multicast messages (and probably something specific to the ones node-sonos is using) that are getting blocked.
    Jimmy Shimizu
    @2MuchTech this has been asked before, but I never implemented such a thing, most people manage to resolve the multicast/broadcast problem via other means. It sucks that Ubiquiti are so slow in resolving obvious bugs, but ssdp-relay doesn't have to be handled by the router, you just need a device that belongs to all VLANs you want to relay between.
    https://github.com/alsmith/multicast-relay pops up when searching for this problem, but there are other solutions as well.
    I'm wondering why you can't put the http-api on the same net as the players? Forwarding traffic for the api is much easier than forwarding ssdp.