airsonos icon indicating copy to clipboard operation
airsonos copied to clipboard

Installed but failing on startup - RPi 3

Open sidharthb0 opened this issue 5 years ago • 30 comments

Hey there!

I managed to bypass all errors and got Airsonos finally installed on my Raspberry Pi 3.

Although when I run it, it fails with TypeError: Cannot read property 'forEach' of null

I've tried a few of the suggestions provided in other threads but to no avail. I also do not currently have any BOOST or BRIDGE devices on my network (although I see logicalDevice.js mentions ignoring them)

My current set up is 2 Play:1 Speakers and a Connect:Amp

Really hoping someone can help me sort this out!

LOG

pi@raspberrypi:~ $ airsonos

*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi. *** WARNING *** Please fix your application to use the native API of Avahi! *** WARNING *** For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=node *** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi. *** WARNING *** Please fix your application to use the native API of Avahi! *** WARNING *** For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=node&f=DNSServiceRegister Searching for Sonos devices on network...

/usr/local/lib/node_modules/airsonos/node_modules/sonos/lib/logicalDevice.js:84 devices.forEach(function(device) { ^

TypeError: Cannot read property 'forEach' of null at /usr/local/lib/node_modules/airsonos/node_modules/sonos/lib/logicalDevice.js:84:16 at /usr/local/lib/node_modules/airsonos/node_modules/sonos/lib/sonos.js:719:7 at Parser. (/usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/xml2js/lib/xml2js.js:255:20) at emitOne (events.js:77:13) at Parser.emit (events.js:169:7) at Object.saxParser.onclosetag (/usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/xml2js/lib/xml2js.js:225:24) at emit (/usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/xml2js/node_modules/sax/lib/sax.js:615:33) at emitNode (/usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/xml2js/node_modules/sax/lib/sax.js:620:3) at closeTag (/usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/xml2js/node_modules/sax/lib/sax.js:861:5) at Object.write (/usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/xml2js/node_modules/sax/lib/sax.js:1293:29) at Parser.exports.Parser.Parser.parseString (/usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/xml2js/lib/xml2js.js:273:29) at Parser.parseString (/usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/xml2js/lib/xml2js.js:6:61) at Object.exports.parseString (/usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/xml2js/lib/xml2js.js:296:19) at Request._callback (/usr/local/lib/node_modules/airsonos/node_modules/sonos/lib/sonos.js:702:12) at Request.self.callback (/usr/local/lib/node_modules/airsonos/node_modules/sonos/node_modules/request/request.js:129:22) at emitTwo (events.js:87:13)

sidharthb0 avatar Sep 10 '18 21:09 sidharthb0

I'm having the same exact issue trying to run AirSonos on Mac. Hopefully someone can find a solution for this.

doner005 avatar Sep 23 '18 01:09 doner005

Same issue on Raspberry Pi 3 - it was working but stopped recently.

DJBenson avatar Sep 25 '18 20:09 DJBenson

Can reproduce on macOS 10.13.6 -- was working last week 🤷🏼‍♂️

ksho avatar Sep 27 '18 22:09 ksho

Same here. Doesn't work on macOS 10.13.6 anymore. Didn't use in a while tho'.

ddmoh avatar Sep 28 '18 16:09 ddmoh

This seems to be an error coming from a sonos firmware upgrade. I cannot start my instance either on ubuntu. It looks to me from the logs that airsonos can no longer find the speakers.

rafale77 avatar Sep 28 '18 16:09 rafale77

One more comment, Airsonos as I noticed is no longer needed with airplay2. The bridging is done directly into the sonos without the need of airsonos if you have a sonos which supports airplay2.

https://blog.sonos.com/en/airplay2-coming/

rafale77 avatar Sep 28 '18 16:09 rafale77

@rafale77 I'm still waiting to pickup an airplay2 compatible sonos. It sounds like only one AP2 sonos is needed on your network to make all speakers AP2 compatible?

ksho avatar Sep 28 '18 17:09 ksho

@ksho indeed, only one is needed in your network but it needs to be the group leader. If you play through it, it works. If you are trying to play through only one speaker, it needs to be one of the newer ones.

rafale77 avatar Sep 28 '18 17:09 rafale77

As far as I can see the issue is because getTopology has been deprecated, as reflected in the sonos package: https://github.com/bencevans/node-sonos/commit/7b7164d91895ae64dbc1f2d92968bf962dd67443 I can try to submit a PR but it does not look like this repo here is still maintained

max-mathieu avatar Oct 04 '18 00:10 max-mathieu

I am also having the same issue. Definitely interested in figuring this out so I can keep using airsonos!

tmelot2 avatar Oct 09 '18 15:10 tmelot2

I tried pulling the latest version of node-sonos into the mix, and whilst the error message did change, it seems that there is something in airsonos (lib/airsonos.js) which also needs updating. It is calling a method which I don't think exists in the node-sonos library (probably due to the change to getTopology mentioned above).

I also tried pulling one of the forks which are still updated but they don't appear to have been fixed yet.

DJBenson avatar Oct 09 '18 15:10 DJBenson

This is definitely broken since one of the latest Sonos updates. I guess Sonos trying to force everyone to buy their latest speakers.

vkoi81 avatar Oct 10 '18 11:10 vkoi81

This is definitely broken since one of the latest Sonos updates. I guess Sonos trying to force everyone to buy their latest speakers.

I don't think that's the case at all. Sonos have a very good reputation for supporting "legacy" devices for a long time. For example they only recently stopped supporting the CR100 hardware controller which was released 13 years ago and stopped being manufactured almost a decade ago - that's above and beyond what many manufacturers will support these days.

This is likely as a result of a change in the API which hasn't been reflected in airsonos (which of course is because this project appears to be abandoned).

DJBenson avatar Oct 10 '18 11:10 DJBenson

This was definitely a great project when it was alive.

I remember reading something a while back where Sonos said in an interview that they were aware of some “workarounds” for airplay support but were not yet ready to address those “workarounds”.

I just thought that now they decided to close up the holes so to speak.

You’re probably right though, might just need an api update to get this working again.

vkoi81 avatar Oct 10 '18 11:10 vkoi81

Interestingly, there is a project (https://github.com/ebaauw/homebridge-zp/tree/AirTunes) which is an interface betwen homebridge (the open source implementation of Apple's HomeKit) which in the beta version exposes AirTunes receivers for each speaker - that is still working - so perhaps there is something from that projects code which can be ported across into airsonos?

Alternatively, you could just switch to using homebridge + homebridge-sp to allow you to continue using AirPlay with non-AirPlay Sonos speakers, even if you don't need the HomeKit integration.

DJBenson avatar Oct 10 '18 11:10 DJBenson

Here's what happens if you delete the sonos directory from airsonos/node_modules and then reinstall the latest version with npm install git://github.com/bencevans/node-sonos.git:

pi@homekithub:~/airsonos/bin $ node index.js
*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node>
*** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node&f=DNSServiceRegister>
Searching for Sonos devices on network...

**/home/pi/airsonos/bin/airsonos.js:67
      return Promise.promisify(sonos.LogicalDevice.search);
                                                   ^

TypeError: Cannot read property 'search' of undefined**
    at AirSonos.get (/home/pi/airsonos/bin/airsonos.js:67:52)
    at AirSonos.start (/home/pi/airsonos/bin/airsonos.js:24:19)
    at Object.<anonymous> (/home/pi/airsonos/bin/index.js:32:12)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Function.Module.runMain (module.js:694:10)
    at startup (bootstrap_node.js:204:16)
    at bootstrap_node.js:625:3

DJBenson avatar Oct 10 '18 11:10 DJBenson

sonos.LogicalDevice.search doesn't exist in the latest version of node-sonos - the new method is called DeviceDiscovery but I cannot work out how to incorporate that into airsonos.

DJBenson avatar Oct 10 '18 12:10 DJBenson

Here’s my solution. I ditched this project and use this. https://sonoair.mihosoft.eu/

I downloaded the installer from their website and it worked right away.

doner005 avatar Oct 10 '18 12:10 doner005

Here's what happens if you delete the sonos directory from airsonos/node_modules and then reinstall the latest version with npm install git://github.com/bencevans/node-sonos.git:

pi@homekithub:~/airsonos/bin $ node index.js
*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node>
*** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node&f=DNSServiceRegister>
Searching for Sonos devices on network...

**/home/pi/airsonos/bin/airsonos.js:67
      return Promise.promisify(sonos.LogicalDevice.search);
                                                   ^

TypeError: Cannot read property 'search' of undefined**
    at AirSonos.get (/home/pi/airsonos/bin/airsonos.js:67:52)
    at AirSonos.start (/home/pi/airsonos/bin/airsonos.js:24:19)
    at Object.<anonymous> (/home/pi/airsonos/bin/index.js:32:12)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Function.Module.runMain (module.js:694:10)
    at startup (bootstrap_node.js:204:16)
    at bootstrap_node.js:625:3

I just started using AirConnect and it's working fine. Have you tried it?

vkoi81 avatar Oct 17 '18 16:10 vkoi81

same problem here. hope someone can come up with a fix

ricosuave0922 avatar Nov 09 '18 03:11 ricosuave0922

I think this project is abandoned. Have you tried airconnect?

vkoi81 avatar Nov 09 '18 05:11 vkoi81

I just did. Got it all setup and working. Now to figure out how to uninstall Airsonos.

ricosuave0922 avatar Nov 09 '18 05:11 ricosuave0922

@ricosuave0922 npm uninstall -g airsonos

jasonmarziani avatar Nov 09 '18 21:11 jasonmarziani

Has this repo been abandoned? I have a working version and I want to know if I should PR or just start a new project?

eeston avatar May 15 '19 18:05 eeston

Has this repo been abandoned? I have a working version and I want to know if I should PR or just start a new project?

I’d be a happy recipient of a working version.

DJBenson avatar May 27 '19 15:05 DJBenson

On holiday at the moment. Will push my fork up next week

eeston avatar May 27 '19 15:05 eeston

@DJBenson give this a spin and let me know how you get on... https://github.com/johneas10/airsonos

It's turned into a bit of a mish-mash of various fixes on various forks, none of which I could get to work on their own. Hopefully now that they're all on one repo, it should make things a little easier to maintain. I've also implemented NicerCast and NodeTunes to make development a little smoother.

At the moment it's pretty limited but it seems to run fine with a single play:1 multiple play:1s (if they are grouped) setups. They're the only devices I can test on at the moment. Volume is also a little flakey.

Still very much a work in progress, and I will probably refactor a lot of it over the coming weeks. Hopefully I can get it running pretty well. If anyone has other devices to test with, I would appreciate some feedback.

eeston avatar Jun 05 '19 13:06 eeston

Hi @johneas10, thanks for the share.

I've replaced my broken install with your fork and it seems to work well. I'm running it on a Raspberry Pi 3 using wired ethernet and have 3xSonos:1's (non Alexa) a Sonos Connect:Amp and a Sonos Boost (not sure the latter makes any difference).

I've streamed from iTunes Music Library on my iPhone (running iOS 13 Beta 1...I've clearly got a thing for experimental/unstable software...) and no problems. There is a lag of about 2-3 seconds between starting streaming and/or changing tracks but that might be environmental or just a consequence of using this type of solution.

EDIT: I've also streamed from Apple Music on my Apple TV 4K with similar results.

I've played around with the volume slider as you mentioned it might be flaky but I can't spot anything obvious, what kind of flakiness did you have on your side? It seems to control the volume well, smoothly (both in terms of the slider in the app, response time from Sonos and no audio distortion of any kind).

I'm so thrilled to have this back up and running. I was using a plugin for HomeBridge which had an experinental AirTunes feature but for some reason the developer removed it so when I updated the plugin I lost the AirPlay functionality.

Well done fixing this, even if it is currently held together with string and stickytape, I've subscribed to your repo so will watch for updates and feel free to give me a shout if you need anything testing.

DJBenson avatar Jun 05 '19 15:06 DJBenson

Thanks @DJBenson.

I have the same lag. I actually thought it was an issue with my wifi as it's really really bad. Good to know though...I can do a bit of tinkering to see if I can get it sped up a little bit. No idea where to start with it at the moment but I'm sure I'll learn as I go. The volume just seemed a little out of sync at times....maybe that's how it always was?? I've never had this installed so not sure what it was like before.

Glad it's working well for you though. If you have any issues, drop me a ticket on the repo 👍

eeston avatar Jun 05 '19 15:06 eeston

I've been running it for quite some time in various guises as each Sonos update seemed to break things until one of the most recent updates which killed it. The lag has always been there, I guess it's understandable given the conversion that's going on by the devices not being able to "speak pure AirPlay" as it were.

Thanks again, very happy to have AirPlay back on my Sonos kit again.

DJBenson avatar Jun 05 '19 19:06 DJBenson