@george.talusan/eufy-robovac-js 0.0.3 → 0.0.5

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 +44 -1
  2. package/package.json +1 -1
package/lib/RoboVac.js CHANGED
@@ -4,6 +4,8 @@ const api = require('tuyapi');
4
4
  const { EventEmitter } = require('events');
5
5
 
6
6
  const COMMAND = {
7
+ playPause: '2',
8
+ workMode: '5',
7
9
  activity: '15',
8
10
  goHome: '101',
9
11
  findMyRobot: '103',
@@ -112,7 +114,13 @@ class RoboVac extends EventEmitter
112
114
 
113
115
  Object.keys(data.dps).forEach(command => {
114
116
  const value = data.dps[command];
115
- if (command === COMMAND.activity) {
117
+ if (command === COMMAND.workMode) {
118
+ this.emit('event', { command: 'playPause', value });
119
+ }
120
+ else if (command === COMMAND.workMode) {
121
+ this.emit('event', { command: 'workMode', value });
122
+ }
123
+ else if (command === COMMAND.activity) {
116
124
  this.emit('event', { command: 'activity', value });
117
125
  }
118
126
  else if (command === COMMAND.goHome) {
@@ -184,6 +192,41 @@ class RoboVac extends EventEmitter
184
192
  return this.connect();
185
193
  }
186
194
 
195
+ async clean() {
196
+ if (!this.dps) {
197
+ debug('no data points available yet');
198
+ return 'unknown';
199
+ }
200
+ return this.set({ [COMMAND.workMode]: 'auto' });
201
+ }
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
+
219
+ workMode() {
220
+ if (!this.dps) {
221
+ debug('no data points available yet');
222
+ return 'unknown';
223
+ }
224
+ if (!this.dps.hasOwnProperty(COMMAND.workMode)) {
225
+ throw new Error('RoboVac does not support this command');
226
+ }
227
+ return this.dps[COMMAND.workMode];
228
+ }
229
+
187
230
  activity() {
188
231
  if (!this.dps) {
189
232
  debug('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",
3
+ "version": "0.0.5",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"