@george.talusan/eufy-robovac-js 0.0.14 → 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 +7 -6
- package/lib/RoboVac.test.js +52 -2
- package/package.json +7 -2
- package/.claude/settings.local.json +0 -8
- package/.github/dependabot.yml +0 -12
- package/.github/workflows/npm-publish.yml +0 -33
- package/.nvmrc +0 -1
- package/eslint.config.mjs +0 -8
package/lib/RoboVac.js
CHANGED
|
@@ -72,11 +72,12 @@ class RoboVac extends EventEmitter
|
|
|
72
72
|
{
|
|
73
73
|
dps = {};
|
|
74
74
|
|
|
75
|
-
constructor({ ip, deviceId, localKey }) {
|
|
75
|
+
constructor({ ip, deviceId, localKey, version = '3.3' }) {
|
|
76
76
|
super();
|
|
77
77
|
this.ip = ip;
|
|
78
78
|
this.deviceId = deviceId;
|
|
79
79
|
this.localKey = localKey;
|
|
80
|
+
this.version = version;
|
|
80
81
|
this.dps = {};
|
|
81
82
|
this.connected = false;
|
|
82
83
|
}
|
|
@@ -86,7 +87,7 @@ class RoboVac extends EventEmitter
|
|
|
86
87
|
id: this.deviceId,
|
|
87
88
|
key: this.localKey,
|
|
88
89
|
ip: this.ip,
|
|
89
|
-
version:
|
|
90
|
+
version: this.version,
|
|
90
91
|
issueRefreshOnConnect: true,
|
|
91
92
|
});
|
|
92
93
|
|
|
@@ -389,9 +390,8 @@ class RoboVac extends EventEmitter
|
|
|
389
390
|
if (this.docked()) {
|
|
390
391
|
throw new Error('RoboVac is already home');
|
|
391
392
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
}
|
|
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.
|
|
395
395
|
const b = this.dps[COMMAND.goHome];
|
|
396
396
|
if (b === flag) {
|
|
397
397
|
return;
|
|
@@ -407,7 +407,8 @@ class RoboVac extends EventEmitter
|
|
|
407
407
|
return true;
|
|
408
408
|
}
|
|
409
409
|
if (!Object.hasOwn(this.dps, COMMAND.goHome)) {
|
|
410
|
-
|
|
410
|
+
// Never reported by some models; not seen means not going home.
|
|
411
|
+
return false;
|
|
411
412
|
}
|
|
412
413
|
return this.dps[COMMAND.goHome];
|
|
413
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,17 +1,22 @@
|
|
|
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"
|
|
7
7
|
},
|
|
8
|
+
"files": [
|
|
9
|
+
"lib",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
8
12
|
"engines": {
|
|
9
13
|
"node": ">=22"
|
|
10
14
|
},
|
|
11
15
|
"scripts": {
|
|
16
|
+
"build": "npm pack --dry-run",
|
|
12
17
|
"lint": "eslint lib",
|
|
13
18
|
"prepack": "npm run lint",
|
|
14
|
-
"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"
|
|
15
20
|
},
|
|
16
21
|
"author": "",
|
|
17
22
|
"license": "ISC",
|
package/.github/dependabot.yml
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
|
2
|
-
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
|
|
3
|
-
|
|
4
|
-
name: publish eufy-robovac-js
|
|
5
|
-
|
|
6
|
-
on:
|
|
7
|
-
release:
|
|
8
|
-
types: [created]
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
build:
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
steps:
|
|
14
|
-
- uses: actions/checkout@v7
|
|
15
|
-
- uses: actions/setup-node@v6
|
|
16
|
-
with:
|
|
17
|
-
node-version: 20
|
|
18
|
-
- run: npm ci
|
|
19
|
-
- run: npm test
|
|
20
|
-
|
|
21
|
-
publish-npm:
|
|
22
|
-
needs: build
|
|
23
|
-
runs-on: ubuntu-latest
|
|
24
|
-
steps:
|
|
25
|
-
- uses: actions/checkout@v7
|
|
26
|
-
- uses: actions/setup-node@v6
|
|
27
|
-
with:
|
|
28
|
-
node-version: 20
|
|
29
|
-
registry-url: https://registry.npmjs.org/
|
|
30
|
-
- run: npm ci
|
|
31
|
-
- run: npm publish
|
|
32
|
-
env:
|
|
33
|
-
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
package/.nvmrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
22
|
package/eslint.config.mjs
DELETED