Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    𝕚𝕒𝕚𝕟 𝕡𝕠𝕥𝕥𝕖𝕣 🐳
    @ForefrontTweets_twitter
    I have a file in my presets folder called nightmode.yaml
    It has the following contents
    {
      "players": [
         {
           "roomName": "TV",
           "equalizer": {
             "bass": -10,
             "treble": 5,
             "loudness": false,
             "speechEnhancement": true,
             "nightMode": true
           }
        }
      ],
      "pauseOthers": false
    }
    essentially, I want to call the API to set this preset from home assistant
    however, the preset isn't being picked up, even if I strip out the equalizer part (which could be wrong...)
    I can see that the API is aware of the preset file, because I see a log entry when I save the file

    for example

    2020-08-05T10:56:24.185Z INFO Presets loaded: {}

    any advice please?
    𝕚𝕒𝕚𝕟 𝕡𝕠𝕥𝕥𝕖𝕣 🐳
    @ForefrontTweets_twitter
    I just want to use it to configure eq and sound settings, and don't want to change playing state etc.
    Jimmy Shimizu
    @jishi
    @ForefrontTweets_twitter it needs to have a json file ending, not yaml.
    𝕚𝕒𝕚𝕟 𝕡𝕠𝕥𝕥𝕖𝕣 🐳
    @ForefrontTweets_twitter
    'doh!
    thanks @jishi :D
    Jean-Xavier DUQUESNE
    @Jxduquesne_twitter

    Got a question : Once I switched to tune-in radio for example (or other source), how do I play back the current queue without replacing it ? Thanks a lot !

    Hi there! Maybe my question is trivial, but I can't make it. I am able to play tunein radio using the API, this works great. But once I'm fed up the the radio, I would like to switch back to my playlist (the playlist of the group the player I am addressing is in). Event starting from the 1st track, I am not able to do that. Maybe I missed something ? Can something help me ? thanks a lot in advance !

    jnbht
    @jnbht
    @jishi You told me how to duplicate modified actions and use them. Is it also possible to duplicate a custom variant of "single-player-announcement.js" in which i delete this line: https://github.com/jishi/node-sonos-http-api/blob/master/lib/helpers/single-player-announcement.js#L126
    ?
    Thanks!
    jnbht
    @jnbht
    Ok, i think i got it and it worked. Had to duplicate and rename "single-player-announcement.js" and also change this new name in the custom "say.js" in Row 7 and 37 ;)
    jnbht
    @jnbht

    But ... what do i need to delete in a second custom "single-play-announcement" so that it will not log the player/music/group-stuff?

    What i basically want is, a "announcement-start.js" which logs everything but does not call the backup when finished (solved by deleting line 126) AND a "announcement-stop.js" which does not save a new log, but reloads the existing log when finished.

    Thanks a lot in advance to @jishi or everybody who can help!

    jnbht
    @jnbht
    I guess, i see the problem here. The info of 'backupPresets' is not saved between different calls. Right?
    Is this possible to do somehow? that 'say-start' saves the backup, and 'say-stop' loads the last one?
    Why i want this is, that i start a chain of actions and say-commands. And the System breaks very easy, if the commands come in to fast. Then the backup-action gets lost very often.
    jnbht
    @jnbht
    It really sucks, that Sonos does not support the 'audioClip'-API on older devices. Would make everything so much easier. Nevertheless, your workaround is an awesome piece of code!
    bausi2k
    @bausi2k
    Hi, I'm not sure if I'm allowed to ask a usage question in this chat, or if this is just for devs
    MY Problem is, that I don't know how to group two speakers, play a clip in the group and then leave the "destroy" the group again
    /a/join/b | /b/clip/file.mp3 | /a/leave/b was my idea but i doesn'T do the trick, because it only plays the mp3 on the speaker b
    jnbht
    @jnbht
    As far as i can tell, it should work like this. Try to wait 1 or 2 sconds before you fire the clip-command. That worked for me, if the commands did not do what they should
    otherwise you could try /b/add/a
    Jimmy Shimizu
    @jishi
    There is already a function for it. /clippreset can use a preset as player spec and group/ungroup automatically
    bausi2k
    @bausi2k
    thx @jishi @jnbht
    bausi2k
    @bausi2k
    /clippreset/{presetfile without extension}/file.mp3 does the trick! thx @jishi
    jnbht
    @jnbht
    Clean and easy!
    Alan Ogilvie
    @webziggy
    Hey, if you use macOS and Launchbar - I created an action which uses @jishi 's node-sonos-http-api to do the heavy lifting. https://github.com/webziggy/sonos-control-launchbar-action
    paul-thomas1964
    @paul-thomas1964
    I've set up a preset to allow me to perform a text to voice in 2 rooms, however, it never responds. No errors, it just eventually times out. I see the preset added in the console log, and it looks ok. Both devices work fine with individual say commands. Any ideas what I've done wrong?
    paul-thomas1964
    @paul-thomas1964
    An update on the above... It seems to create the grouping correctly, loads the voice file to the devices, but then it seems to just stop. The file is not spoken. I've changed my sonos config to be wifi i.e removed the bridge, and thats made no difference. Everything is up to date, using the legacy sonos (s1) app
    Bart de Jong
    @bartdejongbdj
    Is there a way to wake the Sonos Move through the API? The speaker goes into sleep mode after an inactive period of about 30 minutes and the only way I know to wake it remotely is by opening the Sonos app.
    Jimmy Shimizu
    @jishi
    @bartdejongbdj I don't own a Move, so I can't check how it actually wakes it. But if you can wake it from the Sonos app, I assume it would be possible to do it via an API as well. Then the WiFi card is still active and does respond to calls. It might just use a regular Wake On Lan signals, you could try with something like this to see if it works: https://www.microsoft.com/sv-se/p/wake-on-lan-magic-packet/9nblggh51pb3?activetab=pivot:overviewtab
    Bart de Jong
    @bartdejongbdj
    @jishi Thank you for your suggestions, I hadn't heard of WOL before. I just checked and WOL doesn't seem to activate the Move so it must be something else. Am I correct in saying that if such a waking command exists, it must be documented on the Sonos Developer website?
    Jimmy Shimizu
    @jishi
    @bartdejongbdj No, there is very sparse information regarding the inner protocol of Sonos (besides it being UPnP), and I've reverse engineered it by capturing the traffic from the desktop client. I would need a Move to figure out how they wake it up.
    I've always suspected that they eventually will move away from UPnP altogether, but they have yet to do that (I thought S2 would pull the plug but apparently not).
    Bart de Jong
    @bartdejongbdj
    @jishi That's unfortunately way over my head. I'll have to accept that I can't have Siri waking me up over the speaker when it's not on its charger. Thank you anyway!
    Bart de Jong
    @bartdejongbdj
    @jishi Quick question, did you use Wireshark to capture the traffic? Maybe I'll attempt to figure out the waking command myself
    Bengt Dahlberg
    @BengtDahlberg1_twitter

    Hi
    I'm new to Linux and also to Rasperry pi so please bare with me.
    I have tried to use the user guide https://github.com/jishi/node-sonos-http-api/wiki/Step-by-Step---RPi3-Install-of-Sonos-http-api

    I have come so far that I have been able to start npm and it works, so that is good.
    I needed to change the following line

    wget https://nodejs.org/dist/latest-v8.x/node-v8.16.2-linux-armv6l.tar.gz
    to
    wget https://nodejs.org/dist/latest-v8.x/node-v8.17.0-linux-armv7l.tar.gz
    by looking at the next line in the guide. (tar -xzf node-v8.17.0-linux-armv7l.tar.gz).

    So now I have the following state in my pi
    pi@raspberrypi:~ $ node -v
    v8.17.0
    pi@raspberrypi:~ $ npm -v
    6.13.4

    Is this a good start?

    When I tried to get it started after a reboot I run in to different problem, but I think we discussed this after see if the above is a good start.

    Hope you can help a beginner, thanks in advance!

    Jimmy Shimizu
    @jishi
    @bartdejongbdj Yes, wireshark is what I've used, but Intel UPnP tools are also useful to figure out what the devices support.
    @BengtDahlberg1_twitter Seems like you have gotten node.js and npm up and running, so yes, that is a good start :) There is also a pre-compiled raspberry image (albeit a bit outdated) if you want to avoid the hassle of setting up node and autostart etc. That image also runs from a RAM drive, minimizing the wear and tear of the SD-card. With Rasbian, your SD-card will probably fail within the year.
    Bart de Jong
    @bartdejongbdj
    @jishi Thankyou!
    Bengt Dahlberg
    @BengtDahlberg1_twitter

    Thanks @jishi

    I have now tried to get it started after a reboot.

    Bengt Dahlberg
    @BengtDahlberg1_twitter

    It did not work.
    pi@raspberrypi:~ $ pm2 startup
    [PM2] Init System found: systemd
    [PM2] To setup the Startup Script, copy/paste the following command:
    sudo env PATH=$PATH:/usr/local/bin /usr/local/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi

    pi@raspberrypi:~ $ sudo env PATH=$PATH:/usr/local/bin /usr/local/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi
    [PM2] Init System found: systemd
    Platform systemd
    Template
    [Unit]
    Description=PM2 process manager
    Documentation=https://pm2.keymetrics.io/
    After=network.target

    [Service]
    Type=forking
    User=pi
    LimitNOFILE=infinity
    LimitNPROC=infinity
    LimitCORE=infinity
    Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/usr/local/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
    Environment=PM2_HOME=/home/pi/.pm2
    PIDFile=/home/pi/.pm2/pm2.pid
    Restart=on-failure

    ExecStart=/usr/local/lib/node_modules/pm2/bin/pm2 resurrect
    ExecReload=/usr/local/lib/node_modules/pm2/bin/pm2 reload all
    ExecStop=/usr/local/lib/node_modules/pm2/bin/pm2 kill

    [Install]
    WantedBy=multi-user.target

    Target path
    /etc/systemd/system/pm2-pi.service
    Command list
    [ 'systemctl enable pm2-pi' ]
    [PM2] Writing init configuration in /etc/systemd/system/pm2-pi.service
    [PM2] Making script booting at startup...
    [PM2] [-] Executing: systemctl enable pm2-pi...
    [PM2] [v] Command successfully executed.
    +---------------------------------------+
    [PM2] Freeze a process list on reboot via:
    $ pm2 save

    [PM2] Remove init script via:
    $ pm2 unstartup systemd

    pi@raspberrypi:~ $ cd node-sonos-http-api

    pi@raspberrypi:~/node-sonos-http-api $ sudo pm2 start server.js -x --name "http-api"
    [PM2] Spawning PM2 daemon with pm2_home=/root/.pm2
    [PM2] PM2 Successfully daemonized
    [PM2] Starting /home/pi/node-sonos-http-api/server.js in fork_mode (1 instance)
    [PM2] Done.
    ┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐
    │ id │ name │ mode │ ↺ │ status │ cpu │ memory │
    ├────┼────────────────────┼──────────┼──────┼───────────┼──────────┼──────────┤
    │ 0 │ http-api │ fork │ 0 │ online │ 0% │ 21.9mb │
    └────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘

    pi@raspberrypi:~/node-sonos-http-api $ pm2 dump
    [PM2] Saving current process list...
    [PM2][WARN] PM2 is not managing any process, skipping save...
    [PM2][WARN] To force saving use: pm2 save --force

    pi@raspberrypi:~/node-sonos-http-api $ pm2 save --force
    [PM2] Saving current process list...
    [PM2] Successfully saved in /home/pi/.pm2/dump.pm2

    Do you see any problem above?

    Jimmy Shimizu
    @jishi
    @BengtDahlberg1_twitter yes, you are setting up pm2 for startup with your user, but then you started the api as root (via sudo). Pm2 keeps different dump files per user, and you only dumped it for the pi user. I recommend not running the api as root as well, there is no need for that.
    Bengt Dahlberg
    @BengtDahlberg1_twitter
    @jishi You mean this line sudo pm2 start server.js -x --name "http-api"
    Jimmy Shimizu
    @jishi
    Yes, run that without sudo. Then do the pm2 save
    Bengt Dahlberg
    @BengtDahlberg1_twitter
    Thanks, will try...
    Bengt Dahlberg
    @BengtDahlberg1_twitter

    Thanks @jishi now it works.

    I have done some editing below in your guide for Raspberry

    INSTALL NODE.JS & NPM

    I use Node.js v8 here as there appears to be a conflict netween v10 and npm where npm doesn't work correctly. Npm is included in the Node v8 release below

    Clone/Copy to the Pi

    wget https://nodejs.org/dist/latest-v8.x/node-v8.17.0-linux-armv7l.tar.gz
    Extract & Install using

    tar -xzf node-v8.17.0-linux-armv7l.tar.gz
    cd node-v8.17.0-linux-armv7l
    sudo cp -R * /usr/local/
    reboot Pi using

    sudo reboot
    Use following commands to veryify install

    node -v
    npm -v
    INSTALL SONOS HTTP API

    Clone http api files to PI

    sudo git clone https://github.com/jishi/node-sonos-http-api.git

    ls (will display files folder)

    cd node-sonos-http-api (change to api folder)

    sudo npm install --production

    sudo npm start (this will start sonos-http-api service) You should see references to sonos rooms, etc

    Now open a browser and assuming your sonos zone/room name is Kitchen you can confirm that the api is working by entering the following

    http://IP of Pi:5005/kitchen/state
    For me it is http://192.168.1.240:5005/kitchen/state

    You should see something like

    {"volume":13,"mute":false,"equalizer":{"bass":7,"treble":9,"loudness":true},"currentTrack":{"artist":"Cork's 96fm","title":"x-sonosapi-stream:s15078?sid=254","albumArtUri":"/getaa?s=1&u=x-sonosapi-stream%3as15078%3fsid%3d254","duration":0,"uri":"x-sonosapi-stream:s15078?sid=254","trackUri":"x-sonosapi-stream:s15078?sid=254","type":"radio","stationName":"Cork's 96fm","absoluteAlbumArtUri":"http://192.168.1.63:1400/getaa?s=1&u=x-sonosapi-stream%3as15078%3fsid%3d254"},"nextTrack":{"artist":"","title":"","album":"","albumArtUri":"","duration":0,"uri":""},"trackNo":1,"elapsedTime":25197,"elapsedTimeFormatted":"06:59:57","playbackState":"PLAYING","playMode":{"repeat":"none","shuffle":false,"crossfade":false}}

    START API ON PI POWERUP

    INSTALL PM2 by running the following commands

    sudo reboot

    npm install -g pm2

    pm2 startup

    Read the printout from above command and do as it says. Could be something like,
    "sudo env PATH=$PATH:/usr/local/bin /usr/local/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi"

    cd node-sonos-http-api

    pm2 start server.js -x --name "http-api"

    pm2 save

    pm2 dump

    Reboot Pi sudo reboot

    Confirm service starts automatically by using browser commands above

    Bengt Dahlberg
    @BengtDahlberg1_twitter
    1 reply
    Jimmy Shimizu
    @jishi
    The installation guide is a wiki, so I think it's editable by anyone. I think that leave / remove are aliases, and leaving is basically a call to the leaving player. It doesn't care which group it belongs to because leaving means that it isolates itself.
    1 reply