File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed
Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -2114,7 +2114,7 @@ export class WoLeak extends SwitchbotDevice {
21142114 * @param {Buffer } serviceData - The service data buffer.
21152115 * @param {Buffer } manufacturerData - The manufacturer data buffer.
21162116 * @param {Function } emitLog - The function to emit log messages.
2117- * @returns {Promise<leakServiceData | null> } - Parsed service data or null if invalid.
2117+ * @returns {Promise<waterLeakDetectorServiceData | null> } - Parsed service data or null if invalid.
21182118 */
21192119 static async parseServiceData (
21202120 serviceData : Buffer ,
@@ -2131,7 +2131,7 @@ export class WoLeak extends SwitchbotDevice {
21312131 return null
21322132 }
21332133
2134- const waterLeakDetected = ! ! ( manufacturerData . readUInt8 ( 8 ) & 0b00000001 ) // Bit 0
2134+ const waterLeakDetected = manufacturerData . length > 8 && ! ! ( manufacturerData . readUInt8 ( 8 ) & 0b00000001 ) // Bit 0
21352135 const deviceTampered = ! ! ( manufacturerData . readUInt8 ( 8 ) & 0b00000010 ) // Bit 1
21362136 const batteryLevel = manufacturerData . readUInt8 ( 7 ) & 0b01111111 // Bits 0-6
21372137 const lowBattery = ! ! ( manufacturerData . readUInt8 ( 7 ) & 0b10000000 ) // Bit 7
You can’t perform that action at this time.
0 commit comments