MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    MMM-Sonos - To show what your SONOS is playing.

    Scheduled Pinned Locked Moved Entertainment
    29 Posts 17 Posters 27.7k Views 16 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C Offline
      cohron
      last edited by

      Guess I’m total noob but I havent figured out exactly how to install MMM-Sonos.

      1. I’m confused on installing and running node-sonos-http-api part. Does it get installed on /usr/local/lib/node_modules (I dont have that folder) but I do have /home/pi/MagicMirror/node_modules.

      2. MM is on rPI3b using the default installation from the readme but the the documentation on the api says i should install the latest nodejs. do i need to update/install? I went to https://nodejs.org/download/release/latest/ and it looks like 7.9.0 is the latest. i assume i install this on the MM rPI also. I’ll have to figure out how to git that too if so.

      3. I have my mm.sh file that auto-starts MM using pm2. Do I add a line in the mm.sh file to auto run the api on boot?
        my mm.sh
        cd ~/MagicMirror
        DISPLAY=:0 npm start

      1 Reply Last reply Reply Quote 0
      • SnilleS Offline
        Snille Module Developer
        last edited by

        @cohron First you need to “install” the node-sonos-http-api. You can put the node-sonos-http-api on the RPi I think. I have not tried that. I have mine installed on another server. But just try it, do the following (obs I have not tried this):

        cd ~
        git clone git@github.com:jishi/node-sonos-http-api.git
        cd node-sonos-http-api
        npm install --production
        npm start
        

        Now, see if you can get your zones via the link: http://yourmagicmirrorip:5005/zones
        If you do, you should be able to point your config to http://localhost
        And you should see something playing, if it is playing. :)

        Now you need to make sure the http-api is running all the time.
        Use the same procedure as for the MagicMirror.
        When you have the MagicMirror and http-api running type pm2 save (if you are using pm2).
        Otherwise you have to add it to your startup manually.

        I hope this helps a bit at least. :)

        If you cant find it, make it and share it!
        Modules: MMM-homeassistant-sensors, MMM-Modulebar, MMM-Profilepicture, MMM-Videoplayer

        C 1 Reply Last reply Reply Quote 0
        • C Offline
          cohron @Snille
          last edited by

          @Snille

          All right, love trial and error. Got it all up and running on my MM rPI!!!
          Through ssh pi@192.168.0.207 (my MM ip address)

          cd ~ //which puts me at /home/pi
          pi@magicpi:~ $ git clone https://github.com/jishi/node-sonos-http-api.git

          cd node-sonos-http-api
          npm install --production
          npm start

          verify, open a browser, point to your MM’s IP like so:
          http://192.168.0.207:5005/zones
          you should see a page full of sonos related text, if so the hard part is done…

          create another pm2 script named sonos.sh in ~ directory
          cd ~
          sonos.sh file contents:
          cd ~/node-sonos-http-api
          DISPLAY=:0 npm start

          pm2 start sonos.sh
          pm2 start mm
          pm2 save

          now just do the normal git for the sonos module
          pi@magicpi:~/MagicMirror/modules $ git clone https://github.com/Snille/MMM-Sonos.git

          fill in your config, this is mine:
          {
          module: ‘MMM-Sonos’,
          header: “Playing on SONOS”,
          position: “top_center”, // This can be any of the regions, best results in center regions
          classes: “default everyone”,
          config: {
          // See ‘Configuration options’ for more information.
          showStoppedRoom: false,
          showAlbumArt: true
          }
          },

          I also copied your awsome custom css content!

          D B 2 Replies Last reply Reply Quote 0
          • SnilleS Offline
            Snille Module Developer
            last edited by

            @cohron So it’s working now? Congrats! Great work! :)

            If you cant find it, make it and share it!
            Modules: MMM-homeassistant-sensors, MMM-Modulebar, MMM-Profilepicture, MMM-Videoplayer

            J 1 Reply Last reply Reply Quote 0
            • J Offline
              j.e.f.f Project Sponsor Module Developer @Snille
              last edited by

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • brandongomezB Offline
                brandongomez
                last edited by

                Great module! I am new to all of this and have the module working as intended. I listen to SiriusXM, Google Play and Spotify through Sonos.

                Google Play looks great and pulls the Artist and Track Title correctly. However, SiriusXM is sending everything together. Is there a way to format what SiriusXM sends me?

                For example, if I go to http://IP_Address:5005/zones when using Google Play, I see… {“currentTrack”:{“artist”:“Aretha Franklin”,“title”:“Respect”,“album”:“I Never Loved A Man The Way I Love You”,“albumArtUri”

                But if I put on a SiriusXM channel, it looks like this… {“currentTrack”:{“title”:“BR P|TYPE=SNG|TITLE Cold Little Heart|ARTIST Michael Kiwanuka|ALBUM”,“albumArtUri”

                As a result, the SiriusXM channel shows nothing for the Artist and “BR P|TYPE=SNG|TITLE Cold Little Heart|ARTIST Michael Kiwanuka|ALBUM” for the Track. Would love to get it to show something like “Cold Little Heart, Michael Kiwanuka” instead.

                Any help is appreciated. Thanks!

                1 Reply Last reply Reply Quote 0
                • SnilleS Offline
                  Snille Module Developer
                  last edited by

                  Hi! Hm… Looks like the SiriusMX information is not coming out in JSON format correctly from the SonosAPI.
                  I think you may have to contact Jimmi about this. Open an issue here: https://github.com/jishi/node-sonos-http-api/issues and describe your problem. As soon as the “output” is in correct JSON format, it should be working. Usually hes quick in fixing things. :)

                  Good luck.

                  If you cant find it, make it and share it!
                  Modules: MMM-homeassistant-sensors, MMM-Modulebar, MMM-Profilepicture, MMM-Videoplayer

                  1 Reply Last reply Reply Quote 0
                  • DesaydroneD Offline
                    Desaydrone
                    last edited by

                    Hello,

                    I got two sonos (for now) but on my mirror i only want to show one of this two. I don’t find how to do that, is ti possible ?

                    yawnsY 1 Reply Last reply Reply Quote 0
                    • yawnsY Offline
                      yawns Moderator @Desaydrone
                      last edited by

                      @Desaydrone
                      I don’t have any Sonos devices. According to the read me, you can exclude zones, I guess that’s what you are after, right?

                      Just follow the download link in first post and scroll down to the bottom for options

                      DesaydroneD 1 Reply Last reply Reply Quote 0
                      • DesaydroneD Offline
                        Desaydrone @yawns
                        last edited by

                        @yawns

                        Thaanks i didn’t see this options !!
                        THanks a lot

                        1 Reply Last reply Reply Quote 0
                        • S Offline
                          SuperSchenk
                          last edited by

                          Thank you for your work @Snille! Got it working on my mirror yesterday. Works great!

                          1 Reply Last reply Reply Quote 0
                          • D Offline
                            Damian @cohron
                            last edited by Damian

                            @cohron

                            @Snille

                            Hello,

                            Can you please explian how and where to create the sonos.sh file?
                            And how to then add the rest into that file?

                            I’m having trouble understanding what you mean by placing a script in ~ directory…
                            And the next part cd~sonos.sh file contents:

                            Thanks

                            create another pm2 script named sonos.sh in ~ directory
                            cd ~
                            sonos.sh file contents:
                            cd ~/node-sonos-http-api
                            DISPLAY=:0 npm start
                            
                            pm2 start sonos.sh
                            pm2 start mm
                            pm2 save
                            
                            D 1 Reply Last reply Reply Quote 0
                            • D Offline
                              Damian @Damian
                              last edited by

                              @Damian said in MMM-Sonos - To show what your SONOS is playing.:

                              create another pm2 script named sonos.sh in ~ directory
                              cd ~
                              sonos.sh file contents:
                              cd ~/node-sonos-http-api
                              DISPLAY=:0 npm start
                              
                              pm2 start sonos.sh
                              pm2 start mm
                              pm2 save
                              

                              Okay, so I opened up my directory… created a new file in /home/pi and named it sonos.sh… going by the jumbled up way things have been written in the example above, I have tried every combination to try and make sense of what it is saying to type into terminal

                              cd ~ sonos.sh file contents
                              sonos.sh

                              I will no doubt be going around in circles here trying to decypher the instructions, so can I ask anyone to please decypher this for me and tell me what and where to enter these? do I manually input them into the sonos.sh file? do I get terminal to enter them?
                              I a
                              l already set up PM2 over a year ago to autostart MM, and sure it was never as hard as this?

                              this is what I get when trying

                              pi@raspi:~ $ cd ~sonos.sh
                              bash: cd: ~sonos.sh: No such file or directory
                              pi@raspi:~ $ sonos.sh
                              bash: sonos.sh: command not found
                              pi@raspi:~ $ sonos.sh file contents:
                              bash: sonos.sh: command not found
                              pi@raspi:~ $ cd ~/node-sonos-http-api
                              pi@raspi:~/node-sonos-http-api $ DISPLAY=:0 npm start
                              
                              > sonos-http-api@1.6.0 start /home/pi/node-sonos-http-api
                              > node server.js
                              
                              2018-04-16T11:21:47.702Z INFO Could not find file /home/pi/node-sonos-http-api/settings.json
                              2018-04-16T11:21:48.670Z INFO Presets loaded: { example: 
                                 { players: 
                                    [ { roomName: 'Bathroom', volume: 10 },
                                      { roomName: 'Kitchen', volume: 10 },
                                      { roomName: 'Office', volume: 10 },
                                      { roomName: 'Bedroom', volume: 10 },
                                      { roomName: 'TV Room', volume: 15 } ],
                                   playMode: { shuffle: true, repeat: 'all', crossfade: false },
                                   pauseOthers: false } }
                              2018-04-16T11:21:54.317Z ERROR Port 5005 seems to be in use already. Make sure the sonos-http-api isn't 
                                  already running, or that no other server uses that port. You can specify an alternative http port 
                                  with property "port" in settings.json
                              
                              npm ERR! Linux 4.9.35-v7+
                              npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "start"
                              npm ERR! node v6.14.1
                              npm ERR! npm  v3.10.10
                              npm ERR! code ELIFECYCLE
                              npm ERR! sonos-http-api@1.6.0 start: `node server.js`
                              npm ERR! Exit status 1
                              npm ERR! 
                              npm ERR! Failed at the sonos-http-api@1.6.0 start script 'node server.js'.
                              npm ERR! Make sure you have the latest version of node.js and npm installed.
                              npm ERR! If you do, this is most likely a problem with the sonos-http-api package,
                              npm ERR! not with npm itself.
                              npm ERR! Tell the author that this fails on your system:
                              npm ERR!     node server.js
                              npm ERR! You can get information on how to open an issue for this project with:
                              npm ERR!     npm bugs sonos-http-api
                              npm ERR! Or if that isn't available, you can get their info via:
                              npm ERR!     npm owner ls sonos-http-api
                              npm ERR! There is likely additional logging output above.
                              
                              npm ERR! Please include the following file with any support request:
                              npm ERR!     /home/pi/node-sonos-http-api/npm-debug.log
                              pi@papaspi:~/node-sonos-http-api $ pm2 start sonos.sh
                              [PM2][ERROR] script not found : /home/pi/node-sonos-http-api/sonos.sh
                              script not found : /home/pi/node-sonos-http-api/sonos.sh
                              ┌──────┬──────┬────────┬───┬─────┬────────┐
                              │ Name │ mode │ status │ ↺ │ cpu │ memory │
                              ├──────┼──────┼────────┼───┼─────┼────────┤
                              │ mm   │ fork │ online │ 0 │ 0%  │ 0 B    │
                              └──────┴──────┴────────┴───┴─────┴────────┘
                               Use `pm2 show ` to get more details about an app
                              pi@raspi:~/node-sonos-http-api $ 
                              
                              D 1 Reply Last reply Reply Quote 0
                              • D Offline
                                Damian @Damian
                                last edited by

                                @Mods

                                Appreciate I have posted this twice in 2 seperate posts - but this one is FAO the Developer in his original post of 1 year ago, and to the poster who replied with his fix.

                                The other post goes to anyone here who can help me with making and executing a script, going by the example given for this module.

                                1 Reply Last reply Reply Quote 0
                                • F Offline
                                  flopp
                                  last edited by

                                  When I play TV sound on my Beam it will show up in Magic Mirror even if that it seems to be that is should hide

                                                  // if Sonos Playbar is in TV mode, no title is provided and therefore the room should not be displayed
                                                  var isEmpty = (artist && artist.trim().length) == 0
                                                          && (track && track.trim().length) == 0
                                                          && (cover && cover.trim().length) == 0;
                                  
                                  
                                  F 1 Reply Last reply Reply Quote 0
                                  • F Offline
                                    flopp @flopp
                                    last edited by flopp

                                    @flopp said in MMM-Sonos - To show what your SONOS is playing.:

                                    When I play TV sound on my Beam it will show up in Magic Mirror even if that it seems to be that is should hide

                                                    // if Sonos Playbar is in TV mode, no title is provided and therefore the room should not be displayed
                                                    var isEmpty = (artist && artist.trim().length) == 0
                                                            && (track && track.trim().length) == 0
                                                            && (cover && cover.trim().length) == 0;
                                    
                                    

                                    I now have forked this and correct the problem and also done some small changes. Added radio station name when playing Radio. Showing artist and track when playing radio.
                                    https://github.com/flopp999/MMM-Sonos

                                    StoffbeuteluweS 1 Reply Last reply Reply Quote 0
                                    • B Offline
                                      BD0G
                                      last edited by

                                      Looks like I am missing settings.json under /home/pi/node-sonos-http-api. I went to magicmirrors IP address:5005/zones and saw the output from my sonos one time , but then on reboot I can no longer get the output to show up by visiting the above specified URL . I think it may be a result of this missing settings.json file.

                                      1 Reply Last reply Reply Quote 0
                                      • StoffbeuteluweS Offline
                                        Stoffbeuteluwe Project Sponsor @flopp
                                        last edited by

                                        @flopp when I play Apple Music from my Sonos, is no artwork showing, anybody same problem

                                        1 Reply Last reply Reply Quote 0
                                        • B Offline
                                          BD0G @cohron
                                          last edited by BD0G

                                          @cohron OK , Im getting somewhere. When I visit http://192.168.1.5:5005/zones after installing sonos-http-api and then doing npm install --production and then npm start. I do see a webpage of output information from my sonos device.

                                          However, when I run my sonos.sh file after creating it like this

                                          create another pm2 script named sonos.sh in ~ directory
                                          cd ~
                                          sonos.sh file contents:
                                          cd ~/node-sonos-http-api
                                          DISPLAY=:0 npm start

                                          pm2 start sonos.sh
                                          pm2 start mm
                                          pm2 save

                                          It does start sonos as noted here

                                          │ id │ name │ mode │ ↺ │ status │ cpu │ memory │
                                          ├────┼────────────────────┼──────────┼──────┼──────────┼──────────┼──────────┤
                                          │ 0 │ MagicMirror │ fork │ 2 │ stopped │ 0% │ 0b │
                                          │ 1 │ sonos │ fork │ 212 │ online │ 0% │ 2.4mb │

                                          Then if I visit the same address (http://192.168.1.5:5005/zones) to see if there is still output . There is not!

                                          I realize that the Magic Mirror is not started as I stopped it as I just wanted to see if there was still output on http://192.168.1.5:5005/zones

                                          Sonos is playing when I visit http://192.168.1.5:5005/zones so there should be data being output.

                                          1 Reply Last reply Reply Quote 0
                                          • B Offline
                                            BD0G
                                            last edited by BD0G

                                            I finally solved this. Turned out I left out the tilde (~) in front of the /node-sonos-http-api within the sonos.sh file. So in essence the directory was never switched to execute the npm start command. So even though my PM2 status of running processes showed Sonos as a running process it was not providing the output data so that the module could display it

                                            1 Reply Last reply Reply Quote 0

                                            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                            With your input, this post could be even better 💗

                                            Register Login
                                            • 1
                                            • 2
                                            • 2 / 2
                                            • First post
                                              Last post
                                            Enjoying MagicMirror? Please consider a donation!
                                            MagicMirror created by Michael Teeuw.
                                            Forum managed by Sam, technical setup by Karsten.
                                            This forum is using NodeBB as its core | Contributors
                                            Contact | Privacy Policy