Have made some progress, so my questions have changed.
I found that recognising lost or new zones is made easy by the fact that the SoCo object is a set,, ie. use set differences function. ... That's nice :)
I have my eval app subscribing to my Sonos zones, and recognising new and lost Sonos zones.
I am currently making everything thread safe, and crash testing by turning my zones off and on.
I have some difficulty if I turn a zone off just before I start my app. Sometimes the powered down zone happens to coincide with the zone which Sonos has decided should be the one that responds to the SoCo discovery function.
When this happens, there is along delay before SoCp returns to my app following my call to discovery.
In the meantime I see a series of error from the utility libraries that SoCo uses:
- TimeoutError
- urllib3.exceptions.NewConnectionError
- urllib3.exceptions.MaxRetryError
- and requests.exceptions.ConnectionError
A repeat call of the discovery function gives exactly the same result. ... It only gets fixed if I re-power the Sonos zone, which was powered off before my app starts btw.
If I power down a Sonos zone, after my app has started, there is a long delay before SoCo notices that the zone is missing. ... I haven't measured yet, but I guess that it could be around half an hour.
It is good that the SoCo discovery call responds so quickly, but the slow detection of a lost zone is not so good. ... Could you also have the option of a more expensive, but more thorough type of discovery?
When the device is powered off, it device within the SoCo set becomes damaged. device.ip_address responds Ok, but any attempt to access anything deeper, eg. the device.player_name property, raises the slow series of exceptions listed above.
Is there a way that my app could check that a specific SoCo device instance is damaged, because there is a longish delay using a try except block.
thanks.