Advice on how to use swyh-rs-cli to connect to a stereo pair of Sonos speakers
Closed this issue · 16 comments
Hello dheijl,
Could you advise if the following command I am using for swyh-rs-cli is correct?
swyh-rs-cli.exe -o "<ipaddress1>,<ipaddress2>" -r true -s "<speakersource>" -f wav+u64maxchunked -e <netadapter> -S true -v <volumelevel>
My example;
swyh-rs-cli.exe -o "192.168.111.244,192.168.111.245" -r true -s "Speakers (Realtek(R) Audio)" -f wav+u64maxchunked -e 192.168.111.60 -S true -v 55
After several syntax iterations, the above seems to work but I would appreciate your input for confirmation as it was not clear to me how best to handle stereo Sonos speakers using the CLI.
And lastly, I have had occasional issues with the stereo pair not working as normal after the CLI session has ended/terminated. Either the right or left speaker does not play. A reboot of both speakers initially resolved the issue but this was cumbersome and so I reconnected to them with swyh-rs (CLI or GUI) but rather than Ctrl-C or Closing the window, I forcibly terminated the process. This results in the stereo pair being "released" and back working as a pair. Odd quirk - Any ideas?
Thank you for all you do in providing this software. It is greatly appreciated.
Boyd
Currently swyh-rs has no knowledge of the "stereo pair" concept. When swyh-rs is stopped it will ask all currently active players to stop playing, and this seems to break the Sonos stereo pair. As I don't own any Sonos speakers myself there is little I can do myself, but I'm open to experimenting with your help. As it is now there is no code in swyh-rs that has knowledge about the kind or make/brand of player it is streaming to.
EDIT: what happens when you let swyh-rs play only to the "master speaker" of the stereo pair?
Thank you for explaining. I am happy to carry out any experiments you may require.
In answer to your question, it plays on both if the "master" is selected. Trouble is, I do not know which speaker happens to be the master at any one time. It can change which prevents me automating the process of streaming.
Is adding the option of using a unique device name substring instead of the ip address a solution?
These are the names detected.
Found new renderer Bedroom - Sonos One Media Renderer - RINCON_7828CACD42CA01400 Sonos One at 192.168.111.244
Found new renderer Bedroom - Sonos One Media Renderer - RINCON_38420B65B1EA01400 Sonos One at 192.168.111.245
They are constants so I think it would work great. To correct the closing issue, would we still need to know which is the master so that the stream can be terminated in the right order?
If you stream to the master only there should be no closing issue as only the master will be asked to stop playing.
I'll make a beta release for you to test.
I still had issues. In my case, I have a script which automates the connection to Sonos and muting of system speakers. As there is no current way of knowing which is the master speaker (as it changes), how else could I only connect to the master?
I can understand that the ip address of the master changes, as it is assigned by DHCP. But the device name of the master should not change, as according to the Sonos community it is the first speaker selected when you create the stereo pair in the Sonos app. Does it not work that way in your setup?
I have assumed the "master" can change not because of IP addresses, as mine have reservations, but after the result of grouping/ungrouping or rebooting. I cannot confirm this as I have not paid attention to device names but I shall do so from now on.
Using the GUI, should only one be selected either nothing will play or sound will only come from one speaker. Both must be selected (although I seem to recall this was not always the case). Closing/reopening the app, having had only one selected, seems to automatically correct the situation and both are selected and playing fine. Upon normal close, in either situation, results in only one speaker working and cannot be corrected unless the app is reopened and forcibly terminated.
Could the CLI allow for connecting to multiple device names? Or can logic be implemented to detect pairs and/or masters?
Happy to carry out whatever is required as I appreciate the fact you do not own a Sonos speaker making this difficult for you.
Perhaps I should simply make the "stop play" on termination optional?
I couldn't say how to handle this without experimenting. I do think it's important for the CLI to accept multiple device names. Then we ensure connectivity.
I'll try to implement both.
I've published a new release 1.11.5 The CLI now supports player names instead of IP addresses too. Any unique substring of the player name (case sensitive) will do. You can't mix names and IP addresses: it's all names or all IP addresses.
I'm hesitant to implement the other change, as it seems to me more of a bug in the Sonos Stereo Pair implementation than a shortcoming in swyh-rs. In theory if you only ever stream to the "master" you should not run into problems.
Could you give an example of syntax as it's not clear?
I may have it. I am using swyh-rs-cli -o "Bedroom - Sonos One Media Renderer - RINCON_38420B65B1EA01400" -r true -s "Speakers (Realtek(R) Audio)" -f wav+u64maxchunked -e 192.168.111.60 -S true -v 20
and it works even when closing. If the master never changes then this resolves my issue. I am in your debt. Thank you.
I'm glad that your issue seems solved! As an aside, even -o 3842
should work as this sub-string is unique to the device name of the master.
This also true for selecting the sound source IIRC.
I suppose it's OK to close this now. And thanks for raising the issue, as using swyh-rs -cli improved as a result! I have also updated the readme with the information about Sonos stereo pairs.