Read the statement by Michael Teeuw here.
MMM-Sonos - Display what is currently playing on your Sonos network
-
Hi there.
I realised there is already a couple of modules for Sonos, but they didn’t really worked for me. I wanted something more minimalist, and easier to install: all sonos modules right now require to install and run a proxy sonos API server along side MagicMirror. My module doesn’t: clone it, install it and there you go!
All necessary information (configuration, screenshot) is available on the GitHub repository: https://github.com/tbouron/MMM-Sonos
Hope you’ll enjoy!

-
Hi @tbouron,
Great idea to simplify SONOS integration installation!
Your module works for me, and I like that it updates the data almost instantly comparing to other modules that do it on schedule.
But in my case your module constantly thinks that something have updated in SONOS groups, even if nothing is currently being played. So it constantly updates the groups, sets listener, causing high CPU utilization by Electron. -
Hi @eliah, thanks for your comment!
The module looking for groups regularly is by design: there is unfortunately no event when groups changes therefore they are pulled every 5 seconds. The listeners are set only when groups have changed.I checked on my mirror and cannot see a difference of CPU usage with or without the module enabled. How “bad” is the CPU hog on yours?
-
@tbouron,
In my case it seems that the script always consider that groups have changed, but that’s not true in fact. The log is full of repeating lines like that:[14:18:03.026] [LOG] Found new (or updated) group "Kitchen + 1" on host "x.x.x.34" [14:18:03.029] [LOG] Registering listeners on group "Kitchen + 1" (host "x.x.x.34") [14:18:03.281] [LOG] [Group Kitchen + 1 - x.x.x.34] Track changed to "Pokerface" by "The Baseballs" [14:18:03.289] [LOG] [Group Kitchen + 1 - x.x.x.34] Play state change to "paused" [14:18:03.353] [LOG] [Group Kitchen + 1 - x.x.x.34] Volume changed to "13" [14:18:03.361] [LOG] [Group Kitchen + 1 - x.x.x.34] Group is unmuted [14:18:07.847] [LOG] Found new (or updated) group "Bathroom" on host "x.x.x.39" [14:18:07.849] [LOG] Registering listeners on group "Bathroom" (host "x.x.x.39") [14:18:07.852] [LOG] Found new (or updated) group "Kids’ Room" on host "x.x.x.40" [14:18:07.854] [LOG] Registering listeners on group "Kids’ Room" (host "x.x.x.40") [14:18:08.045] [LOG] [Group Kids’ Room - x.x.x.40] Track changed to "Durch den Monsun" by "Annett Louisan" [14:18:08.053] [LOG] [Group Kids’ Room - x.x.x.40] Play state change to "paused" [14:18:08.081] [LOG] [Group Bathroom - x.x.x.39] Track changed to "Umbrella" by "The Baseballs" [14:18:08.088] [LOG] [Group Bathroom - x.x.x.39] Play state change to "paused" [14:18:08.157] [LOG] [Group Kids’ Room - x.x.x.40] Volume changed to "22" [14:18:08.163] [LOG] [Group Kids’ Room - x.x.x.40] Group is unmuted [14:18:08.213] [LOG] [Group Bathroom - x.x.x.39] Volume changed to "15" [14:18:08.216] [LOG] [Group Bathroom - x.x.x.39] Group is unmuted [14:18:13.066] [LOG] Found new (or updated) group "Kitchen + 1" on host "x.x.x.34" [14:18:13.069] [LOG] Registering listeners on group "Kitchen + 1" (host "x.x.x.34") [14:18:13.507] [LOG] [Group Kitchen + 1 - x.x.x.34] Track changed to "Pokerface" by "The Baseballs" [14:18:13.514] [LOG] [Group Kitchen + 1 - x.x.x.34] Play state change to "paused" [14:18:13.593] [LOG] [Group Kitchen + 1 - x.x.x.34] Volume changed to "13" [14:18:13.597] [LOG] [Group Kitchen + 1 - x.x.x.34] Group is unmuted [14:18:18.029] [LOG] Found new (or updated) group "Kids’ Room" on host "x.x.x.40" [14:18:18.032] [LOG] Registering listeners on group "Kids’ Room" (host "x.x.x.40") [14:18:18.036] [LOG] Found new (or updated) group "Bathroom" on host "x.x.x.39" [14:18:18.040] [LOG] Registering listeners on group "Bathroom" (host "x.x.x.39") [14:18:18.277] [LOG] [Group Kids’ Room - x.x.x.40] Track changed to "Durch den Monsun" by "Annett Louisan" [14:18:18.285] [LOG] [Group Kids’ Room - x.x.x.40] Play state change to "paused" [14:18:18.309] [LOG] [Group Bathroom - x.x.x.39] Track changed to "Umbrella" by "The Baseballs" [14:18:18.318] [LOG] [Group Bathroom - x.x.x.39] Play state change to "paused" [14:18:18.408] [LOG] [Group Kids’ Room - x.x.x.40] Volume changed to "22" [14:18:18.414] [LOG] [Group Kids’ Room - x.x.x.40] Group is unmuted [14:18:18.434] [LOG] [Group Bathroom - x.x.x.39] Volume changed to "15" [14:18:18.437] [LOG] [Group Bathroom - x.x.x.39] Group is unmuted [14:18:23.059] [LOG] Found new (or updated) group "Kitchen + 1" on host "x.x.x.34" [14:18:23.063] [LOG] Registering listeners on group "Kitchen + 1" (host "x.x.x.34") [14:18:23.248] [LOG] [Group Kitchen + 1 - x.x.x.34] Track changed to "Pokerface" by "The Baseballs" [14:18:23.255] [LOG] [Group Kitchen + 1 - x.x.x.34] Play state change to "paused" [14:18:23.353] [LOG] [Group Kitchen + 1 - x.x.x.34] Volume changed to "13" [14:18:23.359] [LOG] [Group Kitchen + 1 - x.x.x.34] Group is unmuted [14:18:27.955] [LOG] Found new (or updated) group "Kids’ Room" on host "x.x.x.40" [14:18:27.959] [LOG] Registering listeners on group "Kids’ Room" (host "x.x.x.40") [14:18:27.965] [LOG] Found new (or updated) group "Bathroom" on host "x.x.x.39" [14:18:27.969] [LOG] Registering listeners on group "Bathroom" (host "x.x.x.39") [14:18:28.311] [LOG] [Group Kids’ Room - x.x.x.40] Track changed to "Durch den Monsun" by "Annett Louisan" [14:18:28.316] [LOG] [Group Kids’ Room - x.x.x.40] Play state change to "paused" [14:18:28.343] [LOG] [Group Bathroom - x.x.x.39] Track changed to "Umbrella" by "The Baseballs" [14:18:28.351] [LOG] [Group Bathroom - x.x.x.39] Play state change to "paused" [14:18:28.430] [LOG] [Group Kids’ Room - x.x.x.40] Volume changed to "22" [14:18:28.434] [LOG] [Group Kids’ Room - x.x.x.40] Group is unmuted [14:18:28.471] [LOG] [Group Bathroom - x.x.x.39] Volume changed to "15" [14:18:28.474] [LOG] [Group Bathroom - x.x.x.39] Group is unmutedAnd as I said before, actually all speakers are paused so nothing is really playing.
-
@eliah That’s interesting, it would suggest that the group IDs are not consistent (as groups are cached by IDs) which obviously shouldn’t happen. I’m also wondering if targeting a random device on every scan has any implications on this (but it shouldn’t, at least I cannot reproduce this on my own network)
Would it possible for you to test a different version? I would like to see how it can be mitigated.
-
sure, I can test if you have any ideas why it is happening.
-
Hi @eliah. Can you try the version on the branch
fix/group-scanand tell me how it goes ?You would just need to go into the
MMM-Sonosfolder and do:git fetch && git checkout fix/group-scanThanks :)
-
@tbouron Beautiful module. How can I get the album art and Rooms that are stopped to also show up? What other info can I display?
Thanks
-
Hi @Jas and thanks!
Both of these are not supported. The concept of the module was to have a
Sonos now playing...module with minimalist design hence:- only vital information: title, artist, album (can be toggled), metadata: room, volume and track length (can be toggled)
- no album artwork
- show only rooms where music is playing, otherwise show nothing to avoid clutter
It would not be too hard to do all the above, but I don’t plan to do it anytime soon because of the concept.
-
@tbouron Got it! Thank you for the quick response. Looks great!
-
-
@tbouron It looks like the issue is now fixed, no constant updates anymore! Thank you. :)
Some more issues I noticed:- Value for song length minutes has no leading zero, so when a song’s length is 2:04 it shows 2:4.
- If any of speakers are used directly by AirPlay, it shows (null) (null). Maybe it’s better to ignore AirPlay mode if no information is available for it?
- Not sure if it is a bug of a module or Sonos library behind it, but for some reason the group names are sometimes become incorrect. For example, if I start a playlist on three speakers in the same group, first it shows something like “Kitchen+2” (and that’s correct), but after some time it becomes just “Kitchen” (same 3 speakers are playing).
And additionally, if more than one speaker is playing in the same group, each of them can have its own volume. In this case the single volume indicator that your module outputs to the screen becomes useless.
-
@eliah Awesome! Thanks for the feedback, I’ll cleanup and push the changes as soon as possible :)
Regarding the other issues:
Value for song length minutes has no leading zero, so when a song’s length is 2:04 it shows 2:4.
I already fixed that, it’s in a branch since Christmas but I was waiting for your feedback on the group scan issue to release it.
any of speakers are used directly by AirPlay, it shows (null) (null). Maybe it’s better to ignore AirPlay mode if no information is available for it?
I assume you are talking about the second line for
artistandalbumright? I already have sort of partial fix for that (not displaying the album ifnull). I could do the same thing for theartist. When you are using airplay, is the first line displayed correctly? What does it say? I unfortunately cannot know if something comes through airplay or not, it’s all unified through the Sonos library.Not sure if it is a bug of a module or Sonos library behind it, but for some reason the group names are sometimes become incorrect. For example, if I start a playlist on three speakers in the same group, first it shows something like “Kitchen+2” (and that’s correct), but after some time it becomes just “Kitchen” (same 3 speakers are playing).
That would be a bug in the underlying Sonos library. I just listening for events and display whatever comes from there.
And additionally, if more than one speaker is playing in the same group, each of them can have its own volume. In this case the single volume indicator that your module outputs to the screen becomes useless.
The Sonos library doesn’t give me this information unfortunately so that won’t be possible to do for now.
-
@tbouron said in MMM-Sonos - Display what is currently playing on your Sonos network:
I assume you are talking about the second line for
artistandalbumright? I already have sort of partial fix for that (not displaying the album ifnull). I could do the same thing for theartist. When you are using airplay, is the first line displayed correctly? What does it say? I unfortunately cannot know if something comes through airplay or not, it’s all unified through the Sonos library.I checked that more. And it looks if I share a song from iTunes via AirPlay, it provides all necessary information, so the data is correct. But if I use YouTube, then it is empty. Song name is just empty, and both singer and album names are displayed as (null).
That would be a bug in the underlying Sonos library. I just listening for events and display whatever comes from there.
That’s bad. :( As I can see, sometimes it just gets crazy. Shows me up instances of the same, when only one group plays. Looks like the library behind node-http-sonos-api required for another modules of the same type is more stable currently.
The Sonos library doesn’t give me this information unfortunately so that won’t be possible to do for now.
I believe it gives in fact. As I can see from Sonos module, its class SonosGroup contains Members. I believe it can be used to count number of members in the current group, and if there is more than one, not output the volume. Alternatively, I believe it should be possible to extract exact names of members from the Group to construct a more user-friendly custom name to use in metadata (i.e. not “Kitchen+2”, but “Kitchen, Corridor, Bathroom”).
-
@eliah I’ll see what I can do. But in the meantime, feel free to open issues and/or PRs on the GitHub repo for potential fixes
-
@tbouron: first of all, very noice module, chapeau! Now the inevitable nag: is there any means of reducing the font size (especially the track)? Any hint/idea appreciated!
-
@hweigel Thanks, that’s very much appreciated!
The module specifies classes for each element, like this one for the track so you can customise the font size via your
custom.css -
Alright, so I took a deeper look and it turns out that my code to display groups had a bug which made devices reappear even though they were part of a group. That should be fixed now with version
1.2.0.I also added a new config flag to display the group’s full name, see README.md
Regarding your comment @eliah on group volume, I disagree. The volume displayed is the global volume of group, which is exactly what the sonos app displays. Displaying volume of all members wouldn’t make sense here as this module doesn’t control the speakers (again, the sonos app does exactly this, it displays the group volume, then display individual speaker volume when, and only when, you change the volume)
That’s why I’m going to skip your request. However if you strongly feel it should be there, the code is open source on GitHub so feel free to fork the repo and implement it :)And finally, simply
git fetch origin && git pull origin masterwithinMMM-Sonosfolder to update the module. Enjoy! -
I am not able to get the module on the screen it is just blank when i play music on my Sonos units. My error log looks as below:
Do anyone have an idea to what is wrong?
0|mm | at createError (/home/pi/MagicMirror/modules/MMM-Sonos/node_mod ules/axios/lib/core/createError.js:16:15)
0|mm | at settle (/home/pi/MagicMirror/modules/MMM-Sonos/node_modules/ axios/lib/core/settle.js:17:12)
0|mm | at IncomingMessage.handleStreamEnd (/home/pi/MagicMirror/module s/MMM-Sonos/node_modules/axios/lib/adapters/http.js:237:11)
0|mm | at IncomingMessage.emit (events.js:187:15)
0|mm | at endReadableNT (_stream_readable.js:1090:12)
0|mm | at process._tickCallback (internal/process/next_tick.js:63:19)
0|mm | [15:26:18.931] [ERROR] (node:1174) UnhandledPromiseRejectionWarnin g: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 26)
0|mm | [15:26:19.373] [ERROR] (node:1174) UnhandledPromiseRejectionWarnin g: Error: Request failed with status code 405
0|mm | at createError (/home/pi/MagicMirror/modules/MMM-Sonos/node_mod ules/axios/lib/core/createError.js:16:15)
0|mm | at settle (/home/pi/MagicMirror/modules/MMM-Sonos/node_modules/ axios/lib/core/settle.js:17:12)
0|mm | at IncomingMessage.handleStreamEnd (/home/pi/MagicMirror/module s/MMM-Sonos/node_modules/axios/lib/adapters/http.js:237:11)
0|mm | at IncomingMessage.emit (events.js:187:15)
0|mm | at endReadableNT (_stream_readable.js:1090:12)
0|mm | at process._tickCallback (internal/process/next_tick.js:63:19)
0|mm | [15:26:19.380] [ERROR] (node:1174) UnhandledPromiseRejectionWarnin g: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 31) -
@tbouron I totally understand your concept and I think you created a really cool and good looking MMM! However, the albumart would be a really nice addition. Is there really no chance of adding it to the module? Sorry for nagging :winking_face:
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