@george.talusan/eufy-robovac-js 0.0.4 → 0.0.6

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.
Files changed (2) hide show
  1. package/lib/RoboVac.js +30 -0
  2. package/package.json +1 -1
package/lib/RoboVac.js CHANGED
@@ -4,6 +4,7 @@ const api = require('tuyapi');
4
4
  const { EventEmitter } = require('events');
5
5
 
6
6
  const COMMAND = {
7
+ playPause: '2',
7
8
  workMode: '5',
8
9
  activity: '15',
9
10
  goHome: '101',
@@ -114,6 +115,9 @@ class RoboVac extends EventEmitter
114
115
  Object.keys(data.dps).forEach(command => {
115
116
  const value = data.dps[command];
116
117
  if (command === COMMAND.workMode) {
118
+ this.emit('event', { command: 'playPause', value });
119
+ }
120
+ else if (command === COMMAND.workMode) {
117
121
  this.emit('event', { command: 'workMode', value });
118
122
  }
119
123
  else if (command === COMMAND.activity) {
@@ -196,6 +200,22 @@ class RoboVac extends EventEmitter
196
200
  return this.set({ [COMMAND.workMode]: 'auto' });
197
201
  }
198
202
 
203
+ async resume() {
204
+ if (!this.dps) {
205
+ debug('no data points available yet');
206
+ return 'unknown';
207
+ }
208
+ return this.set({ [COMMAND.playPause]: true });
209
+ }
210
+
211
+ async pause() {
212
+ if (!this.dps) {
213
+ debug('no data points available yet');
214
+ return 'unknown';
215
+ }
216
+ return this.set({ [COMMAND.playPause]: false });
217
+ }
218
+
199
219
  workMode() {
200
220
  if (!this.dps) {
201
221
  debug('no data points available yet');
@@ -352,6 +372,16 @@ class RoboVac extends EventEmitter
352
372
  return this.set({ [COMMAND.goHome]: flag });
353
373
  }
354
374
 
375
+ goingHome() {
376
+ if (!this.dps) {
377
+ throw new Error('no data points available yet');
378
+ }
379
+ if (!this.dps.hasOwnProperty(COMMAND.goHome)) {
380
+ throw new Error('RoboVac does not support this command');
381
+ }
382
+ return this.dps[COMMAND.goHome];
383
+ }
384
+
355
385
  volume() {
356
386
  if (!this.dps) {
357
387
  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.4",
3
+ "version": "0.0.6",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"