Radio through sonos doesn't show radio station title
Closed this issue · 40 comments
Thanks @CFenner for update. Album art, track title and artist all now working again.
Radio stations through sonos doesnt show the title of the radio station. It worked before. Currently this is what I can see
Whereas before it used to say BBC radio 2.
@dinkybluebug I just invoked http://<magicMirrorIp>:5005/zones
and get the following:
for playing BBC radio 2
"currentTrack": {
"title": "x-sonosapi-stream:s24940?sid=254&flags=8224&sn=0",
"albumArtUri": "/getaa?s=1&u=x-sonosapi-stream%3as24940%3fsid%3d254%26flags%3d8224%26sn%3d0",
"duration": 0,
"uri": "x-sonosapi-stream:s24940?sid=254&flags=8224&sn=0",
"type": "radio",
"absoluteAlbumArtUri": "http://192.168.178.25:1400/getaa?s=1&u=x-sonosapi-stream%3as24940%3fsid%3d254%26flags%3d8224%26sn%3d0"
},
for playing Deutschlandfunk
"currentTrack": {
"title": "Susanne Bontemps - Gasrausch im ewigen Eis",
"albumArtUri": "/getaa?s=1&u=x-sonosapi-stream%3as55652%3fsid%3d254%26flags%3d8224%26sn%3d0",
"duration": 0,
"uri": "x-sonosapi-stream:s55652?sid=254&flags=8224&sn=0",
"type": "radio",
"absoluteAlbumArtUri": "http://192.168.178.25:1400/getaa?s=1&u=x-sonosapi-stream%3as55652%3fsid%3d254%26flags%3d8224%26sn%3d0"
},
Unfortunately the Station Title is not provided anymore. Also BBC is not providing anything to display at all unlike Deutschlandfunk.
I'll try to fix the display of the x-sonosapi-stream:s24940?sid=254&flags=8224&sn=0
for the station.
Quick question, how do you view the output of …5005/zones so it looks nice and separated? When I view, it is all a mess and each line follows each other- rather than nice line breaks
Safari is doing this automatically, I think chrome is doing it as well. You can use a JSON beautifier like http://www.csvjson.com/json_beautifier.
node-sonos-http-api got an update again, and now radio station appears in localip:5005/zones, under artist - but its not showing in sonos module, which is weird. Still shows title as x-sonosapi-stream:s24940?sid=254&flags=8224&sn=0
see jishi/node-sonos-http-api#365
[
{
"uuid": "RINCON_000E58C229A401400",
"coordinator": {
"uuid": "RINCON_000E58C229A401400",
"state": {
"currentTrack": {
"artist": "BBC Radio 2",
"title": "x-sonosapi-stream:s24940?sid=254&flags=8224&sn=0",
"albumArtUri": "/getaa?s=1&u=x-sonosapi-stream%3as24940%3fsid%3d254%26flags%3d8224%26sn%3d0",
"duration": 0,
"uri": "x-sonosapi-stream:s24940?sid=254&flags=8224&sn=0",
"type": "radio",
"absoluteAlbumArtUri": "http://192.168.1.10:1400/getaa?s=1&u=x-sonosapi-stream%3as24940%3fsid%3d254%26flags%3d8224%26sn%3d0"
},
"nextTrack": {
"artist": "",
"title": "",
"album": "",
"albumArtUri": "",
"duration": 0,
"uri": ""
},
"volume": 24,
"mute": false,
"trackNo": 1,
"elapsedTime": 0,
"elapsedTimeFormatted": "00:00:00",
"playbackState": "STOPPED",
"playMode": {
"repeat": "none",
"shuffle": false,
"crossfade": false
}
},
"roomName": "Bedroom",
"coordinator": "RINCON_000E58C229A401400",
"groupState": {
"volume": 33,
"mute": false
}
},
"members": [
{
"uuid": "RINCON_B8E9375058C601400",
"state": {
"currentTrack": {
"artist": "BBC Radio 2",
"title": "x-sonosapi-stream:s24940?sid=254&flags=8224&sn=0",
"albumArtUri": "/getaa?s=1&u=x-sonosapi-stream%3as24940%3fsid%3d254%26flags%3d8224%26sn%3d0",
"duration": 0,
"uri": "x-sonosapi-stream:s24940?sid=254&flags=8224&sn=0",
"type": "radio",
"absoluteAlbumArtUri": "http://192.168.1.10:1400/getaa?s=1&u=x-sonosapi-stream%3as24940%3fsid%3d254%26flags%3d8224%26sn%3d0"
},
"nextTrack": {
"artist": "",
"title": "",
"album": "",
"albumArtUri": "",
"duration": 0,
"uri": ""
},
"volume": 41,
"mute": false,
"trackNo": 1,
"elapsedTime": 0,
"elapsedTimeFormatted": "00:00:00",
"playbackState": "STOPPED",
"playMode": {
"repeat": "none",
"shuffle": false,
"crossfade": false
}
},
"roomName": "Bathroom",
"coordinator": "RINCON_000E58C229A401400",
"groupState": {
"volume": 0,
"mute": false
}
},
{
"uuid": "RINCON_000E58C229A401400",
"state": {
"currentTrack": {
"artist": "BBC Radio 2",
"title": "x-sonosapi-stream:s24940?sid=254&flags=8224&sn=0",
"albumArtUri": "/getaa?s=1&u=x-sonosapi-stream%3as24940%3fsid%3d254%26flags%3d8224%26sn%3d0",
"duration": 0,
"uri": "x-sonosapi-stream:s24940?sid=254&flags=8224&sn=0",
"type": "radio",
"absoluteAlbumArtUri": "http://192.168.1.10:1400/getaa?s=1&u=x-sonosapi-stream%3as24940%3fsid%3d254%26flags%3d8224%26sn%3d0"
},
"nextTrack": {
"artist": "",
"title": "",
"album": "",
"albumArtUri": "",
"duration": 0,
"uri": ""
},
"volume": 24,
"mute": false,
"trackNo": 1,
"elapsedTime": 0,
"elapsedTimeFormatted": "00:00:00",
"playbackState": "STOPPED",
"playMode": {
"repeat": "none",
"shuffle": false,
"crossfade": false
}
},
"roomName": "Bedroom",
"coordinator": "RINCON_000E58C229A401400",
"groupState": {
"volume": 33,
"mute": false
}
}
]
},
{
"uuid": "RINCON_000E58B9149B01400",
"coordinator": {
"uuid": "RINCON_000E58B9149B01400",
"state": {
"currentTrack": {
"artist": "RINCON_000E58B9149B01400",
"duration": 0,
"uri": "x-sonos-htastream:RINCON_000E58B9149B01400:spdif",
"type": "line_in",
"absoluteAlbumArtUri": "http://192.168.1.6:1400undefined"
},
"nextTrack": {
"artist": "",
"title": "",
"album": "",
"albumArtUri": "",
"duration": 0,
"uri": ""
},
"volume": 36,
"mute": true,
"trackNo": 1,
"elapsedTime": 38,
"elapsedTimeFormatted": "00:00:38",
"playbackState": "PLAYING",
"playMode": {
"repeat": "none",
"shuffle": false,
"crossfade": false
}
},
"roomName": "Living Room",
"coordinator": "RINCON_000E58B9149B01400",
"groupState": {
"volume": 36,
"mute": true
}
},
"members": [
{
"uuid": "RINCON_000E58B9149B01400",
"state": {
"currentTrack": {
"artist": "RINCON_000E58B9149B01400",
"duration": 0,
"uri": "x-sonos-htastream:RINCON_000E58B9149B01400:spdif",
"type": "line_in",
"absoluteAlbumArtUri": "http://192.168.1.6:1400undefined"
},
"nextTrack": {
"artist": "",
"title": "",
"album": "",
"albumArtUri": "",
"duration": 0,
"uri": ""
},
"volume": 36,
"mute": true,
"trackNo": 1,
"elapsedTime": 38,
"elapsedTimeFormatted": "00:00:38",
"playbackState": "PLAYING",
"playMode": {
"repeat": "none",
"shuffle": false,
"crossfade": false
}
},
"roomName": "Living Room",
"coordinator": "RINCON_000E58B9149B01400",
"groupState": {
"volume": 36,
"mute": true
}
}
]
},
{
"uuid": "RINCON_B8E93721CD5201400",
"coordinator": {
"uuid": "RINCON_B8E93721CD5201400",
"state": {
"currentTrack": {
"title": "x-sonosapi-stream:s24940?sid=254&flags=8224&sn=0",
"albumArtUri": "/getaa?s=1&u=x-sonosapi-stream%3as24940%3fsid%3d254%26flags%3d8224%26sn%3d0",
"duration": 0,
"uri": "x-sonosapi-stream:s24940?sid=254&flags=8224&sn=0",
"type": "radio",
"absoluteAlbumArtUri": "http://192.168.1.8:1400/getaa?s=1&u=x-sonosapi-stream%3as24940%3fsid%3d254%26flags%3d8224%26sn%3d0"
},
"nextTrack": {
"artist": "",
"title": "",
"album": "",
"albumArtUri": "",
"duration": 0,
"uri": ""
},
"volume": 29,
"mute": false,
"trackNo": 1,
"elapsedTime": 1,
"elapsedTimeFormatted": "00:00:01",
"playbackState": "PLAYING",
"playMode": {
"repeat": "none",
"shuffle": false,
"crossfade": false
}
},
"roomName": "Kitchen",
"coordinator": "RINCON_B8E93721CD5201400",
"groupState": {
"volume": 29,
"mute": false
}
},
"members": [
{
"uuid": "RINCON_B8E93721CD5201400",
"state": {
"currentTrack": {
"title": "x-sonosapi-stream:s24940?sid=254&flags=8224&sn=0",
"albumArtUri": "/getaa?s=1&u=x-sonosapi-stream%3as24940%3fsid%3d254%26flags%3d8224%26sn%3d0",
"duration": 0,
"uri": "x-sonosapi-stream:s24940?sid=254&flags=8224&sn=0",
"type": "radio",
"absoluteAlbumArtUri": "http://192.168.1.8:1400/getaa?s=1&u=x-sonosapi-stream%3as24940%3fsid%3d254%26flags%3d8224%26sn%3d0"
},
"nextTrack": {
"artist": "",
"title": "",
"album": "",
"albumArtUri": "",
"duration": 0,
"uri": ""
},
"volume": 29,
"mute": false,
"trackNo": 1,
"elapsedTime": 1,
"elapsedTimeFormatted": "00:00:01",
"playbackState": "PLAYING",
"playMode": {
"repeat": "none",
"shuffle": false,
"crossfade": false
}
},
"roomName": "Kitchen",
"coordinator": "RINCON_B8E93721CD5201400",
"groupState": {
"volume": 29,
"mute": false
}
}
]
}
]
That output is weird, title should be empty now if it hasn't received "currently playing" info from the station (which only arrives during playback, as well). Are you sure you updated the dependencies before testing? You don't have "stationName" either, which should be there if it is using the correct version of sonos-discovery.
Also note that artist/stationName will contain the station name, and "title" is equivalent to the "Information" string in the Sonos desktop-client. You probably want to display both.
just run npm install --production
after you have pulled the latest master, and it will update the dependency accordingly.
Ok - I will test everything again.. Im sure I did this - but will check - thanks for your help
yes it kind of works. Radio titles shows, but then so does this random {1} underneath. Which is the same for when my playbar in my living room and the TV is on.
In this picture the first data is my playbar/TV , with the second which is the Kitchen, showing the radio.
Weirdly enough the {1} appeared before, and I could never understand why it did, as the code suggests that when the playbar is on, and TV is playing, it shouldnt show anything - which then lead me to generate the pullrequest to hide speakers/rooms - as I could never get the playbar to hide.
Not sure what is going on now. The output of my sonos-http-api is
[
{
"uuid": "RINCON_000E58C229A401400",
"coordinator": {
"uuid": "RINCON_000E58C229A401400",
"state": {
"currentTrack": {
"artist": "BBC Radio 2",
"albumArtUri": "/getaa?s=1&u=x-sonosapi-stream%3as24940%3fsid%3d254%26flags%3d8224%26sn%3d0",
"duration": 0,
"uri": "x-sonosapi-stream:s24940?sid=254&flags=8224&sn=0",
"type": "radio",
"stationName": "BBC Radio 2",
"absoluteAlbumArtUri": "http://192.168.1.10:1400/getaa?s=1&u=x-sonosapi-stream%3as24940%3fsid%3d254%26flags%3d8224%26sn%3d0"
},
"nextTrack": {
"artist": "",
"title": "",
"album": "",
"albumArtUri": "",
"duration": 0,
"uri": ""
},
"volume": 24,
"mute": false,
"trackNo": 1,
"elapsedTime": 0,
"elapsedTimeFormatted": "00:00:00",
"playbackState": "STOPPED",
"playMode": {
"repeat": "none",
"shuffle": false,
"crossfade": false
}
},
"roomName": "Bedroom",
"coordinator": "RINCON_000E58C229A401400",
"groupState": {
"volume": 33,
"mute": false
}
},
"members": [
{
"uuid": "RINCON_B8E9375058C601400",
"state": {
"currentTrack": {
"artist": "BBC Radio 2",
"albumArtUri": "/getaa?s=1&u=x-sonosapi-stream%3as24940%3fsid%3d254%26flags%3d8224%26sn%3d0",
"duration": 0,
"uri": "x-sonosapi-stream:s24940?sid=254&flags=8224&sn=0",
"type": "radio",
"stationName": "BBC Radio 2",
"absoluteAlbumArtUri": "http://192.168.1.10:1400/getaa?s=1&u=x-sonosapi-stream%3as24940%3fsid%3d254%26flags%3d8224%26sn%3d0"
},
"nextTrack": {
"artist": "",
"title": "",
"album": "",
"albumArtUri": "",
"duration": 0,
"uri": ""
},
"volume": 41,
"mute": false,
"trackNo": 1,
"elapsedTime": 0,
"elapsedTimeFormatted": "00:00:00",
"playbackState": "STOPPED",
"playMode": {
"repeat": "none",
"shuffle": false,
"crossfade": false
}
},
"roomName": "Bathroom",
"coordinator": "RINCON_000E58C229A401400",
"groupState": {
"volume": 0,
"mute": false
}
},
{
"uuid": "RINCON_000E58C229A401400",
"state": {
"currentTrack": {
"artist": "BBC Radio 2",
"albumArtUri": "/getaa?s=1&u=x-sonosapi-stream%3as24940%3fsid%3d254%26flags%3d8224%26sn%3d0",
"duration": 0,
"uri": "x-sonosapi-stream:s24940?sid=254&flags=8224&sn=0",
"type": "radio",
"stationName": "BBC Radio 2",
"absoluteAlbumArtUri": "http://192.168.1.10:1400/getaa?s=1&u=x-sonosapi-stream%3as24940%3fsid%3d254%26flags%3d8224%26sn%3d0"
},
"nextTrack": {
"artist": "",
"title": "",
"album": "",
"albumArtUri": "",
"duration": 0,
"uri": ""
},
"volume": 24,
"mute": false,
"trackNo": 1,
"elapsedTime": 0,
"elapsedTimeFormatted": "00:00:00",
"playbackState": "STOPPED",
"playMode": {
"repeat": "none",
"shuffle": false,
"crossfade": false
}
},
"roomName": "Bedroom",
"coordinator": "RINCON_000E58C229A401400",
"groupState": {
"volume": 33,
"mute": false
}
}
]
},
{
"uuid": "RINCON_000E58B9149B01400",
"coordinator": {
"uuid": "RINCON_000E58B9149B01400",
"state": {
"currentTrack": {
"duration": 0,
"uri": "x-sonos-htastream:RINCON_000E58B9149B01400:spdif",
"type": "line_in",
"stationName": ""
},
"nextTrack": {
"artist": "",
"title": "",
"album": "",
"albumArtUri": "",
"duration": 0,
"uri": ""
},
"volume": 60,
"mute": false,
"trackNo": 1,
"elapsedTime": 259,
"elapsedTimeFormatted": "00:04:19",
"playbackState": "PLAYING",
"playMode": {
"repeat": "none",
"shuffle": false,
"crossfade": false
}
},
"roomName": "Living Room",
"coordinator": "RINCON_000E58B9149B01400",
"groupState": {
"volume": 60,
"mute": false
}
},
"members": [
{
"uuid": "RINCON_000E58B9149B01400",
"state": {
"currentTrack": {
"duration": 0,
"uri": "x-sonos-htastream:RINCON_000E58B9149B01400:spdif",
"type": "line_in",
"stationName": ""
},
"nextTrack": {
"artist": "",
"title": "",
"album": "",
"albumArtUri": "",
"duration": 0,
"uri": ""
},
"volume": 60,
"mute": false,
"trackNo": 1,
"elapsedTime": 259,
"elapsedTimeFormatted": "00:04:19",
"playbackState": "PLAYING",
"playMode": {
"repeat": "none",
"shuffle": false,
"crossfade": false
}
},
"roomName": "Living Room",
"coordinator": "RINCON_000E58B9149B01400",
"groupState": {
"volume": 60,
"mute": false
}
}
]
},
{
"uuid": "RINCON_B8E93721CD5201400",
"coordinator": {
"uuid": "RINCON_B8E93721CD5201400",
"state": {
"currentTrack": {
"artist": "BBC Radio 2",
"albumArtUri": "/getaa?s=1&u=x-sonosapi-stream%3as24940%3fsid%3d254%26flags%3d8224%26sn%3d0",
"duration": 0,
"uri": "x-sonosapi-stream:s24940?sid=254&flags=8224&sn=0",
"type": "radio",
"stationName": "BBC Radio 2",
"absoluteAlbumArtUri": "http://192.168.1.8:1400/getaa?s=1&u=x-sonosapi-stream%3as24940%3fsid%3d254%26flags%3d8224%26sn%3d0"
},
"nextTrack": {
"artist": "",
"title": "",
"album": "",
"albumArtUri": "",
"duration": 0,
"uri": ""
},
"volume": 37,
"mute": false,
"trackNo": 1,
"elapsedTime": 0,
"elapsedTimeFormatted": "00:00:00",
"playbackState": "STOPPED",
"playMode": {
"repeat": "none",
"shuffle": false,
"crossfade": false
}
},
"roomName": "Kitchen",
"coordinator": "RINCON_B8E93721CD5201400",
"groupState": {
"volume": 37,
"mute": false
}
},
"members": [
{
"uuid": "RINCON_B8E93721CD5201400",
"state": {
"currentTrack": {
"artist": "BBC Radio 2",
"albumArtUri": "/getaa?s=1&u=x-sonosapi-stream%3as24940%3fsid%3d254%26flags%3d8224%26sn%3d0",
"duration": 0,
"uri": "x-sonosapi-stream:s24940?sid=254&flags=8224&sn=0",
"type": "radio",
"stationName": "BBC Radio 2",
"absoluteAlbumArtUri": "http://192.168.1.8:1400/getaa?s=1&u=x-sonosapi-stream%3as24940%3fsid%3d254%26flags%3d8224%26sn%3d0"
},
"nextTrack": {
"artist": "",
"title": "",
"album": "",
"albumArtUri": "",
"duration": 0,
"uri": ""
},
"volume": 37,
"mute": false,
"trackNo": 1,
"elapsedTime": 0,
"elapsedTimeFormatted": "00:00:00",
"playbackState": "STOPPED",
"playMode": {
"repeat": "none",
"shuffle": false,
"crossfade": false
}
},
"roomName": "Kitchen",
"coordinator": "RINCON_B8E93721CD5201400",
"groupState": {
"volume": 37,
"mute": false
}
}
]
}
]```
That's probably the same error as for the artist. I'll fix it in a minute.
Ah kewl. Can you hide my playbar then as well when it's playing TV audio. It shows the (1) as well as some weird album art
Did you post the data of a Player with TV sound on?
Yes. It's in the output above.
Here's another output - just my TV is playing in 'Living Room'
[
{
"uuid": "RINCON_000E58B9149B01400",
"coordinator": {
"uuid": "RINCON_000E58B9149B01400",
"state": {
"currentTrack": {
"duration": 0,
"uri": "x-sonos-htastream:RINCON_000E58B9149B01400:spdif",
"type": "line_in",
"stationName": ""
},
"nextTrack": {
"artist": "",
"title": "",
"album": "",
"albumArtUri": "",
"duration": 0,
"uri": ""
},
"volume": 60,
"mute": false,
"trackNo": 1,
"elapsedTime": 50,
"elapsedTimeFormatted": "00:00:50",
"playbackState": "PLAYING",
"playMode": {
"repeat": "none",
"shuffle": false,
"crossfade": false
}
},
"roomName": "Living Room",
"coordinator": "RINCON_000E58B9149B01400",
"groupState": {
"volume": 60,
"mute": false
}
},
"members": [
{
"uuid": "RINCON_000E58B9149B01400",
"state": {
"currentTrack": {
"duration": 0,
"uri": "x-sonos-htastream:RINCON_000E58B9149B01400:spdif",
"type": "line_in",
"stationName": ""
},
"nextTrack": {
"artist": "",
"title": "",
"album": "",
"albumArtUri": "",
"duration": 0,
"uri": ""
},
"volume": 60,
"mute": false,
"trackNo": 1,
"elapsedTime": 50,
"elapsedTimeFormatted": "00:00:50",
"playbackState": "PLAYING",
"playMode": {
"repeat": "none",
"shuffle": false,
"crossfade": false
}
},
"roomName": "Living Room",
"coordinator": "RINCON_000E58B9149B01400",
"groupState": {
"volume": 60,
"mute": false
}
}
]
}
]
@dinkybluebug could you try it now?
@jishi just a minor lapse: in line-in mode the station name is displayed but everything else is omitted.
Can I pull updated files over using some type of git pull commands? Or do I need to copy files in manually?
If you cloned the project into your modules folder you can use git pull
to update. Otherwise you need to download.
yay - it works. Awesome job. Now that its working again - are you able to incorporate the changes I suggested here : #10
which allows you to exclude specific speakers from showing if you want. In my set up - I only want the kitchen speaker to show. - and the changes I had suggested allow a variable 'Exclude' in the config file to allow for this.
I tried to apply your changes, hope it works. I didn't include the lambdas because I don't know how to use them ;)
No it doesnt.... it just says 'loading music' and then it doesnt change. Plus my calendar doesnt load now either. I put it back to the most recent working version and all is working again (albeit all the speakers)
I cant even give any advice on what to fix, as its not my code.... I got someone to help me write it. I might have a go again at the weekend.
For now though, you'll want to move it back a version. lol
Damn, it worked on my side. But I've just one speaker.. so no groups or playbar.
Hi - I think I sorted it.... the sonos.js script now excludes those speakers defined in the config file.
How do you want me to send you this file? Create a pull request? anyway here is is anyway
/* Magic Mirror
* Module: MagicMirror-Sonos-Module
*
* By Christopher Fenner https://github.com/CFenner
* MIT Licensed.
*/
Module.register('sonos', {
defaults: {
showStoppedRoom: true,
showAlbumArt: true,
showRoomName: true,
animationSpeed: 1000,
updateInterval: 0.5, // every 0.5 minutes
apiBase: 'http://localhost',
apiPort: 5005,
apiEndpoint: 'zones',
exclude: []
},
start: function() {
Log.info('Starting module: ' + this.name);
this.update();
// refresh every x minutes
setInterval(
this.update.bind(this),
this.config.updateInterval * 60 * 1000);
},
update: function(){
this.sendSocketNotification(
'SONOS_UPDATE',
this.config.apiBase + ":" + this.config.apiPort + "/" + this.config.apiEndpoint);
},
render: function(data){
var text = '';
$.each(data, (i, item) => {
if(this.config.exclude.indexOf(item.coordinator.roomName) === -1 || item.members.length > 1){
var room = item.coordinator.roomName;
var state = item.coordinator.state.playbackState;
var artist = item.coordinator.state.currentTrack.artist;
var track = item.coordinator.state.currentTrack.title;
var cover = item.coordinator.state.currentTrack.absoluteAlbumArtUri;
var streamInfo = item.coordinator.state.currentTrack.streamInfo;
var type = item.coordinator.state.currentTrack.type;
if(item.members.length > 1){
room = '';
$.each(item.members, (j, member) => {
if(this.config.exclude.indexOf(member.roomName) === -1){
room += member.roomName + ', ';
}
});
room = room.replace(/, $/,"");
}
if(room !== ''){
text += this.renderRoom(state, artist, track, cover, room);
}
}
});
this.loaded = true;
// only update dom if content changed
if(this.dom !== text){
this.dom = text;
this.updateDom(this.config.animationSpeed);
}
},
renderRoom: function(state, artist, track, cover, roomName) {
artist = artist?artist:"";
track = track?track:"";
cover = cover?cover:"";
var room = '';
// 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;
// show song if PLAYING
if(state === 'PLAYING' && !isEmpty) {
room += this.html.song.format(
this.html.name.format(artist, track)+
// show album art if 'showAlbumArt' is set
(this.config.showAlbumArt
?this.html.art.format(cover)
:''
)
//+"<span>"+streamInfo+"</span>"
);
}
// show room name if 'showRoomName' is set and PLAYING or 'showStoppedRoom' is set
if(this.config.showRoomName && (state === 'PLAYING' || this.config.showStoppedRoom)) {
room += this.html.room.format(roomName);
}
return this.html.roomWrapper.format(room);
},
html: {
loading: '<div class="dimmed light small">Loading music ...</div>',
roomWrapper: '<li>{0}</li>',
room: '<div class="room xsmall">{0}</div>',
song: '<div>{0}</div>',
name: '<div class="name normal medium"><div>{0}</div><div>{1}</div></div>',
art: '<div class="art"><img src="{0}"/></div>'
},
getScripts: function() {
return [
'String.format.js',
'//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.js'
];
},
getStyles: function() {
return ['sonos.css'];
},
getDom: function() {
var content = '';
if (!this.loaded) {
content = this.html.loading;
}else if(this.data.position.endsWith("left")){
content = '<ul class="flip">'+this.dom+'</ul>';
}else{
content = '<ul>'+this.dom+'</ul>';
}
return $('<div class="sonos">'+content+'</div>')[0];
},
socketNotificationReceived: function(notification, payload) {
if (notification === 'SONOS_DATA') {
Log.info('received SONOS_DATA');
this.render(payload);
}
}
});
@CFenner did you manage to test my changes to the code. Although you only have one speaker - did it work for you?
Ive been using this for the last two weeks and it works well.
My setup is a bit different to a normal MagicMirror - my display is not a mirror at all and is on in my Kitchen, which is why I only want the kitchen speaker showing.
Hey - so this was working, but now that node-sonos-http-api got another update - the radio stations down work again
my zones output looks like this: (where 'kitchen' is playing BBC Radio 2)
Any ideas what has changed?
What is the error now, no output? Could you reduce the data to the one from the kitchen?
Hi -
It doesnt show radio title - instead a URL.
{
"currentTrack": {
"artist": "BBC Radio 2",
"title": "x-sonosapi-stream:s24940?sid=254&flags=8224&sn=0",
"albumArtUri": "/getaa?s=1&u=x-sonosapi-stream%3as24940%3fsid%3d254%26flags%3d8224%26sn%3d0",
"duration": 0,
"uri": "x-sonosapi-stream:s24940?sid=254&flags=8224&sn=0",
"type": "radio",
"stationName": "BBC Radio 2",
"absoluteAlbumArtUri": "http://192.168.1.5:1400/getaa?s=1&u=x-sonosapi-stream%3as24940%3fsid%3d254%26flags%3d8224%26sn%3d0"
},
"nextTrack": {
"artist": "",
"title": "",
"album": "",
"albumArtUri": "",
"duration": 0,
"uri": ""
},
"volume": 33,
"mute": false,
"trackNo": 1,
"elapsedTime": 2,
"elapsedTimeFormatted": "00:00:02",
"playbackState": "PLAYING",
"playMode": {
"repeat": "none",
"shuffle": false,
"crossfade": false
}
}
Weirdly, I downloaded your sonos-mm code again- and reinstalled just to check I had the most up to date version - and now it doesnt work at all.
Just says 'Loading Music'
Can only assume that as node-sonos-http-api was updated- that something isnt working now.
Has the response of /zones
changed?
edit: ok, you downloaded just the mm module, not sonos api..
Sorry - I dont understand your edit. I downloaded node-sonos-http-api - and updated that (there was support for Amazon AWS polly - which I was playing around with.)
I then downloaded MagicMirror-Sonos-Module - and it doesnt work at all now. Says Loading music. If I revert back to my previous version of MagicMirror-Sonos-Module - it works but radio station doesnt show
Should I be downloading something else?
No, I just wanted to know if the API response changed, but you already posted the updated response.
Anything in the browser console?
ah yes - sonos.js:39 Uncaught TypeError: Cannot read property 'exclude' of undefined
at Object. (sonos.js:39)
at Function.each (jquery.js:365)
at Class. (sonos.js:38)
at Function.each (jquery.js:365)
at Class.render (sonos.js:34)
at Class.socketNotificationReceived (sonos.js:123)
at module.js:165
at Socket. (socketclient.js:26)
at Socket.Emitter.emit (socket.io.js:7413)
at Socket.onevent (socket.io.js:7129)
seams that the config is not present.. but I think I know where the issue is. The problem is I need to fix this blind. I can't test right now.
can you fetch the newest commit and try it again?
yes its working again now.... which is good.
Radio station is showing long URL data.
so my display is showing "stationName": "BBC Radio 2"
but also "title": "x-sonosapi-stream:s24940?sid=254&flags=8224&sn=0",
I suppose in the event that "type": " = "radio" then StationName should only be shown?
not sure why this doesnt work now - as it was working really well before
Well, as a said in the beginning of this post, some stations have a title. I could ignore the title if it is the same as the url or if it starts with x-sonosapi-stream.
chiming in: title is usually detailed information populated by information in the "stream" and is usually delayed. This can, for some streams, never occur and/or be delayed. I was pretty sure that I changed title to be an empty string until that actually happens, but could be wrong. If you find a discrepancy between two different versions of node-sonos-http-api, do file a bug report with detailed information and I'll look into it.
Thanks again for your help
@CFenner - yes that might be a good idea... if the title starts with 'x-sonosapi' - not displaying this might be a good option -as if node-sonos-http-api replaces this variable with something worth displaying, then it would display it