@george.talusan/eufy-robovac-js 0.0.15 → 0.0.16
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/lib/RoboVac.js +4 -4
- package/lib/RoboVac.test.js +52 -2
- package/package.json +3 -2
package/lib/RoboVac.js
CHANGED
|
@@ -390,9 +390,8 @@ class RoboVac extends EventEmitter
|
|
|
390
390
|
if (this.docked()) {
|
|
391
391
|
throw new Error('RoboVac is already home');
|
|
392
392
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
}
|
|
393
|
+
// Some models (e.g. RoboVac 30C, G10 Hybrid, G30 Edge) accept the go home
|
|
394
|
+
// DP but never report it, so send it even if it has not been seen yet.
|
|
396
395
|
const b = this.dps[COMMAND.goHome];
|
|
397
396
|
if (b === flag) {
|
|
398
397
|
return;
|
|
@@ -408,7 +407,8 @@ class RoboVac extends EventEmitter
|
|
|
408
407
|
return true;
|
|
409
408
|
}
|
|
410
409
|
if (!Object.hasOwn(this.dps, COMMAND.goHome)) {
|
|
411
|
-
|
|
410
|
+
// Never reported by some models; not seen means not going home.
|
|
411
|
+
return false;
|
|
412
412
|
}
|
|
413
413
|
return this.dps[COMMAND.goHome];
|
|
414
414
|
}
|
package/lib/RoboVac.test.js
CHANGED
|
@@ -90,6 +90,36 @@ describe('RoboVac', () => {
|
|
|
90
90
|
vac.dps = null;
|
|
91
91
|
strictEqual(vac.error(), 'no error');
|
|
92
92
|
});
|
|
93
|
+
|
|
94
|
+
it('returns fallback values when dps is null', () => {
|
|
95
|
+
const vac = makeVac();
|
|
96
|
+
vac.dps = null;
|
|
97
|
+
strictEqual(vac.workMode(), 'unknown');
|
|
98
|
+
strictEqual(vac.activity(), 'unknown');
|
|
99
|
+
strictEqual(vac.batteryLevel(), -1);
|
|
100
|
+
strictEqual(vac.runtime(), -1);
|
|
101
|
+
strictEqual(vac.coverage(), -1);
|
|
102
|
+
strictEqual(vac.consumables(), '');
|
|
103
|
+
strictEqual(vac.status(), '');
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('throws when dps is null for commands without fallback values', () => {
|
|
107
|
+
const vac = makeVac();
|
|
108
|
+
vac.dps = null;
|
|
109
|
+
const expected = { message: 'no data points available yet' };
|
|
110
|
+
for (const command of [
|
|
111
|
+
() => vac.goingHome(),
|
|
112
|
+
() => vac.volume(),
|
|
113
|
+
() => vac.multimaps(),
|
|
114
|
+
() => vac.boostIQ(),
|
|
115
|
+
() => vac.rooms(),
|
|
116
|
+
() => vac.voice(),
|
|
117
|
+
() => vac.hello(),
|
|
118
|
+
() => vac.autoReturn(),
|
|
119
|
+
]) {
|
|
120
|
+
throws(command, expected);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
93
123
|
});
|
|
94
124
|
|
|
95
125
|
describe('getters (with dps populated)', () => {
|
|
@@ -282,6 +312,12 @@ describe('RoboVac', () => {
|
|
|
282
312
|
it('throws when activity key is missing', () => {
|
|
283
313
|
throws(() => makeVac().goingHome(), { message: 'RoboVac does not support this command' });
|
|
284
314
|
});
|
|
315
|
+
|
|
316
|
+
it('returns false when goHome has never been reported', () => {
|
|
317
|
+
const vac = makeVac();
|
|
318
|
+
vac.dps = { '15': 'Cleaning' };
|
|
319
|
+
strictEqual(vac.goingHome(), false);
|
|
320
|
+
});
|
|
285
321
|
});
|
|
286
322
|
|
|
287
323
|
describe('commands (via set)', () => {
|
|
@@ -365,6 +401,16 @@ describe('RoboVac', () => {
|
|
|
365
401
|
deepStrictEqual(call.arguments[0].data, { '102': 'Max' });
|
|
366
402
|
});
|
|
367
403
|
|
|
404
|
+
it('clean speed commands throw when unsupported', async () => {
|
|
405
|
+
const unsupportedVac = makeVac();
|
|
406
|
+
unsupportedVac.dps = {};
|
|
407
|
+
const expected = { message: 'RoboVac does not support this command' };
|
|
408
|
+
await rejects(() => unsupportedVac.setCleanSpeedQuiet(), expected);
|
|
409
|
+
await rejects(() => unsupportedVac.setCleanSpeedStandard(), expected);
|
|
410
|
+
await rejects(() => unsupportedVac.setCleanSpeedTurbo(), expected);
|
|
411
|
+
await rejects(() => unsupportedVac.setCleanSpeedMax(), expected);
|
|
412
|
+
});
|
|
413
|
+
|
|
368
414
|
it('setBoostIQ() sends when value differs', async () => {
|
|
369
415
|
await vac.setBoostIQ(false);
|
|
370
416
|
const call = vac.device.set.mock.calls.at(-1);
|
|
@@ -443,10 +489,14 @@ describe('RoboVac', () => {
|
|
|
443
489
|
await rejects(() => vac.goHome(true), { message: 'RoboVac is already home' });
|
|
444
490
|
});
|
|
445
491
|
|
|
446
|
-
it('
|
|
492
|
+
it('sends goHome even when it has never been reported', async () => {
|
|
447
493
|
const vac = makeVac();
|
|
494
|
+
vac.connected = true;
|
|
495
|
+
vac.device = { set: mock.fn(() => Promise.resolve()) };
|
|
448
496
|
vac.dps = { '15': 'Cleaning' };
|
|
449
|
-
await
|
|
497
|
+
await vac.goHome(true);
|
|
498
|
+
const call = vac.device.set.mock.calls.at(-1);
|
|
499
|
+
deepStrictEqual(call.arguments[0].data, { '101': true });
|
|
450
500
|
});
|
|
451
501
|
});
|
|
452
502
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@george.talusan/eufy-robovac-js",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./lib/RoboVac.js"
|
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
"node": ">=22"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
|
+
"build": "npm pack --dry-run",
|
|
16
17
|
"lint": "eslint lib",
|
|
17
18
|
"prepack": "npm run lint",
|
|
18
|
-
"test": "node --test lib/*.test.js"
|
|
19
|
+
"test": "node --test --experimental-test-coverage --test-coverage-lines=75 --test-coverage-branches=75 --test-coverage-functions=75 lib/*.test.js"
|
|
19
20
|
},
|
|
20
21
|
"author": "",
|
|
21
22
|
"license": "ISC",
|