nfarina / homebridge-sonos

Sonos plugin for homebridge: https://github.com/nfarina/homebridge
155 stars 52 forks source link

Home bridge finding router not sonos speakers #9

Open garethwebber opened 8 years ago

garethwebber commented 8 years ago

Hi

I have my sonos speakers so they connect over wifi rather than over SonosNet. I think this is causing problems for the search code. The search runs and dumping out the responses shows the devices are found fine by the UDP ping in the sonos lib code (see below).

In the main sonos code, it seems to be that the code sees my router (which is probably what is forwarding the UDP packets back). Should the code not read the IP of the devices from the location field rather than the rinfo field?

TTP/1.1 200 OK CACHE-CONTROL: max-age = 1800 EXT: LOCATION: http://192.168.0.2:1400/xml/device_description.xml SERVER: Linux UPnP/1.0 Sonos/31.8-24090 (ZP90) ST: urn:schemas-upnp-org:device:ZonePlayer:1 USN: uuid:RINCON_changedid::urn:schemas-upnp-org:device:ZonePlayer:1 X-RINCON-HOUSEHOLD: Sonos_changedid X-RINCON-BOOTSEQ: 27 X-RINCON-WIFIMODE: 0

Found sonos device at 192.168.0.1 Ignoring - no description returned HTTP/1.1 200 OK CACHE-CONTROL: max-age = 1800 EXT: LOCATION: http://192.168.0.5:1400/xml/device_description.xml SERVER: Linux UPnP/1.0 Sonos/31.8-24090 (ZPS5) ST: urn:schemas-upnp-org:device:ZonePlayer:1 USN: uuid:RINCON_changedid::urn:schemas-upnp-org:device:ZonePlayer:1 X-RINCON-HOUSEHOLD: Sonos_changedid X-RINCON-BOOTSEQ: 59 X-RINCON-WIFIMODE: 0

Found sonos device at 192.168.0.1 HTTP/1.1 200 OK CACHE-CONTROL: max-age = 1800 EXT: LOCATION: http://192.168.0.9:1400/xml/device_description.xml SERVER: Linux UPnP/1.0 Sonos/31.8-24090 (ZPS3) ST: urn:schemas-upnp-org:device:ZonePlayer:1 USN: uuid:RINCON_changedid::urn:schemas-upnp-org:device:ZonePlayer:1 X-RINCON-HOUSEHOLD: Sonos_changedid X-RINCON-BOOTSEQ: 67 X-RINCON-WIFIMODE: 0

Found sonos device at 192.168.0.1 HTTP/1.1 200 OK CACHE-CONTROL: max-age = 1800 EXT: LOCATION: http://192.168.0.37:1400/xml/device_description.xml SERVER: Linux UPnP/1.0 Sonos/31.8-24090 (ZPS1) ST: urn:schemas-upnp-org:device:ZonePlayer:1 USN: uuid:RINCON_changedid::urn:schemas-upnp-org:device:ZonePlayer:1 X-RINCON-HOUSEHOLD: Sonos_changedid X-RINCON-BOOTSEQ: 54 X-RINCON-WIFIMODE: 0

Found sonos device at 192.168.0.1 Ignoring - no description returned Ignoring - no description returned Ignoring - no description returned

garethwebber commented 8 years ago

This seems to work for me:

*** sonos.js    2016-01-02 13:31:45.249519496 +0000
--- sonos.js.old    2016-01-02 13:24:15.542317344 +0000
***************
*** 769,777 ****
        var modelCheck = buffer.match(/SERVER.*\((.*)\)/);
        var model = (modelCheck.length > 1 ? modelCheck[1] : null);

!       var modelip = buffer.match(/LOCATION: http:\/\/(.*):1400\/xml\/device_description\.xml/)[1];
! 
!       _this.emit('DeviceAvailable', new Sonos(modelip), model);
      }
    });
--- 769,774 ----
        var modelCheck = buffer.match(/SERVER.*\((.*)\)/);
        var model = (modelCheck.length > 1 ? modelCheck[1] : null);

!       _this.emit('DeviceAvailable', new Sonos(rinfo.address), model);
      }
    });