From 5bd69a33e441565b767c43bd66f9082da6a77f4d Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Thu, 20 Feb 2020 20:34:16 +0000 Subject: [PATCH] Deprecate coordinator method since it'll always return the Speaker's IP on > 9.1 --- src/device.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/device.rs b/src/device.rs index c4626e3..97afacb 100644 --- a/src/device.rs +++ a/src/device.rs @@ -98,6 +98,7 @@ } /// Get the coordinator for this speaker. + #[deprecated(note = "Broken on Sonos 9.1")] pub fn coordinator(&self) -> Result { let mut resp = reqwest::blocking::get(&format!("http://{}:1400/status/topology", self.ip)) .chain_err(|| ErrorKind::DeviceUnreachable)?; @@ -118,6 +119,13 @@ // parse the topology xml let elements = Element::parse(content.as_bytes()).chain_err(|| ErrorKind::ParseError)?; + + if elements.children.is_empty() { + // on Sonos 9.1 this API will always return an empty string in which case we'll return + // the current speaker's IP as the 'coordinator' + return Ok(self.ip); + } + let zone_players = elements .get_child("ZonePlayers") .chain_err(|| ErrorKind::ParseError)?; -- rgit 0.1.3