Find valid audio inputs

32 views
Skip to first unread message

George Shaw

unread,
Dec 1, 2020, 11:31:03 PM12/1/20
to SoCo - Sonos Controller
In order to obtain the names of RCA audio inputs I added the AudioIn service to soco. However, it does not seem to indicate which inputs are connected and valid. I must have missed it somewhere. Anyone know where such a flag is at?

Psychlist

unread,
Dec 2, 2020, 7:06:12 AM12/2/20
to SoCo - Sonos Controller
The Sonos apps will only show a Line-In input when a cable is connected. Are there entries in the AudioIn service for inputs that don't have a cable connected?

George Shaw

unread,
Dec 2, 2020, 12:41:11 PM12/2/20
to SoCo - Sonos Controller
AudioIn service is present on all my devices, with or without anything plugged in. Makes sense, as the Sonos App shows the input, just grayed out, and the default name it shows is precisely what is returned by the Action function. So I just have to look harder. It would be nice for sonos-cli to be able to enumerate only valid AudioIn sources.

Psychlist

unread,
Dec 2, 2020, 1:14:21 PM12/2/20
to SoCo - Sonos Controller
Thanks -- that's interesting.

George Shaw

unread,
Dec 2, 2020, 8:53:08 PM12/2/20
to SoCo - Sonos Controller
So it is only available as an event. When you subscribe to "audioIn" the first thing you will get is something like:

<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0"><e:property><AudioInputName>Audio Component</AudioInputName></e:property><e:property><Icon>AudioComponent</Icon></e:property><e:property><LineInConnected>0</LineInConnected></e:property><e:property><LeftLineInLevel>1</LeftLineInLevel></e:property><e:property><RightLineInLevel>1</RightLineInLevel></e:property></e:propertyset>

LineInConnected is a bool, as specified in the LineIn1.xml.

Note that if you are using a current version of python you will have to fix soco/events.py, as it is still using the depreciated isAlive() rather than is_alive(). Also, if you have logging turned on you will notice that the events code tries to do an HTTP GET during shutdown for some reason.

Psychlist

unread,
Dec 3, 2020, 3:48:50 AM12/3/20
to SoCo - Sonos Controller
On Thursday, December 3, 2020 at 1:53:08 AM UTC gfisch wrote:

Note that if you are using a current version of python you will have to fix soco/events.py, as it is still using the depreciated isAlive() rather than is_alive().

Just to expand in case anyone else comes across this message: this is a problem for Python 3.9+ only, and will be fixed in SoCo 0.21. Details at [1]. In the meantime, it can be patched in one's own client code using:

from Threading import Thread
Thread.isAlive = Thread.is_alive

This approach works with all versions of Python supported by SoCo (and will continue working once SoCo 0.21 is released).

Barry4679

unread,
Dec 14, 2020, 3:37:02 AM12/14/20
to SoCo - Sonos Controller
Thanks Psychlist, I am on Python 3.9 and SoCo 0.21. I was struggling with that problem..
There is a capitalisation error in you code though ... s/be:

from threading import Thread 
Thread.isAlive = Thread.is_alive  

Psychlist

unread,
Dec 14, 2020, 6:24:09 AM12/14/20
to SoCo - Sonos Controller
That's correct. Sorry for the typo.
Reply all
Reply to author
Forward
0 new messages