node-miio 0.7.0 → 0.8.0

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 (77) hide show
  1. package/README.md +4 -0
  2. package/dist/cli/commands/roborock/call.d.ts +10 -0
  3. package/dist/cli/commands/roborock/call.js +34 -0
  4. package/dist/cli/commands/roborock/call.js.map +1 -0
  5. package/dist/cli/commands/roborock/devices.d.ts +8 -0
  6. package/dist/cli/commands/roborock/devices.js +58 -0
  7. package/dist/cli/commands/roborock/devices.js.map +1 -0
  8. package/dist/cli/commands/roborock/login.d.ts +7 -0
  9. package/dist/cli/commands/roborock/login.js +34 -0
  10. package/dist/cli/commands/roborock/login.js.map +1 -0
  11. package/dist/cli/commands/roborock/logout.d.ts +4 -0
  12. package/dist/cli/commands/roborock/logout.js +14 -0
  13. package/dist/cli/commands/roborock/logout.js.map +1 -0
  14. package/dist/cli/commands/roborock/map.d.ts +10 -0
  15. package/dist/cli/commands/roborock/map.js +74 -0
  16. package/dist/cli/commands/roborock/map.js.map +1 -0
  17. package/dist/cli/commands/roborock/robot.d.ts +30 -0
  18. package/dist/cli/commands/roborock/robot.js +61 -0
  19. package/dist/cli/commands/roborock/robot.js.map +1 -0
  20. package/dist/cli/commands/roborock/rooms.d.ts +9 -0
  21. package/dist/cli/commands/roborock/rooms.js +40 -0
  22. package/dist/cli/commands/roborock/rooms.js.map +1 -0
  23. package/dist/cli/commands/roborock.d.ts +5 -0
  24. package/dist/cli/commands/roborock.js +55 -0
  25. package/dist/cli/commands/roborock.js.map +1 -0
  26. package/dist/cli/index.js +2 -0
  27. package/dist/cli/index.js.map +1 -1
  28. package/dist/lib/device_info.d.ts +6 -0
  29. package/dist/lib/devices/vacuums/vacuum.d.ts +3 -3
  30. package/dist/lib/devices/vacuums/vacuum.js +13 -3
  31. package/dist/lib/devices/vacuums/vacuum.js.map +1 -1
  32. package/dist/lib/devices/vacuums/vacuum_modes.d.ts +2 -0
  33. package/dist/lib/devices/vacuums/vacuum_modes.js +15 -0
  34. package/dist/lib/devices/vacuums/vacuum_modes.js.map +1 -1
  35. package/dist/lib/index.d.ts +1 -0
  36. package/dist/lib/index.js +1 -0
  37. package/dist/lib/index.js.map +1 -1
  38. package/dist/lib/logger.js +1 -1
  39. package/dist/lib/logger.js.map +1 -1
  40. package/dist/lib/management.d.ts +2 -2
  41. package/dist/lib/management.js.map +1 -1
  42. package/dist/lib/roborock/device.d.ts +118 -0
  43. package/dist/lib/roborock/device.js +273 -0
  44. package/dist/lib/roborock/device.js.map +1 -0
  45. package/dist/lib/roborock/errors.d.ts +18 -0
  46. package/dist/lib/roborock/errors.js +37 -0
  47. package/dist/lib/roborock/errors.js.map +1 -0
  48. package/dist/lib/roborock/hawk.d.ts +39 -0
  49. package/dist/lib/roborock/hawk.js +48 -0
  50. package/dist/lib/roborock/hawk.js.map +1 -0
  51. package/dist/lib/roborock/index.d.ts +9 -0
  52. package/dist/lib/roborock/index.js +36 -0
  53. package/dist/lib/roborock/index.js.map +1 -0
  54. package/dist/lib/roborock/local_connection.d.ts +72 -0
  55. package/dist/lib/roborock/local_connection.js +232 -0
  56. package/dist/lib/roborock/local_connection.js.map +1 -0
  57. package/dist/lib/roborock/map_response.d.ts +26 -0
  58. package/dist/lib/roborock/map_response.js +104 -0
  59. package/dist/lib/roborock/map_response.js.map +1 -0
  60. package/dist/lib/roborock/message.d.ts +110 -0
  61. package/dist/lib/roborock/message.js +313 -0
  62. package/dist/lib/roborock/message.js.map +1 -0
  63. package/dist/lib/roborock/mqtt.d.ts +119 -0
  64. package/dist/lib/roborock/mqtt.js +305 -0
  65. package/dist/lib/roborock/mqtt.js.map +1 -0
  66. package/dist/lib/roborock/rooms.d.ts +17 -0
  67. package/dist/lib/roborock/rooms.js +23 -0
  68. package/dist/lib/roborock/rooms.js.map +1 -0
  69. package/dist/lib/roborock/session_store.d.ts +21 -0
  70. package/dist/lib/roborock/session_store.js +52 -0
  71. package/dist/lib/roborock/session_store.js.map +1 -0
  72. package/dist/lib/roborock/web_api.d.ts +142 -0
  73. package/dist/lib/roborock/web_api.js +334 -0
  74. package/dist/lib/roborock/web_api.js.map +1 -0
  75. package/docs/roborock.md +91 -0
  76. package/package.json +2 -1
  77. package/snapshots/vacuum-specs.json.gz +0 -0
package/README.md CHANGED
@@ -184,6 +184,10 @@ The easiest way to get the tokens is from your Xiaomi account (opt-in):
184
184
  `npx node-miio cloud login --qr` (scan the QR code with the Mi Home app), then
185
185
  `npx node-miio cloud devices`. See [Xiaomi Cloud](docs/cloud.md).
186
186
 
187
+ Robots paired with the **Roborock app** don't use miIO tokens. Their support is starting (experimental):
188
+ `npx node-miio roborock login` (with a code sent to your email), then `npx node-miio roborock devices` lists
189
+ your robots with their model and protocol version, and `roborockDevice()` controls them (locally, or through Roborock's cloud). See [Roborock app accounts](docs/roborock.md).
190
+
187
191
  ## Discovering devices
188
192
 
189
193
  Use `miio.devices()` to look for and connect to devices on the local network.
@@ -0,0 +1,10 @@
1
+ import type { CommandBuilder } from "yargs";
2
+ export declare const command = "call <method> [params]";
3
+ export declare const description = "Call a method on a robot (e.g. get_status), and print the result";
4
+ export declare const builder: CommandBuilder;
5
+ export declare const handler: (argv: {
6
+ method: string;
7
+ params?: string;
8
+ ip?: string;
9
+ duid?: string;
10
+ }) => Promise<void>;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = exports.description = exports.command = void 0;
4
+ const log_1 = require("../../log");
5
+ const robot_1 = require("./robot");
6
+ exports.command = "call <method> [params]";
7
+ exports.description = "Call a method on a robot (e.g. get_status), and print the result";
8
+ exports.builder = {
9
+ ...robot_1.robotOptions,
10
+ };
11
+ const handler = async (argv) => {
12
+ let connected;
13
+ try {
14
+ const params = argv.params ? JSON.parse(argv.params) : [];
15
+ connected = await (0, robot_1.connectRobot)(argv);
16
+ if (!connected) {
17
+ process.exitCode = 1;
18
+ return;
19
+ }
20
+ const result = await connected.api.call(argv.method, params);
21
+ const { api } = connected;
22
+ log_1.log.info(`${connected.robot.name} (${api.transport === "local" ? `local, ${api.address}, protocol ${api.localProtocolVersion}` : "MQTT"}):`);
23
+ console.log(JSON.stringify(result, null, 2));
24
+ }
25
+ catch (err) {
26
+ log_1.log.error(err instanceof Error ? err.message : String(err));
27
+ process.exitCode = 1;
28
+ }
29
+ finally {
30
+ await connected?.close();
31
+ }
32
+ };
33
+ exports.handler = handler;
34
+ //# sourceMappingURL=call.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"call.js","sourceRoot":"","sources":["../../../../src/cli/commands/roborock/call.ts"],"names":[],"mappings":";;;AAEA,mCAAgC;AAEhC,mCAA0E;AAE7D,QAAA,OAAO,GAAG,wBAAwB,CAAC;AACnC,QAAA,WAAW,GACtB,kEAAkE,CAAC;AACxD,QAAA,OAAO,GAAmB;IACrC,GAAG,oBAAY;CAChB,CAAC;AAEK,MAAM,OAAO,GAAG,KAAK,EAAE,IAK7B,EAAE,EAAE;IACH,IAAI,SAAqC,CAAC;IAC1C,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1D,SAAS,GAAG,MAAM,IAAA,oBAAY,EAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;YACrB,OAAO;QACT,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAe,EAAE,MAAM,CAAC,CAAC;QACtE,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;QAC1B,SAAG,CAAC,IAAI,CACN,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,OAAO,cAAc,GAAG,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,CACnI,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,SAAG,CAAC,KAAK,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;YAAS,CAAC;QACT,MAAM,SAAS,EAAE,KAAK,EAAE,CAAC;IAC3B,CAAC;AACH,CAAC,CAAC;AA1BW,QAAA,OAAO,WA0BlB"}
@@ -0,0 +1,8 @@
1
+ import type { CommandBuilder } from "yargs";
2
+ export declare const command = "devices";
3
+ export declare const description = "List the robots of your Roborock account, with their model and protocol version";
4
+ export declare const builder: CommandBuilder;
5
+ export declare const handler: (argv: {
6
+ json?: boolean;
7
+ showKeys?: boolean;
8
+ }) => Promise<void>;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = exports.description = exports.command = void 0;
4
+ const logger_1 = require("../../../lib/logger");
5
+ const index_1 = require("../../../lib/roborock/index");
6
+ const log_1 = require("../../log");
7
+ exports.command = "devices";
8
+ exports.description = "List the robots of your Roborock account, with their model and protocol version";
9
+ exports.builder = {
10
+ json: { type: "boolean", description: "Print the robots as JSON" },
11
+ "show-keys": {
12
+ type: "boolean",
13
+ description: "Show the local keys in full (they are as sensitive as a password)",
14
+ },
15
+ };
16
+ const handler = async (argv) => {
17
+ const session = await (0, index_1.loadRoborockSession)();
18
+ if (!session) {
19
+ log_1.log.error("Not logged in. Run: node-miio roborock login");
20
+ process.exitCode = 1;
21
+ return;
22
+ }
23
+ try {
24
+ const devices = (await new index_1.RoborockWebApi(session).getDevices()).map((device) => ({
25
+ ...device,
26
+ localKey: argv.showKeys ? device.localKey : (0, logger_1.maskToken)(device.localKey),
27
+ }));
28
+ if (argv.json) {
29
+ console.log(JSON.stringify(devices, null, 2));
30
+ return;
31
+ }
32
+ if (devices.length === 0) {
33
+ log_1.log.info("No robots found in this account.");
34
+ return;
35
+ }
36
+ for (const device of devices) {
37
+ log_1.log.plain(`${device.name}${device.shared ? " (shared with you)" : ""}`);
38
+ log_1.log.plain(` Model: ${device.model ?? "-"} (${device.productName ?? "?"})`);
39
+ log_1.log.plain(` Protocol: ${device.protocolVersion}`);
40
+ log_1.log.plain(` Firmware: ${device.firmwareVersion ?? "-"}`);
41
+ log_1.log.plain(` Online: ${device.online ?? "-"}`);
42
+ log_1.log.plain(` ID (duid): ${device.duid}`);
43
+ log_1.log.plain(` Local key: ${device.localKey}`);
44
+ log_1.log.plain();
45
+ }
46
+ }
47
+ catch (err) {
48
+ if (err instanceof index_1.RoborockSessionExpiredError) {
49
+ log_1.log.error("The session expired. Run: node-miio roborock login");
50
+ }
51
+ else {
52
+ log_1.log.error(err instanceof index_1.RoborockError ? err.message : String(err));
53
+ }
54
+ process.exitCode = 1;
55
+ }
56
+ };
57
+ exports.handler = handler;
58
+ //# sourceMappingURL=devices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devices.js","sourceRoot":"","sources":["../../../../src/cli/commands/roborock/devices.ts"],"names":[],"mappings":";;;AAEA,gDAAgD;AAChD,uDAKqC;AACrC,mCAAgC;AAEnB,QAAA,OAAO,GAAG,SAAS,CAAC;AACpB,QAAA,WAAW,GACtB,iFAAiF,CAAC;AACvE,QAAA,OAAO,GAAmB;IACrC,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,0BAA0B,EAAE;IAClE,WAAW,EAAE;QACX,IAAI,EAAE,SAAS;QACf,WAAW,EACT,mEA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CAAC;YACF,SAAG,CAAC,KAAK,CAAC,gBAAgB,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC;YACpD,SAAG,CAAC,KAAK,CAAC,gBAAgB,MAAM,CAAC,eAAe,IAAI,GAAG,EAAE,CAAC,CAAC;YAC3D,SAAG,CAAC,KAAK,CAAC,gBAAgB,MAAM,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC;YAClD,SAAG,CAAC,KAAK,CAAC,gBAAgB,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;YACzC,SAAG,CAAC,KAAK,CAAC,gBAAgB,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC7C,SAAG,CAAC,KAAK,EAAE,CAAC;QACd,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,mCAA2B,EAAE,CAAC;YAC/C,SAAG,CAAC,KAAK,CAAC,oDAAoD,CAAC,CAAC;QAClE,CAAC;aAAM,CAAC;YACN,SAAG,CAAC,KAAK,CAAC,GAAG,YAAY,qBAAa,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACtE,CAAC;QACD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC,CAAC;AA3CW,QAAA,OAAO,WA2ClB"}
@@ -0,0 +1,7 @@
1
+ import type { CommandBuilder } from "yargs";
2
+ export declare const command = "login";
3
+ export declare const description = "Log in to your Roborock app account with a code sent by email (the session is saved)";
4
+ export declare const builder: CommandBuilder;
5
+ export declare const handler: (argv: {
6
+ email?: string;
7
+ }) => Promise<void>;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = exports.description = exports.command = void 0;
4
+ const index_1 = require("../../../lib/roborock/index");
5
+ const log_1 = require("../../log");
6
+ const prompt_1 = require("../../prompt");
7
+ exports.command = "login";
8
+ exports.description = "Log in to your Roborock app account with a code sent by email (the session is saved)";
9
+ exports.builder = {
10
+ email: {
11
+ type: "string",
12
+ description: "The email of the Roborock account (asked if not given)",
13
+ },
14
+ };
15
+ const handler = async (argv) => {
16
+ try {
17
+ const email = argv.email || (await (0, prompt_1.prompt)("Roborock account email: "));
18
+ const login = await index_1.RoborockLogin.start(email);
19
+ await login.requestCode();
20
+ log_1.log.info(`Roborock sent a verification code to ${email}.`);
21
+ const code = await (0, prompt_1.prompt)("Verification code: ");
22
+ const session = await login.loginWithCode(code);
23
+ await (0, index_1.saveRoborockSession)(session);
24
+ log_1.log.info(`Logged in (server ${session.baseUrl}).`);
25
+ log_1.log.plain(`Session saved to ${(0, index_1.defaultRoborockSessionFile)()} (readable only by you).`);
26
+ log_1.log.plain("Next: node-miio roborock devices");
27
+ }
28
+ catch (err) {
29
+ log_1.log.error(err instanceof index_1.RoborockError ? err.message : String(err));
30
+ process.exitCode = 1;
31
+ }
32
+ };
33
+ exports.handler = handler;
34
+ //# sourceMappingURL=login.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.js","sourceRoot":"","sources":["../../../../src/cli/commands/roborock/login.ts"],"names":[],"mappings":";;;AAEA,uDAKqC;AACrC,mCAAgC;AAChC,yCAAsC;AAEzB,QAAA,OAAO,GAAG,OAAO,CAAC;AAClB,QAAA,WAAW,GACtB,sFAAsF,CAAC;AAC5E,QAAA,OAAO,GAAmB;IACrC,KAAK,EAAE;QACL,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,wDAAwD;KACtE;CACF,CAAC;AAEK,MAAM,OAAO,GAAG,KAAK,EAAE,IAAwB,EAAE,EAAE;IACxD,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,IAAA,eAAM,EAAC,0BAA0B,CAAC,CAAC,CAAC;QACvE,MAAM,KAAK,GAAG,MAAM,qBAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC/C,MAAM,KAAK,CAAC,WAAW,EAAE,CAAC;QAC1B,SAAG,CAAC,IAAI,CAAC,wCAAwC,KAAK,GAAG,CAAC,CAAC;QAC3D,MAAM,IAAI,GAAG,MAAM,IAAA,eAAM,EAAC,qBAAqB,CAAC,CAAC;QACjD,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAChD,MAAM,IAAA,2BAAmB,EAAC,OAAO,CAAC,CAAC;QACnC,SAAG,CAAC,IAAI,CAAC,qBAAqB,OAAO,CAAC,OAAO,IAAI,CAAC,CAAC;QACnD,SAAG,CAAC,KAAK,CACP,oBAAoB,IAAA,kCAA0B,GAAE,0BAA0B,CAC3E,CAAC;QACF,SAAG,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;IAChD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,SAAG,CAAC,KAAK,CAAC,GAAG,YAAY,qBAAa,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACpE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC,CAAC;AAlBW,QAAA,OAAO,WAkBlB"}
@@ -0,0 +1,4 @@
1
+ export declare const command = "logout";
2
+ export declare const description = "Delete the saved Roborock session";
3
+ export declare const builder: {};
4
+ export declare const handler: () => Promise<void>;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = exports.description = exports.command = void 0;
4
+ const index_1 = require("../../../lib/roborock/index");
5
+ const log_1 = require("../../log");
6
+ exports.command = "logout";
7
+ exports.description = "Delete the saved Roborock session";
8
+ exports.builder = {};
9
+ const handler = async () => {
10
+ await (0, index_1.deleteRoborockSession)();
11
+ log_1.log.info(`Deleted ${(0, index_1.defaultRoborockSessionFile)()}`);
12
+ };
13
+ exports.handler = handler;
14
+ //# sourceMappingURL=logout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../../src/cli/commands/roborock/logout.ts"],"names":[],"mappings":";;;AAAA,uDAGqC;AACrC,mCAAgC;AAEnB,QAAA,OAAO,GAAG,QAAQ,CAAC;AACnB,QAAA,WAAW,GAAG,mCAAmC,CAAC;AAClD,QAAA,OAAO,GAAG,EAAE,CAAC;AAEnB,MAAM,OAAO,GAAG,KAAK,IAAI,EAAE;IAChC,MAAM,IAAA,6BAAqB,GAAE,CAAC;IAC9B,SAAG,CAAC,IAAI,CAAC,WAAW,IAAA,kCAA0B,GAAE,EAAE,CAAC,CAAC;AACtD,CAAC,CAAC;AAHW,QAAA,OAAO,WAGlB"}
@@ -0,0 +1,10 @@
1
+ import type { CommandBuilder } from "yargs";
2
+ export declare const command = "map";
3
+ export declare const description = "Download the map of a robot: rooms (named as in the Roborock app), robot position and current room";
4
+ export declare const builder: CommandBuilder;
5
+ export declare const handler: (argv: {
6
+ ip?: string;
7
+ duid?: string;
8
+ out?: string;
9
+ json?: boolean;
10
+ }) => Promise<void>;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.handler = exports.builder = exports.description = exports.command = void 0;
7
+ const promises_1 = __importDefault(require("node:fs/promises"));
8
+ const node_zlib_1 = require("node:zlib");
9
+ const roborock_map_1 = require("../../../lib/maps/roborock_map");
10
+ const index_1 = require("../../../lib/roborock/index");
11
+ const log_1 = require("../../log");
12
+ const robot_1 = require("./robot");
13
+ exports.command = "map";
14
+ exports.description = "Download the map of a robot: rooms (named as in the Roborock app), robot position and current room";
15
+ exports.builder = {
16
+ ...robot_1.robotOptions,
17
+ out: {
18
+ type: "string",
19
+ description: "Save the raw map file (gzipped), e.g. to attach it to a bug report",
20
+ },
21
+ json: { type: "boolean", description: "Print the result as JSON" },
22
+ };
23
+ const handler = async (argv) => {
24
+ let connected;
25
+ try {
26
+ connected = await (0, robot_1.connectRobot)(argv);
27
+ if (!connected) {
28
+ process.exitCode = 1;
29
+ return;
30
+ }
31
+ const { api, robot, home } = connected;
32
+ const file = await api.getMapData();
33
+ if (argv.out)
34
+ await promises_1.default.writeFile(argv.out, (0, node_zlib_1.gzipSync)(file));
35
+ const map = (0, roborock_map_1.parseRoborockMap)(file);
36
+ const names = new Map((0, index_1.roomNames)(await api.call("get_room_mapping", []), home.rooms).map((room) => [room.segmentId, room.name]));
37
+ const summary = {
38
+ model: robot.model,
39
+ mapVersion: `${map.majorVersion}.${map.minorVersion}`,
40
+ rooms: map.rooms.map((room) => ({ ...room, name: names.get(room.id) })),
41
+ robot: map.robot,
42
+ charger: map.charger,
43
+ currentRoom: map.currentRoom,
44
+ pathPoints: map.path.length,
45
+ };
46
+ if (argv.json) {
47
+ console.log(JSON.stringify(summary, null, 2));
48
+ }
49
+ else {
50
+ log_1.log.info(`Map of ${robot.name} (${robot.model})`);
51
+ log_1.log.plain(` Rooms: ${map.rooms.length}`);
52
+ for (const room of summary.rooms) {
53
+ log_1.log.plain(` ${room.id}${room.name ? ` (${room.name})` : ""}`);
54
+ }
55
+ log_1.log.plain(` Robot: ${map.robot ? `${map.robot.x}, ${map.robot.y}` : "-"}`);
56
+ log_1.log.plain(` Charger: ${map.charger ? `${map.charger.x}, ${map.charger.y}` : "-"}`);
57
+ const current = map.currentRoom;
58
+ log_1.log.plain(` Current room: ${current === undefined
59
+ ? "none (e.g. docked, or between rooms)"
60
+ : `${current}${names.get(current) ? ` (${names.get(current)})` : ""}`}`);
61
+ }
62
+ if (argv.out)
63
+ log_1.log.info(`Map file saved to ${argv.out}`);
64
+ }
65
+ catch (err) {
66
+ log_1.log.error(err instanceof Error ? err.message : String(err));
67
+ process.exitCode = 1;
68
+ }
69
+ finally {
70
+ await connected?.close();
71
+ }
72
+ };
73
+ exports.handler = handler;
74
+ //# sourceMappingURL=map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map.js","sourceRoot":"","sources":["../../../../src/cli/commands/roborock/map.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAkC;AAClC,yCAAqC;AAIrC,iEAAkE;AAClE,uDAAwD;AACxD,mCAAgC;AAEhC,mCAA0E;AAE7D,QAAA,OAAO,GAAG,KAAK,CAAC;AAChB,QAAA,WAAW,GACtB,oGAAoG,CAAC;AAC1F,QAAA,OAAO,GAAmB;IACrC,GAAG,oBAAY;IACf,GAAG,EAAE;QACH,IAAI,EAAE,QAAQ;QACd,WAAW,EACT,oEAAoE;KACvE;IACD,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,0BAA0B,EAAE;CACnE,CAAC;AAEK,MAAM,OAAO,GAAG,KAAK,EAAE,IAK7B,EAAE,EAAE;IACH,IAAI,SAAqC,CAAC;IAC1C,IAAI,CAAC;QACH,SAAS,GAAG,MAAM,IAAA,oBAAY,EAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;YACrB,OAAO;QACT,CAAC;QACD,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,SAAS,CAAC;QACvC,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,UAAU,EAAE,CAAC;QACpC,IAAI,IAAI,CAAC,GAAG;YAAE,MAAM,kBAAE,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,IAAA,oBAAQ,EAAC,IAAI,CAAC,CAAC,CAAC;QAC3D,MAAM,GAAG,GAAG,IAAA,+BAAgB,EAAC,IAAI,CAAC,CAAC;QACnC,MAAM,KAAK,GAAG,IAAI,GAAG,CACnB,IAAA,iBAAS,EAAC,MAAM,GAAG,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAA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cAAc,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CACnE,CAAC;YACF,SAAG,CAAC,KAAK,CACP,cAAc,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CACzE,CAAC;YACF,MAAM,OAAO,GAAG,GAAG,CAAC,WAAW,CAAC;YAChC,SAAG,CAAC,KAAK,CACP,mBACE,OAAO,KAAK,SAAS;gBACnB,CAAC,CAAC,sCAAsC;gBACxC,CAAC,CAAC,GAAG,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EACvE,EAAE,CACH,CAAC;QACJ,CAAC;QACD,IAAI,IAAI,CAAC,GAAG;YAAE,SAAG,CAAC,IAAI,CAAC,qBAAqB,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IAC1D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,SAAG,CAAC,KAAK,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;YAAS,CAAC;QACT,MAAM,SAAS,EAAE,KAAK,EAAE,CAAC;IAC3B,CAAC;AACH,CAAC,CAAC;AA7DW,QAAA,OAAO,WA6DlB"}
@@ -0,0 +1,30 @@
1
+ import { RoborockDeviceApi, type RoborockDevice, type RoborockHomeData } from "../../../lib/roborock/index";
2
+ export declare const robotOptions: {
3
+ readonly ip: {
4
+ readonly type: "string";
5
+ readonly description: "The robot's IP address. Optional: it's asked to the robot through Roborock's cloud (MQTT)";
6
+ };
7
+ readonly duid: {
8
+ readonly type: "string";
9
+ readonly description: "The robot's ID (`roborock devices`). Not needed with a single robot.";
10
+ };
11
+ };
12
+ export interface ConnectedRobot {
13
+ robot: RoborockDevice;
14
+ home: RoborockHomeData;
15
+ api: RoborockDeviceApi;
16
+ /** Closes the connections */
17
+ close: () => Promise<void>;
18
+ }
19
+ /**
20
+ * Connects to a robot of the saved account: locally (with its IP, or the IP it reports over MQTT), else over MQTT.
21
+ *
22
+ * @param options The options
23
+ * @param options.duid The robot's ID (optional with a single robot)
24
+ * @param options.ip The robot's IP (optional)
25
+ * @returns The robot, or `undefined` (with the error logged)
26
+ */
27
+ export declare function connectRobot(options: {
28
+ duid?: string;
29
+ ip?: string;
30
+ }): Promise<ConnectedRobot | undefined>;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.robotOptions = void 0;
4
+ exports.connectRobot = connectRobot;
5
+ const index_1 = require("../../../lib/roborock/index");
6
+ const log_1 = require("../../log");
7
+ exports.robotOptions = {
8
+ ip: {
9
+ type: "string",
10
+ description: "The robot's IP address. Optional: it's asked to the robot through Roborock's cloud (MQTT)",
11
+ },
12
+ duid: {
13
+ type: "string",
14
+ description: "The robot's ID (`roborock devices`). Not needed with a single robot.",
15
+ },
16
+ };
17
+ /**
18
+ * Connects to a robot of the saved account: locally (with its IP, or the IP it reports over MQTT), else over MQTT.
19
+ *
20
+ * @param options The options
21
+ * @param options.duid The robot's ID (optional with a single robot)
22
+ * @param options.ip The robot's IP (optional)
23
+ * @returns The robot, or `undefined` (with the error logged)
24
+ */
25
+ async function connectRobot(options) {
26
+ const session = await (0, index_1.loadRoborockSession)();
27
+ if (!session) {
28
+ log_1.log.error("Not logged in. Run: node-miio roborock login");
29
+ return undefined;
30
+ }
31
+ const home = await new index_1.RoborockWebApi(session).getHomeData();
32
+ const robots = (0, index_1.toDevices)(home);
33
+ const robot = options.duid
34
+ ? robots.find((r) => r.duid === options.duid)
35
+ : robots.length === 1
36
+ ? robots[0]
37
+ : undefined;
38
+ if (!robot) {
39
+ log_1.log.error(options.duid
40
+ ? `No robot with ID ${options.duid}. See: node-miio roborock devices`
41
+ : "Several robots in this account: choose one with --duid (see: node-miio roborock devices)");
42
+ return undefined;
43
+ }
44
+ const mqtt = new index_1.RoborockMqttSession(session.userData.rriot);
45
+ const api = new index_1.RoborockDeviceApi({
46
+ ...robot,
47
+ model: robot.model ?? "",
48
+ address: options.ip,
49
+ mqtt,
50
+ });
51
+ return {
52
+ robot,
53
+ home,
54
+ api,
55
+ close: async () => {
56
+ api.close();
57
+ await mqtt.close();
58
+ },
59
+ };
60
+ }
61
+ //# sourceMappingURL=robot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"robot.js","sourceRoot":"","sources":["../../../../src/cli/commands/roborock/robot.ts"],"names":[],"mappings":";;;AAwCA,oCAwCC;AAhFD,uDAQqC;AACrC,mCAAgC;AAEnB,QAAA,YAAY,GAAG;IAC1B,EAAE,EAAE;QACF,IAAI,EAAE,QAAQ;QACd,WAAW,EACT,2FAA2F;KAC9F;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,WAAW,EACT,sEAAsE;KACzE;CACO,CAAC;AAUX;;;;;;;GAOG;AACI,KAAK,UAAU,YAAY,CAAC,OAGlC;IACC,MAAM,OAAO,GAAG,MAAM,IAAA,2BAAmB,GAAE,CAAC;IAC5C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,SAAG,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAC1D,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,IAAI,sBAAc,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;IAC7D,MAAM,MAAM,GAAG,IAAA,iBAAS,EAAC,IAAI,CAAC,CAAC;IAC/B,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI;QACxB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC;QAC7C,CAAC,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;YACnB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;YACX,CAAC,CAAC,SAAS,CAAC;IAChB,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,SAAG,CAAC,KAAK,CACP,OAAO,CAAC,IAAI;YACV,CAAC,CAAC,oBAAoB,OAAO,CAAC,IAAI,mCAAmC;YACrE,CAAC,CAAC,0FAA0F,CAC/F,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,2BAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC7D,MAAM,GAAG,GAAG,IAAI,yBAAiB,CAAC;QAChC,GAAG,KAAK;QACR,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,EAAE;QACxB,OAAO,EAAE,OAAO,CAAC,EAAE;QACnB,IAAI;KACL,CAAC,CAAC;IACH,OAAO;QACL,KAAK;QACL,IAAI;QACJ,GAAG;QACH,KAAK,EAAE,KAAK,IAAI,EAAE;YAChB,GAAG,CAAC,KAAK,EAAE,CAAC;YACZ,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { CommandBuilder } from "yargs";
2
+ export declare const command = "rooms";
3
+ export declare const description = "List the rooms of a robot's map, with the names given in the Roborock app";
4
+ export declare const builder: CommandBuilder;
5
+ export declare const handler: (argv: {
6
+ ip?: string;
7
+ duid?: string;
8
+ json?: boolean;
9
+ }) => Promise<void>;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = exports.description = exports.command = void 0;
4
+ const index_1 = require("../../../lib/roborock/index");
5
+ const log_1 = require("../../log");
6
+ const robot_1 = require("./robot");
7
+ exports.command = "rooms";
8
+ exports.description = "List the rooms of a robot's map, with the names given in the Roborock app";
9
+ exports.builder = {
10
+ ...robot_1.robotOptions,
11
+ json: { type: "boolean", description: "Print the rooms as JSON" },
12
+ };
13
+ const handler = async (argv) => {
14
+ let connected;
15
+ try {
16
+ connected = await (0, robot_1.connectRobot)(argv);
17
+ if (!connected) {
18
+ process.exitCode = 1;
19
+ return;
20
+ }
21
+ const rooms = (0, index_1.roomNames)(await connected.api.call("get_room_mapping", []), connected.home.rooms);
22
+ if (argv.json) {
23
+ console.log(JSON.stringify(rooms, null, 2));
24
+ return;
25
+ }
26
+ log_1.log.info(`${connected.robot.name}: ${rooms.length} rooms`);
27
+ for (const room of rooms) {
28
+ log_1.log.plain(` ${String(room.segmentId).padStart(3)} ${room.name ?? "(no name)"}`);
29
+ }
30
+ }
31
+ catch (err) {
32
+ log_1.log.error(err instanceof Error ? err.message : String(err));
33
+ process.exitCode = 1;
34
+ }
35
+ finally {
36
+ await connected?.close();
37
+ }
38
+ };
39
+ exports.handler = handler;
40
+ //# sourceMappingURL=rooms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rooms.js","sourceRoot":"","sources":["../../../../src/cli/commands/roborock/rooms.ts"],"names":[],"mappings":";;;AAEA,uDAAwD;AACxD,mCAAgC;AAEhC,mCAA0E;AAE7D,QAAA,OAAO,GAAG,OAAO,CAAC;AAClB,QAAA,WAAW,GACtB,2EAA2E,CAAC;AACjE,QAAA,OAAO,GAAmB;IACrC,GAAG,oBAAY;IACf,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,yBAAyB,EAAE;CAClE,CAAC;AAEK,MAAM,OAAO,GAAG,KAAK,EAAE,IAI7B,EAAE,EAAE;IACH,IAAI,SAAqC,CAAC;IAC1C,IAAI,C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3
+ export declare const description = "Use a Roborock app account (opt-in, experimental): log in, list your robots, their rooms and maps, call methods";
4
+ export declare const builder: CommandBuilder;
5
+ export declare const handler: () => void;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.handler = exports.builder = exports.description = exports.command = void 0;
37
+ const call = __importStar(require("./roborock/call"));
38
+ const devices = __importStar(require("./roborock/devices"));
39
+ const login = __importStar(require("./roborock/login"));
40
+ const logout = __importStar(require("./roborock/logout"));
41
+ const map = __importStar(require("./roborock/map"));
42
+ const rooms = __importStar(require("./roborock/rooms"));
43
+ exports.command = "roborock <command>";
44
+ exports.description = "Use a Roborock app account (opt-in, experimental): log in, list your robots, their rooms and maps, call methods";
45
+ const builder = (yargs) => yargs
46
+ .command(login)
47
+ .command(devices)
48
+ .command(rooms)
49
+ .command(map)
50
+ .command(call)
51
+ .command(logout);
52
+ exports.builder = builder;
53
+ const handler = () => { };
54
+ exports.handler = handler;
55
+ //# sourceMappingURL=roborock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"roborock.js","sourceRoot":"","sources":["../../../src/cli/commands/roborock.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,sDAAwC;AACxC,4DAA8C;AAC9C,wDAA0C;AAC1C,0DAA4C;AAC5C,oDAAsC;AACtC,wDAA0C;AAE7B,QAAA,OAAO,GAAG,oBAAoB,CAAC;AAC/B,QAAA,WAAW,GACtB,iHAAiH,CAAC;AAC7G,MAAM,OAAO,GAAmB,CAAC,KAAW,EAAE,EAAE,CACrD,KAAK;KACF,OAAO,CAAC,KAAiC,CAAC;KAC1C,OAAO,CAAC,OAAmC,CAAC;KAC5C,OAAO,CAAC,KAAiC,CAAC;KAC1C,OAAO,CAAC,GAA+B,CAAC;KACxC,OAAO,CAAC,IAAgC,CAAC;KACzC,OAAO,CAAC,MAAkC,CAAC,CAAC;AAPpC,QAAA,OAAO,WAO6B;AAC1C,MAAM,OAAO,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAAnB,QAAA,OAAO,WAAY"}
package/dist/cli/index.js CHANGED
@@ -45,6 +45,7 @@ const control = __importStar(require("./commands/control"));
45
45
  const discover = __importStar(require("./commands/discover"));
46
46
  const inspect = __importStar(require("./commands/inspect"));
47
47
  const protocol = __importStar(require("./commands/protocol"));
48
+ const roborock = __importStar(require("./commands/roborock"));
48
49
  const spec = __importStar(require("./commands/miot-spec"));
49
50
  const tokens = __importStar(require("./commands/tokens"));
50
51
  // Commands are registered explicitly (instead of `commandDir`) because
@@ -57,6 +58,7 @@ void (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
57
58
  .command(discover)
58
59
  .command(inspect)
59
60
  .command(protocol)
61
+ .command(roborock)
60
62
  .command(spec)
61
63
  .command(tokens)
62
64
  .recommendCommands()
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,kDAAkD;AAClD,2CAAwC;AAExC,wDAA0C;AAC1C,gEAAkD;AAClD,4DAA8C;AAC9C,8DAAgD;AAChD,4DAA8C;AAC9C,8DAAgD;AAChD,2DAA6C;AAC7C,0DAA4C;AAE5C,uEAAuE;AACvE,sEAAsE;AACtE,KAAK,IAAA,eAAK,EAAC,IAAA,iBAAO,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;KAC9B,UAAU,CAAC,WAAW,CAAC;KACvB,OAAO,CAAC,KAAiC,CAAC;KAC1C,OAAO,CAAC,SAAqC,CAAC;KAC9C,OAAO,CAAC,OAAmC,CAAC;KAC5C,OAAO,CAAC,QAAoC,CAAC;KAC7C,OAAO,CAAC,OAAmC,CAAC;KAC5C,OAAO,CAAC,QAAoC,CAAC;KAC7C,OAAO,CAAC,IAAgC,CAAC;KACzC,OAAO,CAAC,MAAkC,CAAC;KAC3C,iBAAiB,EAAE;KACnB,aAAa,EAAE;KACf,MAAM,EAAE;KACR,KAAK,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,kDAAkD;AAClD,2CAAwC;AAExC,wDAA0C;AAC1C,gEAAkD;AAClD,4DAA8C;AAC9C,8DAAgD;AAChD,4DAA8C;AAC9C,8DAAgD;AAChD,8DAAgD;AAChD,2DAA6C;AAC7C,0DAA4C;AAE5C,uEAAuE;AACvE,sEAAsE;AACtE,KAAK,IAAA,eAAK,EAAC,IAAA,iBAAO,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;KAC9B,UAAU,CAAC,WAAW,CAAC;KACvB,OAAO,CAAC,KAAiC,CAAC;KAC1C,OAAO,CAAC,SAAqC,CAAC;KAC9C,OAAO,CAAC,OAAmC,CAAC;KAC5C,OAAO,CAAC,QAAoC,CAAC;KAC7C,OAAO,CAAC,OAAmC,CAAC;KAC5C,OAAO,CAAC,QAAoC,CAAC;KAC7C,OAAO,CAAC,QAAoC,CAAC;KAC7C,OAAO,CAAC,IAAgC,CAAC;KACzC,OAAO,CAAC,MAAkC,CAAC;KAC3C,iBAAiB,EAAE;KACnB,aAAa,EAAE;KACf,MAAM,EAAE;KACR,KAAK,EAAE,CAAC"}
@@ -63,4 +63,10 @@ export declare class DeviceInfo {
63
63
  _retryOnTimeout(retries: number | undefined, actionPromiseFn: any): Promise<any>;
64
64
  _nextId(isFirstAttempt: boolean): number;
65
65
  }
66
+ /**
67
+ * What a device needs from its connection: {@link DeviceInfo} (miIO over UDP) or a Roborock connection.
68
+ */
69
+ export type DeviceApi = Pick<DeviceInfo, "model" | "address" | "port" | "token" | "autoToken" | "connected" | "logger" | "call"> & {
70
+ id: number | string | undefined;
71
+ };
66
72
  export {};
@@ -100,11 +100,11 @@ export declare class Vacuum extends Vacuum_base {
100
100
  */
101
101
  changeFanSpeed(speed: any): Promise<void>;
102
102
  /**
103
- * Get WaterBoxMode (only working for the model S6)
103
+ * The current water level (see {@link waterBoxModes}).
104
104
  *
105
- * @returns The current water box mode
105
+ * @returns The current water box mode (`undefined` if the robot doesn't report it)
106
106
  */
107
- getWaterBoxMode(): Promise<any>;
107
+ getWaterBoxMode(): Promise<number | undefined>;
108
108
  setWaterBoxMode(mode: any): Promise<void>;
109
109
  /**
110
110
  * Activate the find function, will make the device give off a sound.
@@ -180,6 +180,12 @@ class Vacuum extends climate_1.Vacuum.with(device_1.MiioApi, battery_level_1.Bat
180
180
  return "room-cleaning";
181
181
  case 22:
182
182
  return "dust-collection";
183
+ // Docks that wash the mop (e.g. S7 MaxV Ultra, Saros 20): codes from the Roborock app
184
+ case 23:
185
+ case 25:
186
+ return "washing-mop";
187
+ case 26:
188
+ return "returning-to-wash-mop";
183
189
  case 100:
184
190
  return "fully-charged";
185
191
  }
@@ -414,16 +420,20 @@ class Vacuum extends climate_1.Vacuum.with(device_1.MiioApi, battery_level_1.Bat
414
420
  }).then(check_result_1.checkResult);
415
421
  }
416
422
  /**
417
- * Get WaterBoxMode (only working for the model S6)
423
+ * The current water level (see {@link waterBoxModes}).
418
424
  *
419
- * @returns The current water box mode
425
+ * @returns The current water box mode (`undefined` if the robot doesn't report it)
420
426
  */
421
427
  async getWaterBoxMode() {
422
428
  // From https://github.com/marcelrv/XiaomiRobotVacuumProtocol/blob/master/water_box_custom_mode.md
423
429
  const response = await this.call("get_water_box_custom_mode", [], {
424
430
  refresh: ["waterBoxMode"],
425
431
  });
426
- return response[0];
432
+ // Older firmwares respond `[203]`, newer ones `{ water_box_mode: 235, distance_off: 0 }`
433
+ const value = Array.isArray(response)
434
+ ? response[0]
435
+ : response?.water_box_mode;
436
+ return typeof value === "number" ? value : undefined;
427
437
  }
428
438
  setWaterBoxMode(mode) {
429
439
  // From https://github.com/marcelrv/XiaomiRobotVacuumProtocol/blob/master/water_box_custom_mode.md