@george.talusan/eufy-robovac-js 0.0.6 → 0.0.8
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 +32 -11
- package/package.json +1 -2
package/lib/RoboVac.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const ping = require('net-ping').createSession({ retries: 10 });
|
|
2
1
|
const debug = require('debug');
|
|
3
2
|
const api = require('tuyapi');
|
|
4
3
|
const { EventEmitter } = require('events');
|
|
@@ -16,6 +15,7 @@ const COMMAND = {
|
|
|
16
15
|
volume: '111',
|
|
17
16
|
consumables: '116',
|
|
18
17
|
multimaps: '117',
|
|
18
|
+
rooms: '124',
|
|
19
19
|
voice: '125',
|
|
20
20
|
hello: '126',
|
|
21
21
|
autoReturn: '135',
|
|
@@ -70,17 +70,7 @@ class RoboVac extends EventEmitter
|
|
|
70
70
|
this.connected = false;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
ping() {
|
|
74
|
-
ping.pingHost(this.ip, (error, target) => {
|
|
75
|
-
if (error) {
|
|
76
|
-
debug(`${target}: ${error.toString()}`);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
73
|
async initialize() {
|
|
82
|
-
this.ping();
|
|
83
|
-
|
|
84
74
|
this.device = new api({
|
|
85
75
|
id: this.deviceId,
|
|
86
76
|
key: this.localKey,
|
|
@@ -174,6 +164,9 @@ class RoboVac extends EventEmitter
|
|
|
174
164
|
else if (command === COMMAND.multimaps) {
|
|
175
165
|
this.emit('event', { command: 'multimaps', value: this.multimaps() });
|
|
176
166
|
}
|
|
167
|
+
else if (command === COMMAND.rooms) {
|
|
168
|
+
this.emit('event', { command: 'rooms', this.rooms() });
|
|
169
|
+
}
|
|
177
170
|
else if (command === COMMAND.voice) {
|
|
178
171
|
this.emit('event', { command: 'voice', value: this.voice() });
|
|
179
172
|
}
|
|
@@ -200,6 +193,23 @@ class RoboVac extends EventEmitter
|
|
|
200
193
|
return this.set({ [COMMAND.workMode]: 'auto' });
|
|
201
194
|
}
|
|
202
195
|
|
|
196
|
+
async cleanRooms(rooms) {
|
|
197
|
+
if (!this.dps) {
|
|
198
|
+
debug('no data points available yet');
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const fn = {
|
|
202
|
+
method: 'selectRoomsClean',
|
|
203
|
+
data: {
|
|
204
|
+
roomIds: rooms || [ 1 ],
|
|
205
|
+
cleanTimes: 1
|
|
206
|
+
},
|
|
207
|
+
timestamp: Date.now()
|
|
208
|
+
};
|
|
209
|
+
const value = Buffer.from(JSON.stringify(fn)).toString('base64');
|
|
210
|
+
return this.set({ [COMMAND.rooms]: value });
|
|
211
|
+
}
|
|
212
|
+
|
|
203
213
|
async resume() {
|
|
204
214
|
if (!this.dps) {
|
|
205
215
|
debug('no data points available yet');
|
|
@@ -413,6 +423,17 @@ class RoboVac extends EventEmitter
|
|
|
413
423
|
return JSON.parse(json);
|
|
414
424
|
}
|
|
415
425
|
|
|
426
|
+
rooms() {
|
|
427
|
+
if (!this.dps) {
|
|
428
|
+
throw new Error('no data points available yet');
|
|
429
|
+
}
|
|
430
|
+
if (!this.dps.hasOwnProperty(COMMAND.rooms)) {
|
|
431
|
+
throw new Error('RoboVac does not support this command');
|
|
432
|
+
}
|
|
433
|
+
const json = Buffer.from(this.dps[COMMAND.rooms], 'base64');
|
|
434
|
+
return JSON.parse(json);
|
|
435
|
+
}
|
|
436
|
+
|
|
416
437
|
voice() {
|
|
417
438
|
if (!this.dps) {
|
|
418
439
|
throw new Error('no data points available yet');
|
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.8",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
"main": "./lib/RoboVac.js",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"debug": "^4.3.5",
|
|
13
|
-
"net-ping": "^1.2.4",
|
|
14
13
|
"tuyapi": "github:codetheweb/tuyapi"
|
|
15
14
|
},
|
|
16
15
|
"directories": {
|