svrooij / node-sonos-ts

:speaker: Sonos control library, use this library in your own appliction.
https://sonos-ts.svrooij.io/
MIT License
84 stars 18 forks source link

TypeError: Cannot read properties of undefined (reading 's:Body') #173

Closed Reinschki closed 1 year ago

Reinschki commented 1 year ago

Hello, i am using sonos2mqtt together with Fhem. A publish with /cmd/ generally fails. As an example, I show below the logging after the publish sonos/cmd/pauseall.

What is going wrong?

2023-01-19T11:01:13.597Z [Information] LogLevel changed to verbose
2023-01-19T11:01:48.656Z [Debug] Mqtt got generic command pauseall
2023-01-19T11:01:48.656Z [Debug] Got generic command pauseall from mqtt
/usr/local/lib/node_modules/sonos2mqtt/node_modules/@svrooij/sonos/lib/services/base-service.js:226
            if (typeof errorResponse['s:Envelope']['s:Body']['s:Fault'] !== 'undefined') {
                                                  ^
TypeError: Cannot read properties of undefined (reading 's:Body')
    at AVTransportService.handleErrorResponse (/usr/local/lib/node_modules/sonos2mqtt/node_modules/@svrooij/sonos/lib/services/base-service.js:226:51)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async AVTransportService.handleRequest (/usr/local/lib/node_modules/sonos2mqtt/node_modules/@svrooij/sonos/lib/services/base-service.js:188:16)
    at async AVTransportService.SoapRequestWithBodyNoResponse (/usr/local/lib/node_modules/sonos2mqtt/node_modules/@svrooij/sonos/lib/services/base-service.js:123:16)
    at async AVTransportService.Pause (/usr/local/lib/node_modules/sonos2mqtt/node_modules/@svrooij/sonos/lib/services/av-transport.service.js:169:53)
    at async SonosDevice.Pause (/usr/local/lib/node_modules/sonos2mqtt/node_modules/@svrooij/sonos/lib/sonos-device.js:938:28)
    at async Promise.all (index 1)
Node.js v17.3.0
2023-01-19T11:01:49.315Z [Information] Starting sonos2mqtt v3.2.0
2023-01-19T11:01:49.324Z [Information] LogLevel changed to information
2023-01-19T11:01:49.399Z [Information] Found 7 sonos speakers
2023-01-19T11:01:49.426Z [Information] Mqtt connection changed to connected: true

Regards Reiner

svrooij commented 1 year ago

can you try with any of the new beta versions? Like 3.2.0-beta.9

Reinschki commented 1 year ago
2023-01-20T06:30:49.642Z [Information] Starting sonos2mqtt v3.2.0-beta.9
2023-01-20T06:30:49.654Z [Information] LogLevel changed to information
2023-01-20T06:30:49.676Z [Information] Found 7 sonos speakers
2023-01-20T06:30:49.707Z [Information] Mqtt connection changed to connected: true
2023-01-20T06:31:59.374Z [Information] Shutdown sonos2mqtt, please wait.
2023-01-20T06:31:59.405Z [Information] Mqtt connection changed to connected: false
2023-01-20T06:32:01.013Z [Information] Starting sonos2mqtt v3.2.0-beta.9
2023-01-20T06:32:01.023Z [Information] LogLevel changed to information
2023-01-20T06:32:01.078Z [Information] Found 7 sonos speakers
2023-01-20T06:32:01.117Z [Information] Mqtt connection changed to connected: true
2023-01-20T06:32:45.350Z [Information] LogLevel changed to verbose
2023-01-20T06:33:01.759Z [Verbose] Publishing state for RINCON_542A1BBE498001400
2023-01-20T06:33:01.759Z [Verbose] Mqtt publish to sonos/RINCON_542A1BBE498001400 [object Object]
2023-01-20T06:33:02.575Z [Debug] Mqtt got generic command pauseall
2023-01-20T06:33:02.575Z [Debug] Got generic command pauseall from mqtt
/usr/local/lib/node_modules/sonos2mqtt/node_modules/@svrooij/sonos/lib/services/base-service.js:237
            if (typeof errorResponse['s:Envelope']['s:Body']['s:Fault'] !== 'undefined') {
                                                  ^
TypeError: Cannot read properties of undefined (reading 's:Body')
    at AVTransportService.handleErrorResponse (/usr/local/lib/node_modules/sonos2mqtt/node_modules/@svrooij/sonos/lib/services/base-service.js:237:51)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async AVTransportService.handleRequest (/usr/local/lib/node_modules/sonos2mqtt/node_modules/@svrooij/sonos/lib/services/base-service.js:199:16)
    at async AVTransportService.SoapRequestWithBodyNoResponse (/usr/local/lib/node_modules/sonos2mqtt/node_modules/@svrooij/sonos/lib/services/base-service.js:133:16)
    at async AVTransportService.Pause (/usr/local/lib/node_modules/sonos2mqtt/node_modules/@svrooij/sonos/lib/services/av-transport.service.js:169:53)
    at async SonosDevice.Pause (/usr/local/lib/node_modules/sonos2mqtt/node_modules/@svrooij/sonos/lib/sonos-device.js:976:28)
    at async Promise.all (index 1)
2023-01-20T06:33:03.449Z [Information] Starting sonos2mqtt v3.2.0-beta.9
2023-01-20T06:33:03.457Z [Information] LogLevel changed to information
2023-01-20T06:33:03.489Z [Information] Found 7 sonos speakers
2023-01-20T06:33:03.519Z [Information] Mqtt connection changed to connected: true
github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 2.6.0-beta.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

svrooij commented 1 year ago

@Reinschki sorry for moving the issue, it seemed like there was an issue in parsing of errors. That is in this library, so I fixed it here.

Can you try this release - v3.2.0-beta.10 to see if that fixes your issue?

Reinschki commented 1 year ago

Hello,

the publish sonos/cmd/pauseall is now working. The log shows this:

2023-01-20T13:01:22.990Z [Information] LogLevel changed to verbose
2023-01-20T13:01:43.312Z [Debug] Mqtt got generic command pauseall
2023-01-20T13:01:43.312Z [Debug] Got generic command pauseall from mqtt
2023-01-20T13:01:43.316Z [Warning] Device %s emitted an error %o
2023-01-20T13:01:43.319Z [Warning] Device %s emitted an error %o
2023-01-20T13:01:43.321Z [Warning] Device %s emitted an error %o
2023-01-20T13:01:43.508Z [Verbose] Mqtt publish to sonos/status/roam/avtransport [object Object]
2023-01-20T13:01:43.909Z [Verbose] Publishing state for RINCON_542A1BBE498001400
2023-01-20T13:01:43.909Z [Verbose] Mqtt publish to sonos/RINCON_542A1BBE498001400 [object Object]
2023-01-20T13:01:46.123Z [Verbose] Publishing state for RINCON_542A1BBE498001400
2023-01-20T13:01:46.123Z [Verbose] Mqtt publish to sonos/RINCON_542A1BBE498001400 [object Object]
2023-01-20T13:02:16.216Z [Verbose] Publishing state for RINCON_542A1BBE498001400
2023-01-20T13:02:16.216Z [Verbose] Mqtt publish to sonos/RINCON_542A1BBE498001400 [object Object]

This

sonos/cmd/notify {"trackUri":"https://cdn.smartersoft-group.com/various/pull-bell-short.mp3","onlyWhenPlaying":false,"timeout":100,"volume":20,"delayMs":700}

Does not work and returns this result in the log

2023-01-20T13:02:16.816Z [Debug] Mqtt got generic command notify
2023-01-20T13:02:16.816Z [Debug] Got generic command notify from mqtt
***@***.***/sonos/lib/services/base-service.js:246
        throw new http_error_1.default(action, response.status, response.statusText);
              ^
HttpError: Http status 405 (Method Not Allowed)
    at RenderingControlService.handleErrorResponse ***@***.***/sonos/lib/services/base-service.js:246:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RenderingControlService.handleRequestAndParseResponse ***@***.***/sonos/lib/services/base-service.js:215:15)
    at async RenderingControlService.SoapRequestWithBody ***@***.***/sonos/lib/services/base-service.js:105:16)
    at async RenderingControlService.GetMute ***@***.***/sonos/lib/services/rendering-control.service.js:56:35)
    at async SonosDevice.GetState ***@***.***/sonos/lib/sonos-device.js:327:27)
    at async SonosDevice.PlayNotification ***@***.***/sonos/lib/sonos-device.js:425:23)
    at async Promise.all (index 1) {
  Action: 'GetMute',
  HttpStatusCode: 405,
  HttpStatusText: 'Method Not Allowed'
}

2023-01-20T13:02:17.597Z [Information] Starting sonos2mqtt v3.2.0-beta.10
2023-01-20T13:02:17.605Z [Information] LogLevel changed to information
2023-01-20T13:02:17.629Z [Information] Found 7 sonos speakers
2023-01-20T13:02:17.659Z [Information] Mqtt connection changed to connected: true
2023-01-20T13:11:20.891Z [Warning] Device %s emitted an error %o
2023-01-20T13:11:20.897Z [Warning] Device %s emitted an error %o
2023-01-20T13:11:20.898Z [Warning] Device %s emitted an error %o

Greetings

Von: Stephan van Rooij @.> Gesendet: Freitag, 20. Januar 2023 11:15 An: svrooij/node-sonos-ts @.> Cc: Reinschki @.>; Mention @.> Betreff: Re: [svrooij/node-sonos-ts] TypeError: Cannot read properties of undefined (reading 's:Body') (Issue #173)

@Reinschki https://github.com/Reinschki sorry for moving the issue, it seemed like there was an issue in parsing of errors. That is in this library, so I fixed it here.

Can you try this release - v3.2.0-beta.10 https://github.com/svrooij/sonos2mqtt/releases/tag/v3.2.0-beta.10 to see if that fixes your issue?

— Reply to this email directly, view it on GitHub https://github.com/svrooij/node-sonos-ts/issues/173#issuecomment-1398176936 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ARYKBBVNLWNCVQWC4DLWQULWTJQSPANCNFSM6AAAAAAUBIDJHM . You are receiving this because you were mentioned. https://github.com/notifications/beacon/ARYKBBVX53QGCQERN5WW73TWTJQSPA5CNFSM6AAAAAAUBIDJHOWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTSTKZ6KQ.gif Message ID: @.***>

svrooij commented 1 year ago

Can you try with 3.2.0-beta.11?

Reinschki commented 1 year ago

Both work! Here is the log:

2023-01-20T17:42:27.658Z [Debug] Mqtt got generic command pauseall
2023-01-20T17:42:27.658Z [Debug] Got generic command pauseall from mqtt
2023-01-20T17:42:27.666Z [Warning] Device RINCON_B8E93706A39001400 emitted an error HttpError: Http status 405 (Method Not Allowed)
2023-01-20T17:42:27.681Z [Warning] Device RINCON_5CAAFD001DB201400 emitted an error SonosError: Sonos error on Pause UPnPError 701 (Transition not available)
2023-01-20T17:42:27.682Z [Warning] Device RINCON_5CAAFDC4E3E801400 emitted an error SonosError: Sonos error on Pause UPnPError 701 (Transition not available)
2023-01-20T17:42:27.684Z [Warning] Device RINCON_5CAAFD238D3C01400 emitted an error SonosError: Sonos error on Pause UPnPError 701 (Transition not available)
2023-01-20T17:42:48.167Z [Debug] Mqtt got generic command notify
2023-01-20T17:42:48.167Z [Debug] Got generic command notify from mqtt
2023-01-20T17:42:48.257Z [Verbose] Mqtt publish to sonos/status/küche/avtransport [object Object]
2023-01-20T17:42:48.272Z [Verbose] Mqtt publish to sonos/status/wohnzimmer/renderingcontrol [object Object]
2023-01-20T17:42:48.273Z [Verbose] Mqtt publish to sonos/status/wohnzimmer/renderingcontrol [object Object]
2023-01-20T17:42:48.310Z [Verbose] Mqtt publish to sonos/status/wohnzimmer/avtransport [object Object]
2023-01-20T17:42:48.329Z [Verbose] Mqtt publish to sonos/status/roam/avtransport [object Object]
2023-01-20T17:42:48.346Z [Verbose] Mqtt publish to sonos/status/flex/avtransport [object Object]
2023-01-20T17:42:48.434Z [Verbose] Mqtt publish to sonos/status/wohnzimmer/renderingcontrol [object Object]
2023-01-20T17:42:48.534Z [Verbose] Mqtt publish to sonos/status/küche/renderingcontrol [object Object]
2023-01-20T17:42:48.555Z [Verbose] Mqtt publish to sonos/status/roam/renderingcontrol [object Object]
2023-01-20T17:42:48.570Z [Verbose] Mqtt publish to sonos/status/flex/renderingcontrol [object Object]
2023-01-20T17:42:48.673Z [Verbose] Publishing state for RINCON_5CAAFD00204401400
2023-01-20T17:42:48.673Z [Verbose] Mqtt publish to sonos/RINCON_5CAAFD00204401400 [object Object]
2023-01-20T17:42:48.673Z [Verbose] Publishing state for RINCON_B8E93765D22801400
2023-01-20T17:42:48.673Z [Verbose] Mqtt publish to sonos/RINCON_B8E93765D22801400 [object Object]
2023-01-20T17:42:48.835Z [Verbose] Publishing state for RINCON_5CAAFD001DB201400
2023-01-20T17:42:48.835Z [Verbose] Mqtt publish to sonos/RINCON_5CAAFD001DB201400 [object Object]
2023-01-20T17:42:48.934Z [Verbose] Publishing state for RINCON_5CAAFDC4E3E801400
2023-01-20T17:42:48.934Z [Verbose] Mqtt publish to sonos/RINCON_5CAAFDC4E3E801400 [object Object]
2023-01-20T17:42:48.954Z [Verbose] Publishing state for RINCON_542A1BBE498001400
2023-01-20T17:42:48.954Z [Verbose] Mqtt publish to sonos/RINCON_542A1BBE498001400 [object Object]
2023-01-20T17:42:48.966Z [Verbose] Mqtt publish to sonos/status/küche/avtransport [object Object]
2023-01-20T17:42:48.971Z [Verbose] Publishing state for RINCON_5CAAFD238D3C01400
2023-01-20T17:42:48.971Z [Verbose] Mqtt publish to sonos/RINCON_5CAAFD238D3C01400 [object Object]
2023-01-20T17:42:49.020Z [Verbose] Mqtt publish to sonos/status/flex/avtransport [object Object]
2023-01-20T17:42:49.132Z [Verbose] Mqtt publish to sonos/status/wohnzimmer/avtransport [object Object]
2023-01-20T17:42:49.137Z [Verbose] Mqtt publish to sonos/status/roam/avtransport [object Object]
2023-01-20T17:42:49.377Z [Verbose] Publishing state for RINCON_5CAAFDC4E3E801400
2023-01-20T17:42:49.377Z [Verbose] Mqtt publish to sonos/RINCON_5CAAFDC4E3E801400 [object Object]
2023-01-20T17:42:49.431Z [Verbose] Publishing state for RINCON_5CAAFD238D3C01400
2023-01-20T17:42:49.431Z [Verbose] Mqtt publish to sonos/RINCON_5CAAFD238D3C01400 [object Object]
2023-01-20T17:42:49.532Z [Verbose] Publishing state for RINCON_5CAAFD00204401400
2023-01-20T17:42:49.532Z [Verbose] Mqtt publish to sonos/RINCON_5CAAFD00204401400 [object Object]
2023-01-20T17:42:49.533Z [Verbose] Publishing state for RINCON_B8E93765D22801400
2023-01-20T17:42:49.533Z [Verbose] Mqtt publish to sonos/RINCON_B8E93765D22801400 [object Object]
2023-01-20T17:42:49.538Z [Verbose] Mqtt publish to sonos/status/flex/avtransport [object Object]
2023-01-20T17:42:49.547Z [Verbose] Publishing state for RINCON_5CAAFD001DB201400
2023-01-20T17:42:49.547Z [Verbose] Mqtt publish to sonos/RINCON_5CAAFD001DB201400 [object Object]
2023-01-20T17:42:49.553Z [Verbose] Publishing state for RINCON_542A1BBE498001400
2023-01-20T17:42:49.553Z [Verbose] Mqtt publish to sonos/RINCON_542A1BBE498001400 [object Object]
2023-01-20T17:42:50.000Z [Verbose] Publishing state for RINCON_5CAAFD238D3C01400
2023-01-20T17:42:50.000Z [Verbose] Mqtt publish to sonos/RINCON_5CAAFD238D3C01400 [object Object]
2023-01-20T17:42:50.106Z [Verbose] Mqtt publish to sonos/status/roam/avtransport [object Object]
2023-01-20T17:42:50.131Z [Verbose] Mqtt publish to sonos/status/wohnzimmer/avtransport [object Object]
2023-01-20T17:42:50.159Z [Verbose] Mqtt publish to sonos/status/küche/avtransport [object Object]
2023-01-20T17:42:50.520Z [Verbose] Publishing state for RINCON_542A1BBE498001400
2023-01-20T17:42:50.520Z [Verbose] Mqtt publish to sonos/RINCON_542A1BBE498001400 [object Object]
2023-01-20T17:42:50.543Z [Verbose] Publishing state for RINCON_5CAAFD001DB201400
2023-01-20T17:42:50.543Z [Verbose] Mqtt publish to sonos/RINCON_5CAAFD001DB201400 [object Object]
2023-01-20T17:42:50.602Z [Verbose] Publishing state for RINCON_5CAAFDC4E3E801400
2023-01-20T17:42:50.602Z [Verbose] Mqtt publish to sonos/RINCON_5CAAFDC4E3E801400 [object Object]
2023-01-20T17:42:51.580Z [Verbose] Mqtt publish to sonos/status/küche/avtransport [object Object]
2023-01-20T17:42:51.656Z [Verbose] Mqtt publish to sonos/status/roam/avtransport [object Object]
2023-01-20T17:42:51.708Z [Verbose] Mqtt publish to sonos/status/flex/avtransport [object Object]
2023-01-20T17:42:51.918Z [Verbose] Mqtt publish to sonos/status/wohnzimmer/avtransport [object Object]
2023-01-20T17:42:51.981Z [Verbose] Publishing state for RINCON_5CAAFDC4E3E801400
2023-01-20T17:42:51.981Z [Verbose] Mqtt publish to sonos/RINCON_5CAAFDC4E3E801400 [object Object]
2023-01-20T17:42:52.030Z [Verbose] Mqtt publish to sonos/status/wohnzimmer/renderingcontrol [object Object]
2023-01-20T17:42:52.032Z [Verbose] Mqtt publish to sonos/status/wohnzimmer/renderingcontrol [object Object]
2023-01-20T17:42:52.056Z [Verbose] Publishing state for RINCON_542A1BBE498001400
2023-01-20T17:42:52.056Z [Verbose] Mqtt publish to sonos/RINCON_542A1BBE498001400 [object Object]
2023-01-20T17:42:52.109Z [Verbose] Publishing state for RINCON_5CAAFD238D3C01400
2023-01-20T17:42:52.109Z [Verbose] Mqtt publish to sonos/RINCON_5CAAFD238D3C01400 [object Object]
2023-01-20T17:42:52.137Z [Verbose] Mqtt publish to sonos/status/roam/renderingcontrol [object Object]
2023-01-20T17:42:52.157Z [Verbose] Mqtt publish to sonos/status/küche/renderingcontrol [object Object]
2023-01-20T17:42:52.170Z [Verbose] Mqtt publish to sonos/status/flex/renderingcontrol [object Object]
2023-01-20T17:42:52.264Z [Verbose] Mqtt publish to sonos/status/wohnzimmer/renderingcontrol [object Object]
2023-01-20T17:42:52.386Z [Verbose] Mqtt publish to sonos/status/küche/avtransport [object Object]
2023-01-20T17:42:52.430Z [Verbose] Publishing state for RINCON_B8E93765D22801400
2023-01-20T17:42:52.430Z [Verbose] Mqtt publish to sonos/RINCON_B8E93765D22801400 [object Object]
2023-01-20T17:42:52.432Z [Verbose] Publishing state for RINCON_5CAAFD00204401400
2023-01-20T17:42:52.432Z [Verbose] Mqtt publish to sonos/RINCON_5CAAFD00204401400 [object Object]
2023-01-20T17:42:52.538Z [Verbose] Publishing state for RINCON_542A1BBE498001400
2023-01-20T17:42:52.538Z [Verbose] Mqtt publish to sonos/RINCON_542A1BBE498001400 [object Object]
2023-01-20T17:42:52.570Z [Verbose] Publishing state for RINCON_5CAAFD238D3C01400
2023-01-20T17:42:52.570Z [Verbose] Mqtt publish to sonos/RINCON_5CAAFD238D3C01400 [object Object]
2023-01-20T17:42:52.612Z [Verbose] Mqtt publish to sonos/status/flex/avtransport [object Object]
2023-01-20T17:42:52.665Z [Verbose] Publishing state for RINCON_5CAAFD001DB201400
2023-01-20T17:42:52.665Z [Verbose] Mqtt publish to sonos/RINCON_5CAAFD001DB201400 [object Object]
2023-01-20T17:42:52.700Z [Verbose] Mqtt publish to sonos/status/roam/avtransport [object Object]
2023-01-20T17:42:52.787Z [Verbose] Publishing state for RINCON_5CAAFDC4E3E801400
2023-01-20T17:42:52.787Z [Verbose] Mqtt publish to sonos/RINCON_5CAAFDC4E3E801400 [object Object]
2023-01-20T17:42:52.825Z [Verbose] Mqtt publish to sonos/status/wohnzimmer/avtransport [object Object]
2023-01-20T17:42:53.074Z [Verbose] Mqtt publish to sonos/status/küche/avtransport [object Object]
2023-01-20T17:42:53.101Z [Verbose] Publishing state for RINCON_542A1BBE498001400
2023-01-20T17:42:53.101Z [Verbose] Mqtt publish to sonos/RINCON_542A1BBE498001400 [object Object]
2023-01-20T17:42:53.224Z [Verbose] Publishing state for RINCON_5CAAFD001DB201400
2023-01-20T17:42:53.224Z [Verbose] Mqtt publish to sonos/RINCON_5CAAFD001DB201400 [object Object]
2023-01-20T17:42:53.475Z [Verbose] Publishing state for RINCON_5CAAFDC4E3E801400
2023-01-20T17:42:53.475Z [Verbose] Mqtt publish to sonos/RINCON_5CAAFDC4E3E801400 [object Object]
2023-01-20T17:42:53.484Z [Verbose] Mqtt publish to sonos/status/wohnzimmer/avtransport [object Object]
2023-01-20T17:42:53.884Z [Verbose] Publishing state for RINCON_5CAAFD001DB201400
2023-01-20T17:42:53.884Z [Verbose] Mqtt publish to sonos/RINCON_5CAAFD001DB201400 [object Object]

thank you

svrooij commented 1 year ago

@Reinschki your welcome, I also so your question on the topic on the fhem forum.

And maybe if you really want to show your appreciation: https://github.com/sponsors/svrooij 😉