@george.talusan/eufy-robovac-js 0.0.8 → 0.0.9
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/eslint.config.mjs +8 -0
- package/lib/RoboVac.js +22 -21
- package/package.json +9 -5
package/lib/RoboVac.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const debug = require('debug');
|
|
2
2
|
const api = require('tuyapi');
|
|
3
3
|
const { EventEmitter } = require('events');
|
|
4
|
+
const { Buffer } = require('buffer');
|
|
4
5
|
|
|
5
6
|
const COMMAND = {
|
|
6
7
|
playPause: '2',
|
|
@@ -104,7 +105,7 @@ class RoboVac extends EventEmitter
|
|
|
104
105
|
|
|
105
106
|
Object.keys(data.dps).forEach(command => {
|
|
106
107
|
const value = data.dps[command];
|
|
107
|
-
if (command === COMMAND.
|
|
108
|
+
if (command === COMMAND.playPause) {
|
|
108
109
|
this.emit('event', { command: 'playPause', value });
|
|
109
110
|
}
|
|
110
111
|
else if (command === COMMAND.workMode) {
|
|
@@ -165,7 +166,7 @@ class RoboVac extends EventEmitter
|
|
|
165
166
|
this.emit('event', { command: 'multimaps', value: this.multimaps() });
|
|
166
167
|
}
|
|
167
168
|
else if (command === COMMAND.rooms) {
|
|
168
|
-
this.emit('event', { command: 'rooms', this.rooms() });
|
|
169
|
+
this.emit('event', { command: 'rooms', value: this.rooms() });
|
|
169
170
|
}
|
|
170
171
|
else if (command === COMMAND.voice) {
|
|
171
172
|
this.emit('event', { command: 'voice', value: this.voice() });
|
|
@@ -231,7 +232,7 @@ class RoboVac extends EventEmitter
|
|
|
231
232
|
debug('no data points available yet');
|
|
232
233
|
return 'unknown';
|
|
233
234
|
}
|
|
234
|
-
if (!this.dps
|
|
235
|
+
if (!Object.hasOwn(this.dps, COMMAND.workMode)) {
|
|
235
236
|
throw new Error('RoboVac does not support this command');
|
|
236
237
|
}
|
|
237
238
|
return this.dps[COMMAND.workMode];
|
|
@@ -242,7 +243,7 @@ class RoboVac extends EventEmitter
|
|
|
242
243
|
debug('no data points available yet');
|
|
243
244
|
return 'unknown';
|
|
244
245
|
}
|
|
245
|
-
if (!this.dps
|
|
246
|
+
if (!Object.hasOwn(this.dps, COMMAND.activity)) {
|
|
246
247
|
throw new Error('RoboVac does not support this command');
|
|
247
248
|
}
|
|
248
249
|
return this.dps[COMMAND.activity];
|
|
@@ -253,7 +254,7 @@ class RoboVac extends EventEmitter
|
|
|
253
254
|
debug('no data points available yet');
|
|
254
255
|
return -1;
|
|
255
256
|
}
|
|
256
|
-
if (!this.dps
|
|
257
|
+
if (!Object.hasOwn(this.dps, COMMAND.battery)) {
|
|
257
258
|
throw new Error('RoboVac does not support this command');
|
|
258
259
|
}
|
|
259
260
|
return this.dps[COMMAND.battery];
|
|
@@ -275,7 +276,7 @@ class RoboVac extends EventEmitter
|
|
|
275
276
|
debug('no data points available yet');
|
|
276
277
|
return -1;
|
|
277
278
|
}
|
|
278
|
-
if (!this.dps
|
|
279
|
+
if (!Object.hasOwn(this.dps, COMMAND.cleaningRuntime)) {
|
|
279
280
|
throw new Error('RoboVac does not support this command');
|
|
280
281
|
}
|
|
281
282
|
return this.dps[COMMAND.cleaningRuntime];
|
|
@@ -286,7 +287,7 @@ class RoboVac extends EventEmitter
|
|
|
286
287
|
debug('no data points available yet');
|
|
287
288
|
return -1;
|
|
288
289
|
}
|
|
289
|
-
if (!this.dps
|
|
290
|
+
if (!Object.hasOwn(this.dps, COMMAND.cleaningCoverage)) {
|
|
290
291
|
throw new Error('RoboVac does not support this command');
|
|
291
292
|
}
|
|
292
293
|
return this.dps[COMMAND.cleaningCoverage];
|
|
@@ -297,7 +298,7 @@ class RoboVac extends EventEmitter
|
|
|
297
298
|
debug('no data points available yet');
|
|
298
299
|
return ''
|
|
299
300
|
}
|
|
300
|
-
if (!this.dps
|
|
301
|
+
if (!Object.hasOwn(this.dps, COMMAND.consumables)) {
|
|
301
302
|
throw new Error('RoboVac does not support this command');
|
|
302
303
|
}
|
|
303
304
|
const json = Buffer.from(this.dps[COMMAND.consumables], 'base64');
|
|
@@ -309,7 +310,7 @@ class RoboVac extends EventEmitter
|
|
|
309
310
|
debug('no data points available yet');
|
|
310
311
|
return ''
|
|
311
312
|
}
|
|
312
|
-
if (!this.dps
|
|
313
|
+
if (!Object.hasOwn(this.dps, COMMAND.status)) {
|
|
313
314
|
throw new Error('RoboVac does not support this command');
|
|
314
315
|
}
|
|
315
316
|
const json = Buffer.from(this.dps[COMMAND.status], 'base64');
|
|
@@ -352,7 +353,7 @@ class RoboVac extends EventEmitter
|
|
|
352
353
|
if (!this.dps) {
|
|
353
354
|
throw new Error('no data points available yet');
|
|
354
355
|
}
|
|
355
|
-
if (!this.dps
|
|
356
|
+
if (!Object.hasOwn(this.dps, COMMAND.findMyRobot)) {
|
|
356
357
|
throw new Error('RoboVac does not support this command');
|
|
357
358
|
}
|
|
358
359
|
if (this.docked()) {
|
|
@@ -372,7 +373,7 @@ class RoboVac extends EventEmitter
|
|
|
372
373
|
if (this.docked()) {
|
|
373
374
|
throw new Error('RoboVac is already home');
|
|
374
375
|
}
|
|
375
|
-
if (!this.dps
|
|
376
|
+
if (!Object.hasOwn(this.dps, COMMAND.goHome)) {
|
|
376
377
|
throw new Error('RoboVac does not support this command');
|
|
377
378
|
}
|
|
378
379
|
const b = this.dps[COMMAND.goHome];
|
|
@@ -386,7 +387,7 @@ class RoboVac extends EventEmitter
|
|
|
386
387
|
if (!this.dps) {
|
|
387
388
|
throw new Error('no data points available yet');
|
|
388
389
|
}
|
|
389
|
-
if (!this.dps
|
|
390
|
+
if (!Object.hasOwn(this.dps, COMMAND.goHome)) {
|
|
390
391
|
throw new Error('RoboVac does not support this command');
|
|
391
392
|
}
|
|
392
393
|
return this.dps[COMMAND.goHome];
|
|
@@ -396,17 +397,17 @@ class RoboVac extends EventEmitter
|
|
|
396
397
|
if (!this.dps) {
|
|
397
398
|
throw new Error('no data points available yet');
|
|
398
399
|
}
|
|
399
|
-
if (!this.dps
|
|
400
|
+
if (!Object.hasOwn(this.dps, COMMAND.volume)) {
|
|
400
401
|
throw new Error('RoboVac does not support this command');
|
|
401
402
|
}
|
|
402
403
|
return this.dps[COMMAND.volume];
|
|
403
404
|
}
|
|
404
405
|
|
|
405
406
|
async setVolume(value) {
|
|
406
|
-
if (!this.dps
|
|
407
|
+
if (!Object.hasOwn(this.dps, COMMAND.volume)) {
|
|
407
408
|
throw new Error('RoboVac does not support this command');
|
|
408
409
|
}
|
|
409
|
-
if (value < 0 ||
|
|
410
|
+
if (value < 0 || value > 100) {
|
|
410
411
|
throw new Error('expecting value between 0 to 100');
|
|
411
412
|
}
|
|
412
413
|
return this.set({ [COMMAND.volume]: value });
|
|
@@ -416,7 +417,7 @@ class RoboVac extends EventEmitter
|
|
|
416
417
|
if (!this.dps) {
|
|
417
418
|
throw new Error('no data points available yet');
|
|
418
419
|
}
|
|
419
|
-
if (!this.dps
|
|
420
|
+
if (!Object.hasOwn(this.dps, COMMAND.multimaps)) {
|
|
420
421
|
throw new Error('RoboVac does not support this command');
|
|
421
422
|
}
|
|
422
423
|
const json = Buffer.from(this.dps[COMMAND.multimaps], 'base64');
|
|
@@ -427,7 +428,7 @@ class RoboVac extends EventEmitter
|
|
|
427
428
|
if (!this.dps) {
|
|
428
429
|
throw new Error('no data points available yet');
|
|
429
430
|
}
|
|
430
|
-
if (!this.dps
|
|
431
|
+
if (!Object.hasOwn(this.dps, COMMAND.rooms)) {
|
|
431
432
|
throw new Error('RoboVac does not support this command');
|
|
432
433
|
}
|
|
433
434
|
const json = Buffer.from(this.dps[COMMAND.rooms], 'base64');
|
|
@@ -438,7 +439,7 @@ class RoboVac extends EventEmitter
|
|
|
438
439
|
if (!this.dps) {
|
|
439
440
|
throw new Error('no data points available yet');
|
|
440
441
|
}
|
|
441
|
-
if (!this.dps
|
|
442
|
+
if (!Object.hasOwn(this.dps, COMMAND.voice)) {
|
|
442
443
|
throw new Error('RoboVac does not support this command');
|
|
443
444
|
}
|
|
444
445
|
const json = Buffer.from(this.dps[COMMAND.voice], 'base64');
|
|
@@ -449,7 +450,7 @@ class RoboVac extends EventEmitter
|
|
|
449
450
|
if (!this.dps) {
|
|
450
451
|
throw new Error('no data points available yet');
|
|
451
452
|
}
|
|
452
|
-
if (!this.dps
|
|
453
|
+
if (!Object.hasOwn(this.dps, COMMAND.hello)) {
|
|
453
454
|
throw new Error('RoboVac does not support this command');
|
|
454
455
|
}
|
|
455
456
|
const json = Buffer.from(this.dps[COMMAND.hello], 'base64');
|
|
@@ -460,14 +461,14 @@ class RoboVac extends EventEmitter
|
|
|
460
461
|
if (!this.dps) {
|
|
461
462
|
throw new Error('no data points available yet');
|
|
462
463
|
}
|
|
463
|
-
if (!this.dps
|
|
464
|
+
if (!Object.hasOwn(this.dps, COMMAND.autoReturn)) {
|
|
464
465
|
throw new Error('RoboVac does not support this command');
|
|
465
466
|
}
|
|
466
467
|
return this.dps[COMMAND.autoReturn];
|
|
467
468
|
}
|
|
468
469
|
|
|
469
470
|
async setAutoReturn(flag) {
|
|
470
|
-
if (!this.dps
|
|
471
|
+
if (!Object.hasOwn(this.dps, COMMAND.autoReturn)) {
|
|
471
472
|
throw new Error('RoboVac does not support this command');
|
|
472
473
|
}
|
|
473
474
|
return this.set({ [COMMAND.autoReturn]: flag });
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@george.talusan/eufy-robovac-js",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"main": "
|
|
3
|
+
"version": "0.0.9",
|
|
4
|
+
"main": "./lib/RoboVac.js",
|
|
5
5
|
"scripts": {
|
|
6
|
+
"lint": "eslint lib",
|
|
6
7
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
8
|
},
|
|
8
9
|
"author": "",
|
|
9
10
|
"license": "ISC",
|
|
10
|
-
"main": "./lib/RoboVac.js",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"debug": "^4.3.5",
|
|
13
13
|
"tuyapi": "github:codetheweb/tuyapi"
|
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
"directories": {
|
|
16
16
|
"lib": "lib"
|
|
17
17
|
},
|
|
18
|
-
"
|
|
19
|
-
"
|
|
18
|
+
"description": "",
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@eslint/js": "^9.9.1",
|
|
21
|
+
"eslint": "^9.9.1",
|
|
22
|
+
"globals": "^15.9.0"
|
|
23
|
+
}
|
|
20
24
|
}
|