homebridge-roborock-vacuum 1.4.7 → 1.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/roborockLib/roborockAPI.js +43 -14
package/package.json
CHANGED
|
@@ -71,6 +71,11 @@ class Roborock {
|
|
|
71
71
|
|
|
72
72
|
this.pendingRequests = new Map();
|
|
73
73
|
|
|
74
|
+
// Throttle repeated transient errors (timeouts/retries) so the log
|
|
75
|
+
// is not flooded when a device keeps failing the same request.
|
|
76
|
+
this.transientErrorLog = new Map();
|
|
77
|
+
this.transientErrorLogInterval = 10 * 60 * 1000; // 10 min
|
|
78
|
+
|
|
74
79
|
this.localDevices = {};
|
|
75
80
|
this.remoteDevices = new Set();
|
|
76
81
|
|
|
@@ -1804,21 +1809,45 @@ class Roborock {
|
|
|
1804
1809
|
}
|
|
1805
1810
|
|
|
1806
1811
|
async catchError(error, attribute, duid, model) {
|
|
1807
|
-
if (error) {
|
|
1808
|
-
|
|
1809
|
-
error.toString().includes("retry") ||
|
|
1810
|
-
error.toString().includes("locating") ||
|
|
1811
|
-
error.toString().includes("timed out after 10 seconds")
|
|
1812
|
-
) {
|
|
1813
|
-
this.log.warn(
|
|
1814
|
-
`Failed to execute ${attribute} on robot ${duid} (${model || "unknown model"}): ${error}`
|
|
1815
|
-
);
|
|
1816
|
-
} else {
|
|
1817
|
-
this.log.error(
|
|
1818
|
-
`Failed to execute ${attribute} on robot ${duid} (${model || "unknown model"}): ${error.stack || error}`
|
|
1819
|
-
);
|
|
1820
|
-
}
|
|
1812
|
+
if (!error) {
|
|
1813
|
+
return;
|
|
1821
1814
|
}
|
|
1815
|
+
|
|
1816
|
+
const errorText = error.toString();
|
|
1817
|
+
const isTransient =
|
|
1818
|
+
errorText.includes("retry") ||
|
|
1819
|
+
errorText.includes("locating") ||
|
|
1820
|
+
errorText.includes("timed out after 10 seconds");
|
|
1821
|
+
|
|
1822
|
+
if (isTransient) {
|
|
1823
|
+
this.logTransientError(error, attribute, duid, model);
|
|
1824
|
+
} else {
|
|
1825
|
+
this.log.error(
|
|
1826
|
+
`Failed to execute ${attribute} on robot ${duid} (${model || "unknown model"}): ${error.stack || error}`
|
|
1827
|
+
);
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
logTransientError(error, attribute, duid, model) {
|
|
1832
|
+
const key = `${duid}:${attribute}`;
|
|
1833
|
+
const now = Date.now();
|
|
1834
|
+
const entry = this.transientErrorLog.get(key);
|
|
1835
|
+
|
|
1836
|
+
if (entry && now - entry.lastLogged < this.transientErrorLogInterval) {
|
|
1837
|
+
entry.suppressedCount++;
|
|
1838
|
+
return;
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
const suppressedNote =
|
|
1842
|
+
entry && entry.suppressedCount > 0
|
|
1843
|
+
? ` (suppressed ${entry.suppressedCount} identical message(s) in the last ${Math.round(this.transientErrorLogInterval / 60000)} min)`
|
|
1844
|
+
: "";
|
|
1845
|
+
|
|
1846
|
+
this.log.warn(
|
|
1847
|
+
`Failed to execute ${attribute} on robot ${duid} (${model || "unknown model"}): ${error}${suppressedNote}`
|
|
1848
|
+
);
|
|
1849
|
+
|
|
1850
|
+
this.transientErrorLog.set(key, { lastLogged: now, suppressedCount: 0 });
|
|
1822
1851
|
}
|
|
1823
1852
|
|
|
1824
1853
|
async app_start(duid) {
|