bencevans / sonos-cli

🎢 Command Line Interface for Sonos
https://www.npmjs.com/package/sonos-cli
53 stars 5 forks source link

list-zones Not working with newest Sonos firmware 9.1 #16

Open TefaTBob opened 6 years ago

TefaTBob commented 6 years ago

Opening this back up as it doesn't seem to be resolved for me?

Here is my output from "DEBUG=sonos* sonos list-zones":

sonos:main Sonos.GetAllGroups() +0ms sonos:service Service._request("GetZoneGroupState" {}) +0ms (node:92743) UnhandledPromiseRejectionWarning: StatusCodeError: 500 - "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">s:ClientUPnPError<UPnPError xmlns=\"urn:schemas-upnp-org:control-1-0\">501</s:Fault></s:Body></s:Envelope>" at new StatusCodeError (/usr/local/lib/node_modules/sonos-cli/node_modules/request-promise-core/lib/errors.js:32:15) at Request.plumbing.callback (/usr/local/lib/node_modules/sonos-cli/node_modules/request-promise-core/lib/plumbing.js:104:33) at Request.RP$callback [as _callback] (/usr/local/lib/node_modules/sonos-cli/node_modules/request-promise-core/lib/plumbing.js:46:31) at Request.self.callback (/usr/local/lib/node_modules/sonos-cli/node_modules/request/request.js:185:22) at Request.emit (events.js:182:13) at Request. (/usr/local/lib/node_modules/sonos-cli/node_modules/request/request.js:1161:10) at Request.emit (events.js:182:13) at IncomingMessage. (/usr/local/lib/node_modules/sonos-cli/node_modules/request/request.js:1083:12) at Object.onceWrapper (events.js:273:13) at IncomingMessage.emit (events.js:187:15) (node:92743) UnhandledPromiseRejectionWarning: 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: 1) (node:92743) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

TefaTBob commented 5 years ago

@bencevans Is this a sonos-cli issue, or something in the way I have node setup?

bencevans commented 5 years ago

I'm getting the same here. Shall take a look.

bencevans commented 5 years ago

Were all your devices grouped? Think it's an issue where when all devices are in a single group the object returned from node-sonos is an object rather than array.

TefaTBob commented 5 years ago

@bencevans Not all the devices are in a single group, but rather 4 of 5 different groups. (I've been using this in my office)

bencevans commented 5 years ago

Hmmm, what version of firmware have you got on the devices? There's been some major breaking changes with Sonos v9.1.

TefaTBob commented 5 years ago

All speakers are now on 9.2 (build 46357250), but CLI has been broken for me from 9.1 yeah.

bencevans commented 5 years ago

I've pushed up a couple of fixes that's sorted things here but I think the issues I was having differ from your own. Could you npm i -g sonos-cli && sonos list-zones and see if that works?

There's still issues with play functionality but tracking that in #20

TefaTBob commented 5 years ago

Same issue still:

DEBUG=sonos* sonos list-zones sonos:main Sonos.GetAllGroups() +0ms sonos:service Service._request("GetZoneGroupState" {}) +0ms (node:6227) UnhandledPromiseRejectionWarning: StatusCodeError: 500 - "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">s:ClientUPnPError<UPnPError xmlns=\"urn:schemas-upnp-org:control-1-0\">501</s:Fault></s:Body></s:Envelope>" at new StatusCodeError (/usr/local/lib/node_modules/sonos-cli/node_modules/request-promise-core/lib/errors.js:32:15) at Request.plumbing.callback (/usr/local/lib/node_modules/sonos-cli/node_modules/request-promise-core/lib/plumbing.js:104:33) at Request.RP$callback [as _callback] (/usr/local/lib/node_modules/sonos-cli/node_modules/request-promise-core/lib/plumbing.js:46:31) at Request.self.callback (/usr/local/lib/node_modules/sonos-cli/node_modules/request/request.js:185:22) at Request.emit (events.js:182:13) at Request. (/usr/local/lib/node_modules/sonos-cli/node_modules/request/request.js:1161:10) at Request.emit (events.js:182:13) at IncomingMessage. (/usr/local/lib/node_modules/sonos-cli/node_modules/request/request.js:1083:12) at Object.onceWrapper (events.js:273:13) at IncomingMessage.emit (events.js:187:15) (node:6227) UnhandledPromiseRejectionWarning: 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: 1) (node:6227) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

bencevans commented 5 years ago

@svrooij wondering if you might have any ideas here... Sonos.GetAllGroups() is throwing a UPnPError 500. It seems to be working fine for my setup. Both myself and @TefaTBob are on Sonos Firmware 9.2.

toabi commented 5 years ago

I get this:

bash-3.2$ DEBUG=sonos* sonos-cli list-zones
  sonos:main Sonos.GetAllGroups() +0ms
  sonos:service Service._request("GetZoneGroupState" {}) +0ms
  sonos:helpers Helpers.ParseXml "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetZoneGroupStateResponse xmlns:u=\"urn:schemas-upnp-org:service:ZoneGroupTopology:1\"><ZoneGroupState>&lt;ZoneGroups&gt;&lt;ZoneGroup Coordinator=&quot;RINCON_000E58REDACTED&quot; ID=&quot;RINCON_000E58REDACTED:3557387302&quot;&gt;&lt;ZoneGroupMember UUID=&quot;RINCON_000E58REDACTED&quot; Location=&quot;http://10.0.10.81:1400/xml/device_description.xml&quot; ZoneName=&quot;Tanzsaal&quot; Icon=&quot;x-rincon-roomicon:living&quot; Configuration=&quot;1&quot; SoftwareVersion=&quot;47.2-59120&quot; MinCompatibleVersion=&quot;46.0-00000&quot; LegacyCompatibleVersion=&quot;36.0-00000&quot; BootSeq=&quot;21&quot; TVConfigurationError=&quot;0&quot; HdmiCecAvailable=&quot;0&quot; WirelessMode=&quot;1&quot; WirelessLeafOnly=&quot;0&quot; HasConfiguredSSID=&quot;1&quot; ChannelFreq=&quot;2462&quot; BehindWifiExtender=&quot;0&quot; WifiEnabled=&quot;1&quot; Orientation=&quot;0&quot; RoomCalibrationState=&quot;4&quot; SecureRegState=&quot;3&quot; VoiceState=&quot;0&quot; AirPlayEnabled=&quot;0&quot; IdleState=&quot;0&quot;/&gt;&lt;/ZoneGroup&gt;&lt;/ZoneGroups&gt;</ZoneGroupState></u:GetZoneGroupStateResponse></s:Body></s:Envelope>" +0ms
  sonos:service Parsed service response as JSON
  sonos:service {
  "s:Envelope": {
    "xmlns:s": "http://schemas.xmlsoap.org/soap/envelope/",
    "s:encodingStyle": "http://schemas.xmlsoap.org/soap/encoding/",
    "s:Body": {
      "u:GetZoneGroupStateResponse": {
        "xmlns:u": "urn:schemas-upnp-org:service:ZoneGroupTopology:1",
        "ZoneGroupState": "<ZoneGroups><ZoneGroup Coordinator=\"RINCON_000E58REDACTED\" ID=\"RINCON_000E58REDACTED:3557387302\"><ZoneGroupMember UUID=\"RINCON_000E58REDACTED\" Location=\"http://10.0.10.81:1400/xml/device_description.xml\" ZoneName=\"Tanzsaal\" Icon=\"x-rincon-roomicon:living\" Configuration=\"1\" SoftwareVersion=\"47.2-59120\" MinCompatibleVersion=\"46.0-00000\" LegacyCompatibleVersion=\"36.0-00000\" BootSeq=\"21\" TVConfigurationError=\"0\" HdmiCecAvailable=\"0\" WirelessMode=\"1\" WirelessLeafOnly=\"0\" HasConfiguredSSID=\"1\" ChannelFreq=\"2462\" BehindWifiExtender=\"0\" WifiEnabled=\"1\" Orientation=\"0\" RoomCalibrationState=\"4\" SecureRegState=\"3\" VoiceState=\"0\" AirPlayEnabled=\"0\" IdleState=\"0\"/></ZoneGroup></ZoneGroups>"
      }
    }
  }
} +40ms
  sonos:helpers Helpers.ParseXml "<ZoneGroups><ZoneGroup Coordinator=\"RINCON_000E58REDACTED\" ID=\"RINCON_000E58REDACTED:35573-87302\"><ZoneGroupMember UUID=\"RINCON_000E58REDACTED\" Location=\"http://10.0.10.81:1400/xml/device_description.xml\" ZoneName=\"Tanzsaal\" Icon=\"x-rincon-roomicon:living\" Configuration=\"1\" SoftwareVersion=\"47.2-59120\" MinCompatibleVersion=\"46.0-00000\" LegacyCompatibleVersion=\"36.0-00000\" BootSeq=\"21\" TVConfigurationError=\"0\" HdmiCecAvailable=\"0\" WirelessMode=\"1\" WirelessLeafOnly=\"0\" HasConfiguredSSID=\"1\" ChannelFreq=\"2462\" BehindWifiExtender=\"0\" WifiEnabled=\"1\" Orientation=\"0\" RoomCalibrationState=\"4\" SecureRegState=\"3\" VoiceState=\"0\" AirPlayEnabled=\"0\" IdleState=\"0\"/></ZoneGroup></ZoneGroups>" +7ms
RINCON_000E58REDACTED:3557387302
  undefined
  undefined
  undefined
  undefined
  undefined
  undefined
  undefined
  undefined
  undefined
  undefined
  undefined
  undefined
  undefined
  undefined
  undefined
  undefined
  undefined
  undefined
  undefined
  undefined
  undefined
  undefined
  undefined

and list-devices then fails with:

(node:25463) UnhandledPromiseRejectionWarning: TypeError: group.ZoneGroupMember.forEach is not a function
    at groups.forEach.group (/usr/local/lib/node_modules/sonos-cli/cmds/listDevices.js:4:29)
    at Array.forEach (<anonymous>)
    at initDevice.getAllGroups.then.groups (/usr/local/lib/node_modules/sonos-cli/cmds/listDevices.js:3:12)
    at process._tickCallback (internal/process/next_tick.js:68:7)
TefaTBob commented 5 years ago

@bencevans Any new luck here?

svrooij commented 5 years ago

Will check tomorrow, how many zones/players do you guys have? Might also been solved by some pr months ago on the sonos lib. That forced all the responses to be arrays...

TefaTBob commented 5 years ago

I believe about 16 Zones. It's an office.

bencevans commented 5 years ago

@TefaTBob could you let us know what version of sonos you're using?

$ npm ls -g --depth=1

The following shows that I'm using sonos@1.9.0 which is working successfully for me (4 zones)

β”œβ”€β”¬ sonos-cli@0.5.2
β”‚ β”œβ”€β”€ minimist@1.2.0
β”‚ β”œβ”€β”€ sonos@1.9.0
β”‚ └── underscore@1.9.1
TefaTBob commented 5 years ago

@bencevans

sonos-cli@0.5.2 β”œβ”€β”€ minimist@1.2.0 β”œβ”€β”€ sonos@1.9.0 └── underscore@1.9.1

Appears to be the same

TefaTBob commented 5 years ago

@bencevans Is there anything else you can think of for me to check on my side as to why this still isn't working for me?

bencevans commented 5 years ago

@TefaTBob identifying what sort of device it's communicating with might be useful. If you're able to load up Wireshark, then following what the Sonos app does and see if you can find where the difference is between sonos-cli/node-sonos should identify the issue.

TefaTBob commented 5 years ago

@bencevans I can see Wireshark recording an HTTP/1.1 500 Internal Server Error\r\n, as well as a UPnP: Error 501 around urn:schemas-upnp-org:control-1-0 in the response. I'll bribe someone on our NW team with beers and see if they can't help me understand what's going on. Maybe some port forwarding got changed. Will report back.

bencevans commented 5 years ago

@TefaTBob comparing the request between that of the Sonos app and node-sonos will probably give the biggest insight to what's being passed to the device wrong.