From 011cd36c375200c90b72999ddf7b6687ad6a431d Mon Sep 17 00:00:00 2001 From: Dmitry Bedrin Date: Thu, 14 May 2020 14:22:46 +0300 Subject: [PATCH 1/2] Vacuum respone check should be case insensitive --- lib/devices/vacuum.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/devices/vacuum.js b/lib/devices/vacuum.js index 350ac8f..2fa0302 100644 --- a/lib/devices/vacuum.js +++ b/lib/devices/vacuum.js @@ -12,7 +12,7 @@ function checkResult(r) { //console.log(r) // {"result":0,"id":17} = Firmware 3.3.9_003095 (Gen1) // {"result":["ok"],"id":11} = Firmware 3.3.9_003194 (Gen1), 3.3.9_001168 (Gen2) - if( r !== 0 && r[0] !== 'ok' ) { + if (!(r && r[0] && r[0].toLowerCase() === "ok")) { throw new Error('Could not complete call to device'); } } From 869c8783de86a81dc52263e7f1140fdba4f81959 Mon Sep 17 00:00:00 2001 From: Dmitry Bedrin Date: Sun, 17 May 2020 00:50:30 +0300 Subject: [PATCH 2/2] Support {"result":0,"id":17} response --- lib/devices/vacuum.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/devices/vacuum.js b/lib/devices/vacuum.js index 2fa0302..e256c49 100644 --- a/lib/devices/vacuum.js +++ b/lib/devices/vacuum.js @@ -9,10 +9,10 @@ const MiioApi = require('../device'); const BatteryLevel = require('./capabilities/battery-level'); function checkResult(r) { - //console.log(r) // {"result":0,"id":17} = Firmware 3.3.9_003095 (Gen1) - // {"result":["ok"],"id":11} = Firmware 3.3.9_003194 (Gen1), 3.3.9_001168 (Gen2) - if (!(r && r[0] && r[0].toLowerCase() === "ok")) { + // {"result":["ok"],"id":11} = Firmware 3.3.9_003194 (Gen1), 3.3.9_001168 (Gen2) + // {"result":["OK"],"id":11} = Firmware 1.3.0_0752 on Xiaowa E202-02 + if (!(r && (r === 0 || (r[0] && (r[0] === "ok" || r[0] === "OK")) ) )) { throw new Error('Could not complete call to device'); } }