node-miio 0.0.0-dev-20250810-f1674d0

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 (104) hide show
  1. package/.editorconfig +21 -0
  2. package/.eslintrc +32 -0
  3. package/.github/workflows/build.yml +50 -0
  4. package/.github/workflows/codecov.yml +35 -0
  5. package/.github/workflows/codeql.yml +24 -0
  6. package/.github/workflows/publish-dev-from-main.yml +92 -0
  7. package/.github/workflows/publish-release-to-npm.yml +48 -0
  8. package/CONTRIBUTING.md +104 -0
  9. package/LICENSE.md +20 -0
  10. package/README.md +216 -0
  11. package/cli/commands/configure.js +69 -0
  12. package/cli/commands/control.js +54 -0
  13. package/cli/commands/discover.js +36 -0
  14. package/cli/commands/inspect.js +197 -0
  15. package/cli/commands/protocol/call.js +66 -0
  16. package/cli/commands/protocol/json-dump.js +52 -0
  17. package/cli/commands/protocol/packet.js +29 -0
  18. package/cli/commands/protocol.js +8 -0
  19. package/cli/commands/tokens/update.js +58 -0
  20. package/cli/commands/tokens.js +8 -0
  21. package/cli/device-finder.js +66 -0
  22. package/cli/index.js +9 -0
  23. package/cli/log.js +89 -0
  24. package/docs/advanced-api.md +103 -0
  25. package/docs/devices/README.md +111 -0
  26. package/docs/devices/air-purifier.md +142 -0
  27. package/docs/devices/controller.md +89 -0
  28. package/docs/devices/gateway.md +41 -0
  29. package/docs/devices/humidifier.md +136 -0
  30. package/docs/devices/light.md +141 -0
  31. package/docs/devices/power-outlet.md +56 -0
  32. package/docs/devices/power-plug.md +69 -0
  33. package/docs/devices/power-strip.md +73 -0
  34. package/docs/devices/sensor.md +74 -0
  35. package/docs/devices/vacuum.md +80 -0
  36. package/docs/devices/wall-switch.md +62 -0
  37. package/docs/management.md +109 -0
  38. package/docs/missing-devices.md +48 -0
  39. package/docs/protocol.md +77 -0
  40. package/docs/reporting-issues.md +47 -0
  41. package/example.js +11 -0
  42. package/lib/checkResult.js +13 -0
  43. package/lib/connectToDevice.js +62 -0
  44. package/lib/device.js +290 -0
  45. package/lib/device_info.js +329 -0
  46. package/lib/device_info.test.js +337 -0
  47. package/lib/devices/air-monitor.js +53 -0
  48. package/lib/devices/air-purifier.js +162 -0
  49. package/lib/devices/capabilities/battery-level.js +16 -0
  50. package/lib/devices/capabilities/buzzer.js +78 -0
  51. package/lib/devices/capabilities/changeable-led-brightness.js +48 -0
  52. package/lib/devices/capabilities/colorable.js +14 -0
  53. package/lib/devices/capabilities/dimmable.js +14 -0
  54. package/lib/devices/capabilities/mode.js +13 -0
  55. package/lib/devices/capabilities/power.js +14 -0
  56. package/lib/devices/capabilities/sensor.js +50 -0
  57. package/lib/devices/capabilities/switchable-led.js +49 -0
  58. package/lib/devices/chuangmi.plug.v1.js +61 -0
  59. package/lib/devices/eyecare-lamp2.js +179 -0
  60. package/lib/devices/gateway/86sw1.js +28 -0
  61. package/lib/devices/gateway/86sw2.js +44 -0
  62. package/lib/devices/gateway/ctrl_ln1.js +44 -0
  63. package/lib/devices/gateway/ctrl_ln2.js +53 -0
  64. package/lib/devices/gateway/ctrl_neutral1.js +44 -0
  65. package/lib/devices/gateway/ctrl_neutral2.js +53 -0
  66. package/lib/devices/gateway/cube.js +55 -0
  67. package/lib/devices/gateway/developer-api.js +120 -0
  68. package/lib/devices/gateway/light-channel.js +32 -0
  69. package/lib/devices/gateway/light-mixin.js +71 -0
  70. package/lib/devices/gateway/magnet.js +29 -0
  71. package/lib/devices/gateway/magnet2.js +13 -0
  72. package/lib/devices/gateway/motion.js +27 -0
  73. package/lib/devices/gateway/motion2.js +31 -0
  74. package/lib/devices/gateway/plug.js +45 -0
  75. package/lib/devices/gateway/sensor_ht.js +17 -0
  76. package/lib/devices/gateway/subdevice.js +227 -0
  77. package/lib/devices/gateway/subdevices.js +37 -0
  78. package/lib/devices/gateway/switch.js +29 -0
  79. package/lib/devices/gateway/switch2.js +27 -0
  80. package/lib/devices/gateway/voltage.js +28 -0
  81. package/lib/devices/gateway/weather.js +22 -0
  82. package/lib/devices/gateway.js +244 -0
  83. package/lib/devices/humidifier.js +162 -0
  84. package/lib/devices/mijiavacuum.js +22 -0
  85. package/lib/devices/philips-light-bulb.js +73 -0
  86. package/lib/devices/power-plug.js +26 -0
  87. package/lib/devices/power-strip.js +38 -0
  88. package/lib/devices/vacuum.js +412 -0
  89. package/lib/devices/viomivacuum.js +250 -0
  90. package/lib/devices/yeelight.color.js +6 -0
  91. package/lib/devices/yeelight.js +286 -0
  92. package/lib/devices/yeelight.mono.js +9 -0
  93. package/lib/discovery.js +192 -0
  94. package/lib/index.js +40 -0
  95. package/lib/infoFromHostname.js +24 -0
  96. package/lib/management.js +102 -0
  97. package/lib/models.js +77 -0
  98. package/lib/network.js +234 -0
  99. package/lib/packet.js +191 -0
  100. package/lib/placeholder.js +12 -0
  101. package/lib/safeishJSON.js +14 -0
  102. package/lib/tokens.js +129 -0
  103. package/npm-shrinkwrap.json +853 -0
  104. package/package.json +40 -0
@@ -0,0 +1,412 @@
1
+ 'use strict';
2
+
3
+ const { ChargingState, AutonomousCharging } = require('abstract-things');
4
+ const {
5
+ Vacuum,
6
+ AdjustableFanSpeed,
7
+ AutonomousCleaning,
8
+ SpotCleaning,
9
+ } = require('abstract-things/climate');
10
+
11
+ const MiioApi = require('../device');
12
+ const BatteryLevel = require('./capabilities/battery-level');
13
+ const checkResult = require('../checkResult');
14
+
15
+ /**
16
+ * Implementation of the interface used by the Mi Robot Vacuum. This device
17
+ * doesn't use properties via get_prop but instead has a get_status.
18
+ */
19
+ module.exports = class extends (
20
+ Vacuum.with(
21
+ MiioApi,
22
+ BatteryLevel,
23
+ AutonomousCharging,
24
+ AutonomousCleaning,
25
+ SpotCleaning,
26
+ AdjustableFanSpeed,
27
+ ChargingState
28
+ )
29
+ ) {
30
+ static get type() {
31
+ return 'miio:vacuum';
32
+ }
33
+
34
+ constructor(options) {
35
+ super(options);
36
+
37
+ this.defineProperty('error_code', {
38
+ name: 'error',
39
+ mapper: (e) => {
40
+ switch (e) {
41
+ case 0:
42
+ return null;
43
+ default:
44
+ return {
45
+ code: e,
46
+ message: 'Unknown error ' + e,
47
+ };
48
+ }
49
+
50
+ // TODO: Find a list of error codes and map them correctly
51
+ },
52
+ });
53
+
54
+ this.defineProperty('state', (s) => {
55
+ switch (s) {
56
+ case 1:
57
+ return 'initiating';
58
+ case 2:
59
+ return 'charger-offline';
60
+ case 3:
61
+ return 'waiting';
62
+ case 5:
63
+ return 'cleaning';
64
+ case 6:
65
+ return 'returning';
66
+ case 8:
67
+ return 'charging';
68
+ case 9:
69
+ return 'charging-error';
70
+ case 10:
71
+ return 'paused';
72
+ case 11:
73
+ return 'spot-cleaning';
74
+ case 12:
75
+ return 'error';
76
+ case 13:
77
+ return 'shutting-down';
78
+ case 14:
79
+ return 'updating';
80
+ case 15:
81
+ return 'docking';
82
+ case 16:
83
+ return 'going-to-location';
84
+ case 17:
85
+ return 'zone-cleaning';
86
+ case 18:
87
+ return 'room-cleaning';
88
+ case 22:
89
+ return 'dust-collection';
90
+ case 100:
91
+ return 'full';
92
+ }
93
+ return 'unknown-' + s;
94
+ });
95
+
96
+ // Define the batteryLevel property for monitoring battery
97
+ this.defineProperty('battery', {
98
+ name: 'batteryLevel',
99
+ });
100
+
101
+ this.defineProperty('clean_time', {
102
+ name: 'cleanTime',
103
+ });
104
+ this.defineProperty('clean_area', {
105
+ name: 'cleanArea',
106
+ mapper: (v) => v / 1000000,
107
+ });
108
+ this.defineProperty('fan_power', {
109
+ name: 'fanSpeed',
110
+ });
111
+ this.defineProperty('in_cleaning');
112
+
113
+ // Consumable status - times for brushes and filters
114
+ this.defineProperty('main_brush_work_time', {
115
+ name: 'mainBrushWorkTime',
116
+ });
117
+ this.defineProperty('side_brush_work_time', {
118
+ name: 'sideBrushWorkTime',
119
+ });
120
+ this.defineProperty('filter_work_time', {
121
+ name: 'filterWorkTime',
122
+ });
123
+ this.defineProperty('sensor_dirty_time', {
124
+ name: 'sensorDirtyTime',
125
+ });
126
+
127
+ this.defineProperty('water_box_mode', {
128
+ name: 'waterBoxMode',
129
+ });
130
+
131
+ this.defineProperty('auto_dust_collection', {
132
+ name: 'autoDustCollection',
133
+ });
134
+ this.defineProperty('dust_collection_status', {
135
+ name: 'dustCollectionStatus',
136
+ });
137
+
138
+ this._monitorInterval = 60000;
139
+ }
140
+
141
+ propertyUpdated(key, value, oldValue) {
142
+ if (key === 'state') {
143
+ // Update charging state
144
+ this.updateCharging(value === 'charging');
145
+
146
+ switch (value) {
147
+ case 'cleaning':
148
+ case 'spot-cleaning':
149
+ case 'zone-cleaning':
150
+ case 'room-cleaning':
151
+ // The vacuum is cleaning
152
+ this.updateCleaning(true);
153
+ break;
154
+ case 'paused':
155
+ // Cleaning has been paused, do nothing special
156
+ break;
157
+ case 'error':
158
+ // An error has occurred, rely on error mapping
159
+ this.updateError(this.property('error'));
160
+ break;
161
+ case 'charging-error':
162
+ // Charging error, trigger an error
163
+ this.updateError({
164
+ code: 'charging-error',
165
+ message: 'Error during charging',
166
+ });
167
+ break;
168
+ case 'charger-offline':
169
+ // Charger is offline, trigger an error
170
+ this.updateError({
171
+ code: 'charger-offline',
172
+ message: 'Charger is offline',
173
+ });
174
+ break;
175
+ default:
176
+ // The vacuum is not cleaning
177
+ this.updateCleaning(false);
178
+ break;
179
+ }
180
+ } else if (key === 'fanSpeed') {
181
+ this.updateFanSpeed(value);
182
+ }
183
+
184
+ super.propertyUpdated(key, value, oldValue);
185
+ }
186
+
187
+ getDeviceInfo() {
188
+ return this.call('miIO.info');
189
+ }
190
+
191
+ async getSerialNumber() {
192
+ const serial = await this.call('get_serial_number');
193
+ return serial[0].serial_number;
194
+ }
195
+
196
+ getRoomMap() {
197
+ return this.call('get_room_mapping');
198
+ }
199
+
200
+ cleanRooms(listOfRooms) {
201
+ return this.call('app_segment_clean', listOfRooms, {
202
+ refresh: ['state'],
203
+ refreshDelay: 1000,
204
+ }).then(checkResult);
205
+ }
206
+
207
+ resumeCleanRooms(listOfRooms) {
208
+ return this.call('resume_segment_clean', listOfRooms, {
209
+ refresh: ['state'],
210
+ refreshDelay: 1000,
211
+ }).then(checkResult);
212
+ }
213
+
214
+ cleanZones(listOfZones) {
215
+ return this.call('app_zoned_clean', listOfZones, {
216
+ refresh: ['state'],
217
+ refreshDelay: 1000,
218
+ }).then(checkResult);
219
+ }
220
+
221
+ getTimer() {
222
+ return this.call('get_timer');
223
+ }
224
+
225
+ /**
226
+ * Start a cleaning session.
227
+ */
228
+ activateCleaning() {
229
+ return this.call('app_start', [], {
230
+ refresh: ['state'],
231
+ refreshDelay: 1000,
232
+ }).then(checkResult);
233
+ }
234
+
235
+ /**
236
+ * Pause the current cleaning session.
237
+ */
238
+ pause() {
239
+ return this.call('app_pause', [], {
240
+ refresh: ['state'],
241
+ refreshDelay: 1000, // https://github.com/homebridge-xiaomi-roborock-vacuum/homebridge-xiaomi-roborock-vacuum/issues/236
242
+ }).then(checkResult);
243
+ }
244
+
245
+ /**
246
+ * Stop the current cleaning session.
247
+ */
248
+ deactivateCleaning() {
249
+ return this.call('app_stop', [], {
250
+ refresh: ['state'],
251
+ refreshDelay: 1000,
252
+ }).then(checkResult);
253
+ }
254
+
255
+ /**
256
+ * Stop the current cleaning session and return to charge.
257
+ */
258
+ activateCharging() {
259
+ return (
260
+ this.pause()
261
+ .catch(() => this.deactivateCleaning())
262
+ // Wait 1 second
263
+ .then(() => new Promise((resolve) => setTimeout(resolve, 1000)))
264
+ .then(() =>
265
+ this.call('app_charge', [], {
266
+ refresh: ['state'],
267
+ refreshDelay: 1000,
268
+ })
269
+ )
270
+ .then(checkResult)
271
+ );
272
+ }
273
+
274
+ /**
275
+ * Start cleaning the current spot.
276
+ */
277
+ activateSpotClean() {
278
+ return this.call('app_spot', [], {
279
+ refresh: ['state'],
280
+ }).then(checkResult);
281
+ }
282
+
283
+ /**
284
+ * Start dustCollection.
285
+ */
286
+ startDustCollection() {
287
+ return this.call('app_start_collect_dust', [], {
288
+ refresh: ['state'],
289
+ refreshDelay: 1000,
290
+ }).then(checkResult);
291
+ }
292
+
293
+ /**
294
+ * Stop dustCollection.
295
+ */
296
+ stopDustCollection() {
297
+ return this.call('app_stop_collect_dust', [], {
298
+ refresh: ['state'],
299
+ refreshDelay: 1000,
300
+ }).then(checkResult);
301
+ }
302
+
303
+ /**
304
+ * Set the power of the fan. Usually 38, 60 or 77.
305
+ */
306
+ changeFanSpeed(speed) {
307
+ return this.call('set_custom_mode', [speed], {
308
+ refresh: ['fanSpeed'],
309
+ }).then(checkResult);
310
+ }
311
+
312
+ /**
313
+ * Get WaterBoxMode (only working for the model S6)
314
+ * @returns {Promise<*>}
315
+ */
316
+ async getWaterBoxMode() {
317
+ // From https://github.com/marcelrv/XiaomiRobotVacuumProtocol/blob/master/water_box_custom_mode.md
318
+ const response = await this.call('get_water_box_custom_mode', [], {
319
+ refresh: ['waterBoxMode'],
320
+ });
321
+ return response[0];
322
+ }
323
+
324
+ setWaterBoxMode(mode) {
325
+ // From https://github.com/marcelrv/XiaomiRobotVacuumProtocol/blob/master/water_box_custom_mode.md
326
+ return this.call('set_water_box_custom_mode', [mode], {
327
+ refresh: ['waterBoxMode'],
328
+ }).then(checkResult);
329
+ }
330
+
331
+ /**
332
+ * Activate the find function, will make the device give off a sound.
333
+ */
334
+ find() {
335
+ return this.call('find_me', ['']).then(() => null);
336
+ }
337
+
338
+ /**
339
+ * Send the vacuum to a specific location.
340
+ */
341
+ sendToLocation(x, y) {
342
+ return this.call('app_goto_target', [x, y], {
343
+ refresh: ['state'],
344
+ refreshDelay: 1000,
345
+ }).then(checkResult);
346
+ }
347
+
348
+ /**
349
+ * Get information about the cleaning history of the device. Contains
350
+ * information about the number of times it has been started and
351
+ * the days it has been run.
352
+ */
353
+ getHistory() {
354
+ return this.call('get_clean_summary').then((result) => {
355
+ return {
356
+ count: result[2],
357
+ days: result[3].map((ts) => new Date(ts * 1000)),
358
+ };
359
+ });
360
+ }
361
+
362
+ /**
363
+ * Get history for the specified day. The day should be fetched from
364
+ * `getHistory`.
365
+ */
366
+ getHistoryForDay(day) {
367
+ let record = day;
368
+ if (record instanceof Date) {
369
+ record = Math.floor(record.getTime() / 1000);
370
+ }
371
+ return this.call('get_clean_record', [record]).then((result) => ({
372
+ day: day,
373
+ history: result.map((data) => ({
374
+ // Start and end times
375
+ start: new Date(data[0] * 1000),
376
+ end: new Date(data[1] * 1000),
377
+
378
+ // How long it took in seconds
379
+ duration: data[2],
380
+
381
+ // Area in m2
382
+ area: data[3] / 1000000,
383
+
384
+ // If it was a complete run
385
+ complete: data[5] === 1,
386
+ })),
387
+ }));
388
+ }
389
+
390
+ loadProperties(props) {
391
+ // We override loadProperties to use get_status and get_consumables
392
+ props = props.map((key) => this._reversePropertyDefinitions[key] || key);
393
+
394
+ return Promise.all([
395
+ this.call('get_status'),
396
+ this.call('get_consumable'),
397
+ ]).then((result) => {
398
+ const status = result[0][0];
399
+ const consumables = result[1][0];
400
+
401
+ const mapped = {};
402
+ props.forEach((prop) => {
403
+ let value = status[prop];
404
+ if (typeof value === 'undefined') {
405
+ value = consumables[prop];
406
+ }
407
+ this._pushProperty(mapped, prop, value);
408
+ });
409
+ return mapped;
410
+ });
411
+ }
412
+ };
@@ -0,0 +1,250 @@
1
+ 'use strict';
2
+
3
+ const { ChargingState, AutonomousCharging } = require('abstract-things');
4
+ const {
5
+ Vacuum,
6
+ AdjustableFanSpeed,
7
+ AutonomousCleaning,
8
+ SpotCleaning,
9
+ } = require('abstract-things/climate');
10
+
11
+ const MiioApi = require('../device');
12
+ const BatteryLevel = require('./capabilities/battery-level');
13
+ const checkResult = require('../checkResult');
14
+
15
+ module.exports = class extends (
16
+ Vacuum.with(
17
+ MiioApi,
18
+ BatteryLevel,
19
+ AutonomousCharging,
20
+ AutonomousCleaning,
21
+ SpotCleaning,
22
+ AdjustableFanSpeed,
23
+ ChargingState
24
+ )
25
+ ) {
26
+ static get type() {
27
+ return 'miio:vacuum';
28
+ }
29
+ constructor(options) {
30
+ super(options);
31
+
32
+ this.defineProperty('err_state', {
33
+ name: 'error',
34
+ mapper: (e) => {
35
+ switch (e) {
36
+ case 0:
37
+ return null;
38
+ default:
39
+ return {
40
+ code: e,
41
+ message: 'Unknown error ' + e,
42
+ };
43
+ }
44
+ },
45
+ });
46
+
47
+ this.defineProperty('run_state', {
48
+ name: 'state',
49
+ mapper: (s) => {
50
+ switch (s) {
51
+ case 0:
52
+ return 'paused';
53
+ case 1:
54
+ return 'initiating';
55
+ case 2:
56
+ return 'waiting';
57
+ case 3:
58
+ return 'cleaning';
59
+ case 4:
60
+ return 'returning';
61
+ case 5:
62
+ return 'charging';
63
+ case 6:
64
+ return 'cleaning-and-mopping';
65
+ }
66
+ return 'unknown-' + s;
67
+ },
68
+ });
69
+
70
+ // Define the batteryLevel property for monitoring battery
71
+ this.defineProperty('battary_life', {
72
+ name: 'batteryLevel',
73
+ });
74
+
75
+ this.defineProperty('s_time', {
76
+ name: 'cleanTime',
77
+ });
78
+ this.defineProperty('s_area', {
79
+ name: 'cleanArea',
80
+ mapper: (v) => v / 1000000,
81
+ });
82
+ this.defineProperty('suction_grade', {
83
+ name: 'fanSpeed',
84
+ });
85
+
86
+ // Consumable status - times for brushes and filters
87
+ // From https://github.com/rytilahti/python-miio/issues/550#issuecomment-570808184
88
+ this.defineProperty('main_brush_life', {
89
+ name: 'mainBrushWorkTime',
90
+ });
91
+ this.defineProperty('side_brush_life', {
92
+ name: 'sideBrushWorkTime',
93
+ });
94
+ this.defineProperty('hypa_life', {
95
+ name: 'filterWorkTime',
96
+ });
97
+ this.defineProperty('mop_life', {
98
+ name: 'mopWorkTime',
99
+ });
100
+
101
+ // Monitor the property as is
102
+ this.defineProperty('hw_info');
103
+
104
+ this._monitorInterval = 60000;
105
+ }
106
+
107
+ propertyUpdated(key, value, oldValue) {
108
+ if (key === 'state') {
109
+ // Update charging state
110
+ this.updateCharging(value === 'charging');
111
+
112
+ switch (value) {
113
+ case 'cleaning':
114
+ case 'spot-cleaning':
115
+ case 'zone-cleaning':
116
+ case 'room-cleaning':
117
+ // The vacuum is cleaning
118
+ this.updateCleaning(true);
119
+ break;
120
+ case 'paused':
121
+ // Cleaning has been paused, do nothing special
122
+ break;
123
+ case 'error':
124
+ // An error has occurred, rely on error mapping
125
+ this.updateError(this.property('error'));
126
+ break;
127
+ case 'charging-error':
128
+ // Charging error, trigger an error
129
+ this.updateError({
130
+ code: 'charging-error',
131
+ message: 'Error during charging',
132
+ });
133
+ break;
134
+ case 'charger-offline':
135
+ // Charger is offline, trigger an error
136
+ this.updateError({
137
+ code: 'charger-offline',
138
+ message: 'Charger is offline',
139
+ });
140
+ break;
141
+ default:
142
+ // The vacuum is not cleaning
143
+ this.updateCleaning(false);
144
+ break;
145
+ }
146
+ } else if (key === 'fanSpeed') {
147
+ this.updateFanSpeed(value);
148
+ }
149
+
150
+ super.propertyUpdated(key, value, oldValue);
151
+ }
152
+
153
+ getDeviceInfo() {
154
+ return this.call('miIO.info');
155
+ }
156
+
157
+ async getSerialNumber() {
158
+ return this.property('hw_info') || 'Unknown'; // We don't know the command to retrieve this bit of info for these models
159
+ }
160
+
161
+ getRoomMap() {
162
+ return this.call('get_room_mapping');
163
+ }
164
+
165
+ cleanRooms(listOfRooms) {
166
+ // From https://github.com/rytilahti/python-miio/issues/550#issuecomment-552780952
167
+ return this.call(
168
+ 'set_mode_withroom',
169
+ [0, 1, listOfRooms.length].concat(listOfRooms),
170
+ {
171
+ refresh: ['state'],
172
+ refreshDelay: 1000,
173
+ }
174
+ ).then(checkResult);
175
+ }
176
+
177
+ resumeCleanRooms(listOfRooms) {
178
+ return this.cleanRooms(listOfRooms);
179
+ }
180
+
181
+ getTimer() {
182
+ return this.call('get_ordertime');
183
+ }
184
+
185
+ /**
186
+ * Start a cleaning session.
187
+ */
188
+ activateCleaning() {
189
+ return this.call('set_mode_withroom', [0, 1, 0], {
190
+ refresh: ['state'],
191
+ refreshDelay: 1000,
192
+ }).then(checkResult);
193
+ }
194
+
195
+ /**
196
+ * Pause the current cleaning session.
197
+ */
198
+ pause() {
199
+ return this.call('set_mode_withroom', [0, 2, 0], {
200
+ refresh: ['state'],
201
+ }).then(checkResult);
202
+ }
203
+
204
+ /**
205
+ * Stop the current cleaning session.
206
+ */
207
+ deactivateCleaning() {
208
+ return this.call('set_mode', [0], {
209
+ refresh: ['state'],
210
+ refreshDelay: 1000,
211
+ }).then(checkResult);
212
+ }
213
+
214
+ /**
215
+ * Stop the current cleaning session and return to charge.
216
+ */
217
+ activateCharging() {
218
+ return this.pause()
219
+ .then(() => new Promise((resolve) => setTimeout(resolve, 1000)))
220
+ .then(() =>
221
+ this.call('set_charge', [1], {
222
+ refresh: ['state'],
223
+ refreshDelay: 1000,
224
+ })
225
+ )
226
+ .then(checkResult);
227
+ }
228
+
229
+ /**
230
+ * Set the power of the fan.
231
+ * From https://github.com/rytilahti/python-miio/blob/20f915c9589fed55544a5417abe3fd3d9e12d08d/miio/viomivacuum.py#L16-L20
232
+ * class ViomiVacuumSpeed(Enum):
233
+ * Silent = 0
234
+ * Standard = 1
235
+ * Medium = 2
236
+ * Turbo = 3
237
+ */
238
+ changeFanSpeed(speed) {
239
+ return this.call('set_suction', [speed], {
240
+ refresh: ['fanSpeed'],
241
+ }).then(checkResult);
242
+ }
243
+
244
+ /**
245
+ * Activate the find function, will make the device give off a sound.
246
+ */
247
+ find() {
248
+ return this.call('find_me', ['']).then(() => null);
249
+ }
250
+ };
@@ -0,0 +1,6 @@
1
+ 'use strict';
2
+
3
+ const { Yeelight, ColorFull } = require('./yeelight');
4
+
5
+ module.exports = class YeelightColor extends Yeelight.with(ColorFull) {
6
+ };