Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alexa and homebridge-zp #81

Closed
sschuste opened this issue Jun 21, 2019 · 7 comments
Closed

Alexa and homebridge-zp #81

sschuste opened this issue Jun 21, 2019 · 7 comments
Labels

Comments

@sschuste
Copy link

Hi Erik,

I have a strange behavior with homebridge-zp and Amazon's Alexa. Every time I play music on my SONOS system using my Echo Dot ("Alexa, play funk music in the living room") homebridge-zp stops the Homebridge. For instance:

[6/21/2019, 8:27:57 PM] [Alexa] alexaDiscovery - returned 60 devices
[6/21/2019, 8:29:28 PM] [Calendar] Updating calendar Eintracht
[6/21/2019, 8:29:29 PM] [Calendar] Pushing calendar sensor 'Eintracht' state 0 - value 0
[6/21/2019, 8:29:29 PM] [Calendar] No events to schedule.

"Alexa, play funk music in the living room."
Music is starting. The homebridge log shows normal operation.

[6/21/2019, 8:37:09 PM] [ZP] Wohnzimmer Sonos: set current track from "B&B - Hefe (Schlagzeug)" to ""
[6/21/2019, 8:37:09 PM] [ZP] Wohnzimmer Sonos: set current track from "" to "Midnight Train to Georgia"
[6/21/2019, 8:37:10 PM] [ZP] Wohnzimmer Sonos: set power (play/pause) from false to true

The songs ends. The next song from Alexa's funk playlist is started automatically. This causes:

[6/21/2019, 8:41:50 PM] TypeError: Cannot read property '0' of undefined
    at parser.parseString (/usr/local/lib/node_modules/homebridge-zp/lib/ZpAccessory.js:618:43)
    at Parser.<anonymous> (/usr/local/lib/node_modules/homebridge-zp/node_modules/xml2js/lib/parser.js:303:18)
    at Parser.emit (events.js:198:13)
    at SAXParser.onclosetag (/usr/local/lib/node_modules/homebridge-zp/node_modules/xml2js/lib/parser.js:261:26)
    at emit (/usr/local/lib/node_modules/homebridge-zp/node_modules/sax/lib/sax.js:624:35)
    at emitNode (/usr/local/lib/node_modules/homebridge-zp/node_modules/sax/lib/sax.js:629:5)
    at closeTag (/usr/local/lib/node_modules/homebridge-zp/node_modules/sax/lib/sax.js:889:7)
    at SAXParser.write (/usr/local/lib/node_modules/homebridge-zp/node_modules/sax/lib/sax.js:1436:13)
    at Parser.exports.Parser.Parser.parseString (/usr/local/lib/node_modules/homebridge-zp/node_modules/xml2js/lib/parser.js:322:31)
    at Parser.parseString (/usr/local/lib/node_modules/homebridge-zp/node_modules/xml2js/lib/parser.js:5:59)
    at parser.parseString (/usr/local/lib/node_modules/homebridge-zp/lib/ZpAccessory.js:573:21)
    at Parser.<anonymous> (/usr/local/lib/node_modules/homebridge-zp/node_modules/xml2js/lib/parser.js:303:18)
    at Parser.emit (events.js:198:13)
    at SAXParser.onclosetag (/usr/local/lib/node_modules/homebridge-zp/node_modules/xml2js/lib/parser.js:261:26)
    at emit (/usr/local/lib/node_modules/homebridge-zp/node_modules/sax/lib/sax.js:624:35)
    at emitNode (/usr/local/lib/node_modules/homebridge-zp/node_modules/sax/lib/sax.js:629:5)
    at closeTag (/usr/local/lib/node_modules/homebridge-zp/node_modules/sax/lib/sax.js:889:7)
    at SAXParser.write (/usr/local/lib/node_modules/homebridge-zp/node_modules/sax/lib/sax.js:1436:13)
    at Parser.exports.Parser.Parser.parseString (/usr/local/lib/node_modules/homebridge-zp/node_modules/xml2js/lib/parser.js:322:31)
    at Parser.parseString (/usr/local/lib/node_modules/homebridge-zp/node_modules/xml2js/lib/parser.js:5:59)
    at ZpAccessory.handleAVTransportEvent (/usr/local/lib/node_modules/homebridge-zp/lib/ZpAccessory.js:554:15)
    at ZpAccessory.emit (events.js:198:13)
    at parser.parseString (/usr/local/lib/node_modules/homebridge-zp/lib/ZpPlatform.js:240:23)
    at Parser.<anonymous> (/usr/local/lib/node_modules/homebridge-zp/node_modules/xml2js/lib/parser.js:303:18)
    at Parser.emit (events.js:198:13)
    at SAXParser.onclosetag (/usr/local/lib/node_modules/homebridge-zp/node_modules/xml2js/lib/parser.js:261:26)
    at emit (/usr/local/lib/node_modules/homebridge-zp/node_modules/sax/lib/sax.js:624:35)
    at emitNode (/usr/local/lib/node_modules/homebridge-zp/node_modules/sax/lib/sax.js:629:5)
    at closeTag (/usr/local/lib/node_modules/homebridge-zp/node_modules/sax/lib/sax.js:889:7)
    at SAXParser.write (/usr/local/lib/node_modules/homebridge-zp/node_modules/sax/lib/sax.js:1436:13)
    at Parser.exports.Parser.Parser.parseString (/usr/local/lib/node_modules/homebridge-zp/node_modules/xml2js/lib/parser.js:322:31)
    at Parser.parseString (/usr/local/lib/node_modules/homebridge-zp/node_modules/xml2js/lib/parser.js:5:59)
    at IncomingMessage.request.on (/usr/local/lib/node_modules/homebridge-zp/lib/ZpPlatform.js:229:23)
    at IncomingMessage.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1129:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

[6/21/2019, 8:41:50 PM] Got SIGTERM, shutting down Homebridge...
[6/21/2019, 8:41:50 PM] [ZP] cleaning up...
[6/21/2019, 8:41:55 PM] [ZP] exit

Homebridge doesn't crash but is stopped ("Got SIGTERM") and must be restarted manually as there is no reason for systemctl for restart it. While the music is playing further on, homebridge starts and goes to normal operation. Right until the song ends and the next is started. Bang. This behavior can be reproduced on my setup easily.

This never happens with the first song of the playlist, but with all following. If I restart homebridge while the music is playing, it will be stopped with the beginning of the next song.

At the same time the Sonos controller runs smoothly and shows the song's title, interpret and media art, one after the other while the play list is being played.

This is how I configured homebridge-zp:

        {
            "platform": "ZP",
            "service": "switch",
            "brightness": true,
            "speakers": false
        },

I own a Sonos Playbar and two Play:1s that form a group. I have no other Sonos devices. Any idea?

Gruß,
Stefan

@ebaauw
Copy link
Owner

ebaauw commented Jun 22, 2019

[6/21/2019, 8:41:50 PM] TypeError: Cannot read property '0' of undefined

Note that the message is issued by homebridge itself, handling an otherwise uncaught exception.

at parser.parseString (/usr/local/lib/node_modules/homebridge-zp/lib/ZpAccessory.js:618:43)

That would appear to be a bug. What version of homebridge-zp are you on? And of node? And of homebridge? Best post the message homebridge-zp issues at startup.

at ZpAccessory.handleAVTransportEvent (/usr/local/lib/node_modules/homebridge-zp/lib/ZpAccessory.js:554:15)

It looks like homebridge-zp is handling the event from the zoneplayer for the next song. It probably contains some unexpected content that causes homebridge-zp to choke. It’s a ridiculously deep stack trace, due to recursive XML parsing (the XML response contains a string, which contains XML).

Homebridge doesn't crash but is stopped ("Got SIGTERM")

The alternative is for nodejs to crash on an uncaught exception. This way, homebridge-zp can cancel the subscriptions and homebridge can save persisted accessories. It’s probably a good idea to exit with a non-zero state in this case.

@sschuste
Copy link
Author

Sorry for the delay. I understand the need to cancel the subscriptions and to be honest I'm thankful for it. I had so many problems with superfluous subscriptions that only disappeared completely when I had to turn off the main fuse of my apartment (huh?). But is another story.

Meanwhile I made some tests with playlists. When I select the music source in the Sonos Controller with the mouse, for example from the iTunes library, homebridge-zp shows the change from one song to the next in the log. But if I choose a song via Amazon Music - My Music - Playlists, that doesn't happen. It also doesn't happen when I use Amazon Music - Radio Stations as my source.

In the log it looks like this. I used a 70s party list, not because I want to hear this crap, but because the songs are short. Testing can be hell sometimes :-D

Jun 25 10:20:55 homePi homebridge[839]: [6/25/2019, 10:20:55 AM] [ZP] Wohnzimmer Sonos: set current track from "Russia on Ice" to "Pop Music"
Jun 25 10:20:55 homePi homebridge[839]: [6/25/2019, 10:20:55 AM] [ZP] Wohnzimmer Sonos: set power (play/pause) from false to true
Jun 25 10:24:17 homePi homebridge[839]: [6/25/2019, 10:24:17 AM] [ZP] Wohnzimmer Sonos: set current track from "Pop Music" to "Disco Stomp"

At this point I switched to my Amazon playlist:

Jun 25 10:25:05 homePi homebridge[839]: [6/25/2019, 10:25:05 AM] [ZP] Wohnzimmer Sonos: set power (play/pause) from true to false
Jun 25 10:25:06 homePi homebridge[839]: [6/25/2019, 10:25:06 AM] [ZP] Wohnzimmer Sonos: set power (play/pause) from false to true
Jun 25 10:34:33 homePi homebridge[839]: [6/25/2019, 10:34:33 AM] [ZP] Wohnzimmer Sonos: set power (play/pause) from true to false
Jun 25 10:34:35 homePi homebridge[839]: [6/25/2019, 10:34:35 AM] [ZP] Wohnzimmer Sonos: set power (play/pause) from false to true

And now to the Amazon Radio:

Jun 25 10:39:19 homePi homebridge[839]: [6/25/2019, 10:39:19 AM] [ZP] Wohnzimmer Sonos: set power (play/pause) from true to false
Jun 25 10:39:19 homePi homebridge[839]: [6/25/2019, 10:39:19 AM] [ZP] Wohnzimmer Sonos: set power (play/pause) from false to true

And back to the iTunes library:

Jun 25 10:39:19 homePi homebridge[839]: [6/25/2019, 10:39:19 AM] [ZP] Wohnzimmer Sonos: set current track from "Disco Stomp" to "Learning To Fly"
Jun 25 10:44:12 homePi homebridge[839]: [6/25/2019, 10:44:12 AM] [ZP] Wohnzimmer Sonos: set current track from "Learning To Fly" to "The Dogs Of War"
Jun 25 10:49:04 homePi homebridge[839]: [6/25/2019, 10:49:04 AM] [Alexa] alexaDiscovery - returned 41 devices
Jun 25 10:50:18 homePi homebridge[839]: [6/25/2019, 10:50:18 AM] [ZP] Wohnzimmer Sonos: set current track from "The Dogs Of War" to "One Slip" 

Between "Disco Stomp" and "Learning to fly" I heard three songs via Amazon which don't show up in the log. Meanwhile the Sonos controller works as expected showing song name, interpret, and media art for all played music. I also tested with Sonos playlists and TuneIn radio with no unexpected logging.

I always use pretty new versions of node LTS and homebridge. Actually this is:
[email protected]
[email protected]
node v10.16.0

Is there a better way for me to debug this?

Stefan

@ebaauw
Copy link
Owner

ebaauw commented Jun 25, 2019

[email protected]
[6/21/2019, 8:41:50 PM] TypeError: Cannot read property '0' of undefined
at parser.parseString (/usr/local/lib/node_modules/homebridge-zp/lib/ZpAccessory.js:618:43)

That confirms my suspicion that homebridge-zp chokes while reading the song info.

Is there a better way for me to debug this?

Can you patch /usr/local/lib/node_modules/homebridge-zp/lib/ZpAccessory.js, uncommenting

// this.log.debug('%s: AVTransport CurrentTrackMetaData: %j', this.name, item)

and commenting
track = item['dc:title'][0] // song

And run homebridge -D? That should log the track data as sent by Alexa and prevent the exception.

@sschuste
Copy link
Author

Here is what I have so far:

Adjusting the volume via Sonos controller on my Mac:

Jun 26 09:55:19 homePi homebridge[17724]: [6/26/2019, 9:55:19 AM] [ZP] Wohnzimmer Sonos: set group volume from 26 to 21

"Alexa, play funk music."

Jun 26 09:55:35 homePi homebridge[17724]: [6/26/2019, 9:55:35 AM] [ZP] Wohnzimmer Sonos: AVTransport event
Jun 26 09:55:35 homePi homebridge[17724]: [6/26/2019, 9:55:35 AM] [ZP] Wohnzimmer Sonos: set current track from undefined to ""
Jun 26 09:55:35 homePi homebridge[17724]: [6/26/2019, 9:55:35 AM] [ZP] Wohnzimmer Sonos: DeviceProperties event
Jun 26 09:55:36 homePi homebridge[17724]: [6/26/2019, 9:55:36 AM] [ZP] Wohnzimmer Sonos: AVTransport event
Jun 26 09:55:36 homePi homebridge[17724]: [6/26/2019, 9:55:36 AM] [ZP] Wohnzimmer Sonos: AVTransport CurrentTrackMetaData: {"$":{"id":"-1","parentID":"-1"},"res":[{"_":"https://d2lg00fehdyg04.cloudfront.net/DigitalMusicDeliveryService/HPS.m3u8?m=m&dmid=207459913&c=cf&f=ts&t=10&bl=256k&s=true&e1=1561536900000&e2=1561536900000&v=V2&n=OZZBODBJVN3GW&h=a0d994ed313d2217e0f3b00dbdd7b8f986a35911cf59121b7411b1d7b40fec3a","$":{"duration":"0:03:05"}}],"upnp:albumArtURI":["https://m.media-amazon.com/images/I/81QrdOxJ+GL._UL600_.jpg"],"upnp:class":["object.item.audioItem.musicTrack"],"dc:title":["Family Affair (Single Version)"],"dc:creator":["Sly And The Family Stone"],"upnp:album":["The Essential Sly & The Family Stone"],"r:tiid":["5d36d55f-ce9f-48f7-9149-bd824fd5bbb5"],"r:contentService":[{"$":{"id":"201","imageUrl":"https://s3.amazonaws.com/music-provider-logos/AmazonMusic.svg","name":"Amazon Music"}}],"r:policies":[{"$":{"mask":"0x80320800","flags":"0x80120000"}}]}
Jun 26 09:55:36 homePi homebridge[17724]: [6/26/2019, 9:55:36 AM] [ZP] Wohnzimmer Sonos: DeviceProperties event
Jun 26 09:55:36 homePi homebridge[17724]: [6/26/2019, 9:55:36 AM] [ZP] Wohnzimmer Sonos: AVTransport event
Jun 26 09:55:36 homePi homebridge[17724]: [6/26/2019, 9:55:36 AM] [ZP] Wohnzimmer Sonos: AVTransport CurrentTrackMetaData: {"$":{"id":"-1","parentID":"-1"},"res":[{"_":"https://d2lg00fehdyg04.cloudfront.net/DigitalMusicDeliveryService/HPS.m3u8?m=m&dmid=207459913&c=cf&f=ts&t=10&bl=256k&s=true&e1=1561536900000&e2=1561536900000&v=V2&n=OZZBODBJVN3GW&h=a0d994ed313d2217e0f3b00dbdd7b8f986a35911cf59121b7411b1d7b40fec3a","$":{"duration":"0:03:05"}}],"upnp:albumArtURI":["https://m.media-amazon.com/images/I/81QrdOxJ+GL._UL600_.jpg"],"upnp:class":["object.item.audioItem.musicTrack"],"dc:title":["Family Affair (Single Version)"],"dc:creator":["Sly And The Family Stone"],"upnp:album":["The Essential Sly & The Family Stone"],"r:tiid":["5d36d55f-ce9f-48f7-9149-bd824fd5bbb5"],"r:contentService":[{"$":{"id":"201","imageUrl":"https://s3.amazonaws.com/music-provider-logos/AmazonMusic.svg","name":"Amazon Music"}}],"r:policies":[{"$":{"mask":"0x80320800","flags":"0x80120000"}}]}
Jun 26 09:55:37 homePi homebridge[17724]: [6/26/2019, 9:55:37 AM] [ZP] Wohnzimmer Sonos: ZoneGroupTopology event
Jun 26 09:55:37 homePi homebridge[17724]: [6/26/2019, 9:55:37 AM] [ZP] Wohnzimmer Sonos: found RINCON_5CAAFDAD647901400 at 192.168.1.62 in Wohnzimmer
Jun 26 09:55:37 homePi homebridge[17724]: [6/26/2019, 9:55:37 AM] [ZP] Wohnzimmer Sonos: found RINCON_949F3E1D3CA401400 at 192.168.1.63 in Wohnzimmer (satellite)
Jun 26 09:55:37 homePi homebridge[17724]: [6/26/2019, 9:55:37 AM] [ZP] Wohnzimmer Sonos: found RINCON_949F3E1D19BE01400 at 192.168.1.64 in Wohnzimmer (satellite)
Jun 26 09:55:37 homePi homebridge[17724]: [6/26/2019, 9:55:37 AM] [ZP] Wohnzimmer Sonos: DeviceProperties event
Jun 26 09:55:37 homePi homebridge[17724]: [6/26/2019, 9:55:37 AM] [ZP] Wohnzimmer Sonos: AVTransport event
Jun 26 09:55:37 homePi homebridge[17724]: [6/26/2019, 9:55:37 AM] [ZP] Wohnzimmer Sonos: AVTransport CurrentTrackMetaData: {"$":{"id":"-1","parentID":"-1"},"res":[{"_":"https://d2lg00fehdyg04.cloudfront.net/DigitalMusicDeliveryService/HPS.m3u8?m=m&dmid=207459913&c=cf&f=ts&t=10&bl=256k&s=true&e1=1561536900000&e2=1561536900000&v=V2&n=OZZBODBJVN3GW&h=a0d994ed313d2217e0f3b00dbdd7b8f986a35911cf59121b7411b1d7b40fec3a","$":{"duration":"0:03:05"}}],"upnp:albumArtURI":["https://m.media-amazon.com/images/I/81QrdOxJ+GL._UL600_.jpg"],"upnp:class":["object.item.audioItem.musicTrack"],"dc:title":["Family Affair (Single Version)"],"dc:creator":["Sly And The Family Stone"],"upnp:album":["The Essential Sly & The Family Stone"],"r:tiid":["5d36d55f-ce9f-48f7-9149-bd824fd5bbb5"],"r:contentService":[{"$":{"id":"201","imageUrl":"https://s3.amazonaws.com/music-provider-logos/AmazonMusic.svg","name":"Amazon Music"}}],"r:policies":[{"$":{"mask":"0x80320800","flags":"0x80120000"}}]}
Jun 26 09:55:37 homePi homebridge[17724]: [6/26/2019, 9:55:37 AM] [ZP] Wohnzimmer Sonos: set power (play/pause) from false to true
Jun 26 09:55:37 homePi homebridge[17724]: [6/26/2019, 9:55:37 AM] [ZP] Wohnzimmer Sonos: DeviceProperties event
Jun 26 09:55:39 homePi homebridge[17724]: [6/26/2019, 9:55:39 AM] [ZP] Wohnzimmer Sonos: AVTransport event
Jun 26 09:55:39 homePi homebridge[17724]: [6/26/2019, 9:55:39 AM] [ZP] Wohnzimmer Sonos: AVTransport CurrentTrackMetaData: {"$":{"id":"-1","parentID":"-1"},"res":[{"_":"https://d2lg00fehdyg04.cloudfront.net/DigitalMusicDeliveryService/HPS.m3u8?m=m&dmid=207459913&c=cf&f=ts&t=10&bl=256k&s=true&e1=1561536900000&e2=1561536900000&v=V2&n=OZZBODBJVN3GW&h=a0d994ed313d2217e0f3b00dbdd7b8f986a35911cf59121b7411b1d7b40fec3a","$":{"duration":"0:03:05"}}],"upnp:albumArtURI":["https://m.media-amazon.com/images/I/81QrdOxJ+GL._UL600_.jpg"],"upnp:class":["object.item.audioItem.musicTrack"],"dc:title":["Family Affair (Single Version)"],"dc:creator":["Sly And The Family Stone"],"upnp:album":["The Essential Sly & The Family Stone"],"r:tiid":["5d36d55f-ce9f-48f7-9149-bd824fd5bbb5"],"r:contentService":[{"$":{"id":"201","imageUrl":"https://s3.amazonaws.com/music-provider-logos/AmazonMusic.svg","name":"Amazon Music"}}],"r:policies":[{"$":{"mask":"0x80320800","flags":"0x80120000"}}]}
Jun 26 09:55:40 homePi homebridge[17724]: [6/26/2019, 9:55:40 AM] [ZP] Wohnzimmer Sonos: AVTransport event
Jun 26 09:55:40 homePi homebridge[17724]: [6/26/2019, 9:55:40 AM] [ZP] Wohnzimmer Sonos: AVTransport event
Jun 26 09:55:40 homePi homebridge[17724]: [6/26/2019, 9:55:40 AM] [ZP] Wohnzimmer Sonos: AVTransport CurrentTrackMetaData: {"$":{"id":"-1","parentID":"-1"},"res":[{"_":"https://d2lg00fehdyg04.cloudfront.net/DigitalMusicDeliveryService/HPS.m3u8?m=m&dmid=207459913&c=cf&f=ts&t=10&bl=256k&s=true&e1=1561536900000&e2=1561536900000&v=V2&n=OZZBODBJVN3GW&h=a0d994ed313d2217e0f3b00dbdd7b8f986a35911cf59121b7411b1d7b40fec3a","$":{"duration":"0:03:05"}}],"upnp:albumArtURI":["https://m.media-amazon.com/images/I/81QrdOxJ+GL._UL600_.jpg"],"upnp:class":["object.item.audioItem.musicTrack"],"dc:title":["Family Affair (Single Version)"],"dc:creator":["Sly And The Family Stone"],"upnp:album":["The Essential Sly & The Family Stone"],"r:tiid":["5d36d55f-ce9f-48f7-9149-bd824fd5bbb5"],"r:contentService":[{"$":{"id":"201","imageUrl":"https://s3.amazonaws.com/music-provider-logos/AmazonMusic.svg","name":"Amazon Music"}}],"r:policies":[{"$":{"mask":"0x80320800","flags":"0x80120000"}}]}

Next song starts:

Jun 26 09:58:42 homePi homebridge[17724]: [6/26/2019, 9:58:42 AM] [ZP] Wohnzimmer Sonos: AVTransport event
Jun 26 09:58:42 homePi homebridge[17724]: [6/26/2019, 9:58:42 AM] [ZP] Wohnzimmer Sonos: AVTransport CurrentTrackMetaData: {"$":{"id":"-1","parentID":"-1"},"res":[{"_":"https://d2lg00fehdyg04.cloudfront.net/DigitalMusicDeliveryService/HPS.m3u8?m=m&dmid=200000302924910&c=cf&f=ts&t=10&bl=256k&s=true&e1=1561536900000&e2=1561536900000&v=V2&n=THZO2RZ5EEJZA&h=f168e4da859a17ea9cdcd18aa1430cf994b978c9fb6373b53626f65bd377a709","$":{"duration":"0:00:00"}}],"upnp:class":["object.item.audioItem.musicTrack"],"r:tiid":["7b17e80d-5db2-4efe-99e3-9754a0fdcc39"],"r:contentService":[{"$":{"id":"201","name":"Amazon Music"}}],"r:policies":[{"$":{"mask":"0x80320800","flags":"0x80000000"}}]}
Jun 26 09:58:42 homePi homebridge[17724]: [6/26/2019, 9:58:42 AM] [ZP] Wohnzimmer Sonos: AVTransport event
Jun 26 09:58:42 homePi homebridge[17724]: [6/26/2019, 9:58:42 AM] [ZP] Wohnzimmer Sonos: AVTransport CurrentTrackMetaData: {"$":{"id":"-1","parentID":"-1"},"res":[{"_":"https://d2lg00fehdyg04.cloudfront.net/DigitalMusicDeliveryService/HPS.m3u8?m=m&dmid=200000302924910&c=cf&f=ts&t=10&bl=256k&s=true&e1=1561536900000&e2=1561536900000&v=V2&n=THZO2RZ5EEJZA&h=f168e4da859a17ea9cdcd18aa1430cf994b978c9fb6373b53626f65bd377a709","$":{"duration":"0:00:00"}}],"upnp:class":["object.item.audioItem.musicTrack"],"r:tiid":["7b17e80d-5db2-4efe-99e3-9754a0fdcc39"],"r:contentService":[{"$":{"id":"201","name":"Amazon Music"}}],"r:policies":[{"$":{"mask":"0x80320800","flags":"0x80000000"}}]}
Jun 26 09:58:43 homePi homebridge[17724]: [6/26/2019, 9:58:43 AM] [ZP] Wohnzimmer Sonos: AVTransport event
Jun 26 09:58:43 homePi homebridge[17724]: [6/26/2019, 9:58:43 AM] [ZP] Wohnzimmer Sonos: AVTransport CurrentTrackMetaData: {"$":{"id":"-1","parentID":"-1"},"res":[{"_":"https://d2lg00fehdyg04.cloudfront.net/DigitalMusicDeliveryService/HPS.m3u8?m=m&dmid=200000302924910&c=cf&f=ts&t=10&bl=256k&s=true&e1=1561536900000&e2=1561536900000&v=V2&n=THZO2RZ5EEJZA&h=f168e4da859a17ea9cdcd18aa1430cf994b978c9fb6373b53626f65bd377a709","$":{"duration":"0:04:58"}}],"upnp:albumArtURI":["https://m.media-amazon.com/images/I/61vj8pq5+CL._UL600_.jpg"],"upnp:class":["object.item.audioItem.musicTrack"],"dc:title":["Celebration (Album Version)"],"dc:creator":["Kool and The Gang"],"upnp:album":["Have A Good Day"],"r:tiid":["7b17e80d-5db2-4efe-99e3-9754a0fdcc39"],"r:contentService":[{"$":{"id":"201","imageUrl":"https://s3.amazonaws.com/music-provider-logos/AmazonMusic.svg","name":"Amazon Music"}}],"r:policies":[{"$":{"mask":"0x80320800","flags":"0x80120000"}}]}
Jun 26 09:58:43 homePi homebridge[17724]: [6/26/2019, 9:58:43 AM] [ZP] Wohnzimmer Sonos: AVTransport event
Jun 26 09:58:43 homePi homebridge[17724]: [6/26/2019, 9:58:43 AM] [ZP] Wohnzimmer Sonos: AVTransport CurrentTrackMetaData: {"$":{"id":"-1","parentID":"-1"},"res":[{"_":"https://d2lg00fehdyg04.cloudfront.net/DigitalMusicDeliveryService/HPS.m3u8?m=m&dmid=200000302924910&c=cf&f=ts&t=10&bl=256k&s=true&e1=1561536900000&e2=1561536900000&v=V2&n=THZO2RZ5EEJZA&h=f168e4da859a17ea9cdcd18aa1430cf994b978c9fb6373b53626f65bd377a709","$":{"duration":"0:04:58"}}],"upnp:albumArtURI":["https://m.media-amazon.com/images/I/61vj8pq5+CL._UL600_.jpg"],"upnp:class":["object.item.audioItem.musicTrack"],"dc:title":["Celebration (Album Version)"],"dc:creator":["Kool and The Gang"],"upnp:album":["Have A Good Day"],"r:tiid":["7b17e80d-5db2-4efe-99e3-9754a0fdcc39"],"r:contentService":[{"$":{"id":"201","imageUrl":"https://s3.amazonaws.com/music-provider-logos/AmazonMusic.svg","name":"Amazon Music"}}],"r:policies":[{"$":{"mask":"0x80320800","flags":"0x80120000"}}]}
Jun 26 09:58:46 homePi homebridge[17724]: [6/26/2019, 9:58:46 AM] [ZP] Wohnzimmer Sonos: AVTransport event
Jun 26 09:58:46 homePi homebridge[17724]: [6/26/2019, 9:58:46 AM] [ZP] Wohnzimmer Sonos: AVTransport CurrentTrackMetaData: {"$":{"id":"-1","parentID":"-1"},"res":[{"_":"https://d2lg00fehdyg04.cloudfront.net/DigitalMusicDeliveryService/HPS.m3u8?m=m&dmid=200000302924910&c=cf&f=ts&t=10&bl=256k&s=true&e1=1561536900000&e2=1561536900000&v=V2&n=THZO2RZ5EEJZA&h=f168e4da859a17ea9cdcd18aa1430cf994b978c9fb6373b53626f65bd377a709","$":{"duration":"0:04:58"}}],"upnp:albumArtURI":["https://m.media-amazon.com/images/I/61vj8pq5+CL._UL600_.jpg"],"upnp:class":["object.item.audioItem.musicTrack"],"dc:title":["Celebration (Album Version)"],"dc:creator":["Kool and The Gang"],"upnp:album":["Have A Good Day"],"r:tiid":["7b17e80d-5db2-4efe-99e3-9754a0fdcc39"],"r:contentService":[{"$":{"id":"201","imageUrl":"https://s3.amazonaws.com/music-provider-logos/AmazonMusic.svg","name":"Amazon Music"}}],"r:policies":[{"$":{"mask":"0x80320800","flags":"0x80120000"}}]}

The second song has two log lines which the first song does not have. All following songs have these two lines too. But I'm a bit overwhelmed with the amount of information. I guess it's easier for you to read and rate that.

Stefan

@ebaauw ebaauw added the bug label Jun 28, 2019
@ebaauw
Copy link
Owner

ebaauw commented Jun 28, 2019

But I'm a bit overwhelmed with the amount of information.

Welcome to my world. And for these messages the XML sent by the ZonePlayer has already been converted to JSON...

Next song starts

The "dc:title" is missing from the first two messages. homebridge-zp doesn't handle that (bug 1) and doesn't try/catch the handling of the AVTransport event, causing the unhandled exception (bug 2).

I'm right in the middle of refactoring homebridge-zp to use the dynamic platform accessory model (see #1), so it might be a while before I can fix this.

@sschuste
Copy link
Author

I'm right in the middle of refactoring homebridge-zp to use the dynamic platform accessory model (see #1), so it might be a while before I can fix this.

Take your time. My javascript knowledge is too low to understand your entire code, but it was sufficient to add a small if condition to the correct place. This little patch solves my problem for now. I'm looking forward to your new code.

@ebaauw ebaauw closed this as completed in f033ab0 Jul 17, 2019
@sschuste
Copy link
Author

Works with homebridge-zp v1.0.0. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants