From d601fc185c6b9a2c09be5c09e4967a057f12131e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorben=20G=C3=BCnther?= Date: Sun, 13 Feb 2022 21:23:36 +0100 Subject: [PATCH] Use API to retrieve local device ID for filtering /rest/system/connections returns the local device as well (as unconnected). Filtering out by connection status could falsify the output. --- status.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/status.go b/status.go index a86c304..37c30eb 100644 --- a/status.go +++ b/status.go @@ -5,6 +5,10 @@ import ( "log" ) +type SystemStatus struct { + MyID string `json:"myID"` +} + type LocalStatus struct { Completion float64 `json:"completion"` } @@ -35,15 +39,21 @@ func (client *Client) localStatus() *LocalStatus { func (client *Client) remoteStatus() *RemoteStatus { var totalStatus RemoteStatus var connections Connections + var systemStatus SystemStatus + + err := client.get("/rest/system/status", &systemStatus) + if err != nil { + log.Fatal(err) + } - err := client.get("/rest/system/connections", &connections) + err = client.get("/rest/system/connections", &connections) if err != nil { log.Fatal(err) } var connectedDevices []string - for key, con := range connections.List { - if con.Connected { + for key := range connections.List { + if key != systemStatus.MyID { connectedDevices = append(connectedDevices, key) } } -- 2.44.0