orcema / node-red-google-notify

6 stars 0 forks source link

Paired speakers doesn't work and crashes Node Red #7

Open kenni opened 2 years ago

kenni commented 2 years ago

Running latest Home Assistant 2021.12.10 on Home Assistant OS 7.1. Latest Node Red 10.3.4 installed as an Add-On.

Casting to one speaker works flawlessly, but today I added another speaker and paired them for stereo use through Google Home. I'm now unable to cast to the group or any of the speakers, as Node Red crashes when I try.

Overview of my two speakers and the group when searching for devices using the magnifying glass:

Screenshot 2022-01-20 at 22 55 51

I noticed that when selecting the group-device ("Google Cast Group.Køkken - Nest Audio"), the name is set to "Nest Audio.Køkken - Nest Audio 1" and not the group name. It might be as designed, I just wanted to mention it in case it's part of the root cause of the issue.

Trying to cast something crashes Node Red as can be seen in the log below.

Let me know if I can provide any further useful information or help out with testing. Thank you :)


`20 Jan 23:04:21 - [info] Started flows fileServer listening on ip 10.10.10.20 and port 8098 20 Jan 23:04:21 - [info] [mqtt-broker:Home Assistant] Connected to broker: mqtt://localhost:1883 20 Jan 23:04:26 - [info] [server:Home Assistant] Connecting to http://supervisor/core 20 Jan 23:04:26 - [info] [server:Home Assistant] Connecting to http://supervisor/core 20 Jan 23:04:26 - [info] [server:Home Assistant] Connecting to http://supervisor/core 20 Jan 23:04:26 - [info] [server:Home Assistant] Connected to http://supervisor/core 20 Jan 23:04:26 - [info] [server:Home Assistant] Connected to http://supervisor/core 20 Jan 23:04:26 - [info] [server:Home Assistant] Connected to http://supervisor/core new message ----- Queued messages [ { devicePlaySettings: { msg: [Object], sourceNode: [GoogleNotify], ip: '10.10.10.80', playVolumeLevel: 0.5, playMessage: 'Testing paired speakers', language: 'en', speakSlow: false, mediaServerUrl: 'http://10.10.10.20', mediaServerPort: '8098', cacheFolder: '/tmp' }, callback: [Function (anonymous)] } ] Queued messages [ { devicePlaySettings: { msg: [Object], sourceNode: [GoogleNotify], ip: '10.10.10.80', playVolumeLevel: 0.5, playMessage: 'Testing paired speakers', language: 'en', speakSlow: false, mediaServerUrl: 'http://10.10.10.20', mediaServerPort: '8098', cacheFolder: '/tmp' }, callback: [Function (anonymous)] } ] setting up mediaPlayUrl preparing socket for connection to device connecting with device preparing player on device 20 Jan 23:05:04 - [red] Uncaught Exception: 20 Jan 23:05:04 - [error] ReferenceError: error is not defined at /opt/node_modules/google-notify/google-notify.js:373:18 at /opt/node_modules/castv2-client/lib/senders/platform.js:95:20 at /opt/node_modules/castv2-client/lib/controllers/receiver.js:51:14 at fn.onmessage (/opt/node_modules/castv2-client/lib/controllers/request-response.js:27:7) at fn.emit (node:events:402:35) at Channel.onmessage (/opt/node_modules/castv2-client/lib/controllers/controller.js:16:10) at Channel.emit (node:events:390:28) at Client.onmessage (/opt/node_modules/castv2/lib/channel.js:23:10) at Client.emit (node:events:402:35) at PacketStreamWrapper.onpacket (/opt/node_modules/castv2/lib/client.js:81:10) [23:05:04] INFO: Starting Node-RED...

start node $NODE_OPTIONS node_modules/node-red/red.js "--settings" "/etc/node-red/config.js" 20 Jan 23:05:04 - [info] Welcome to Node-RED

20 Jan 23:05:04 - [info] Node-RED version: v2.1.6 ...`

kenni commented 2 years ago

And an export of the nodes used for testing:

[{"id":"8e1c56d8d174ae79","type":"google-notify","z":"32ec540f3d9e1259","server":"402714a9505922a2","label":"Test","playVolumeLevel":"","playMessage":"Testing paired speakers","language":"config","speakSlow":"false","mediaUrl":"","mediaType":"mp3","x":670,"y":600,"wires":[[]]},{"id":"62f9f90f7eb7f799","type":"inject","z":"32ec540f3d9e1259","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"10","topic":"","payload":"","payloadType":"date","x":470,"y":600,"wires":[["8e1c56d8d174ae79"]]},{"id":"402714a9505922a2","type":"google-notify-config","ipaddress":"10.10.10.80","name":"Nest Audio.Køkken - Nest Audio 1","language":"en","playVolumeLevel":"50","speakSlow":false,"mediaServerUrl":"","mediaServerPort":"8098","cacheFolder":"/tmp"}]

kenni commented 2 years ago

Could it be that it is just the port that is wrong? Using the node-red-contrib-cast node tells me that the group is on port 32000 instead of 8009:

Screenshot 2022-01-20 at 23 20 02

Using the node-red-contrib-cast node to cast to each of the individual speakers on port 8009 fails with the error "Error: Launch failed. Reason: NOT_ALLOWED"

...while playing to the group and using port 32000 works as expected.

orcema commented 2 years ago

I tried to group 2 speackers of mine in a group like (see figure)

Screenshot 2022-01-21 at 21 20 51

but when i pick a "Google Cast Group" as destination speaker it will play only on one speker e.g. 192.168.10.212 or 192.168.10.217. So whow did you manage to have a Google Cast Group with port 32000 ?

kenni commented 2 years ago

I'm creating a "pair" for stereo output, not a speaker group. The process is described here: https://support.google.com/googlenest/answer/7559493?hl=en&co=GENIE.Platform%3DAndroid

SeveranExp commented 2 years ago

I'm having the same issue, only, node red no longer crashes, but when I send a simple timestamp to it, to trigger a "test" message, it's simply ignored. An additional note, I only had one speaker per room and the automation worked. Couple days ago I bought two google nest audios to pair them together, and moved the previous nest mini which was in that room, to pair with another one in another room. End result is that now neither pairs play on queue. All others are fine, so it seems to be something with paired devices only.

SeveranExp commented 2 years ago

Update: seems to me that the port used by the google home speakers is hard coded and it is the 8009 port. The problem comes up only with paired google speakers. I did a netscan and when casting to a speaker pair, the port was instead 32000. Saw this first on a post in the openHAB forum. So it would seem that we need a way to set up a speaker as paired, or not paired.