🏡 index : ~doyle/sonos.rs.git

author Jordan Doyle <jordan@doyle.la> 2020-02-20 20:34:16.0 +00:00:00
committer Jordan Doyle <jordan@doyle.la> 2020-02-20 20:34:16.0 +00:00:00
commit
5bd69a33e441565b767c43bd66f9082da6a77f4d [patch]
tree
6cbb7a0b6908bdf5d8031d27cd345194b18ad370
parent
566818f69e6ccc4457dd80c359a36a89823f5b09
download
5bd69a33e441565b767c43bd66f9082da6a77f4d.tar.gz

Deprecate coordinator method since it'll always return the Speaker's IP on > 9.1



Diff

 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<IpAddr> {
        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)?;