node-miio 0.6.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.
- package/README.md +4 -0
- package/dist/cli/commands/roborock/call.d.ts +10 -0
- package/dist/cli/commands/roborock/call.js +34 -0
- package/dist/cli/commands/roborock/call.js.map +1 -0
- package/dist/cli/commands/roborock/devices.d.ts +8 -0
- package/dist/cli/commands/roborock/devices.js +58 -0
- package/dist/cli/commands/roborock/devices.js.map +1 -0
- package/dist/cli/commands/roborock/login.d.ts +7 -0
- package/dist/cli/commands/roborock/login.js +34 -0
- package/dist/cli/commands/roborock/login.js.map +1 -0
- package/dist/cli/commands/roborock/logout.d.ts +4 -0
- package/dist/cli/commands/roborock/logout.js +14 -0
- package/dist/cli/commands/roborock/logout.js.map +1 -0
- package/dist/cli/commands/roborock/map.d.ts +10 -0
- package/dist/cli/commands/roborock/map.js +74 -0
- package/dist/cli/commands/roborock/map.js.map +1 -0
- package/dist/cli/commands/roborock/robot.d.ts +30 -0
- package/dist/cli/commands/roborock/robot.js +61 -0
- package/dist/cli/commands/roborock/robot.js.map +1 -0
- package/dist/cli/commands/roborock/rooms.d.ts +9 -0
- package/dist/cli/commands/roborock/rooms.js +40 -0
- package/dist/cli/commands/roborock/rooms.js.map +1 -0
- package/dist/cli/commands/roborock.d.ts +5 -0
- package/dist/cli/commands/roborock.js +55 -0
- package/dist/cli/commands/roborock.js.map +1 -0
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/lib/cloud/client.d.ts +18 -5
- package/dist/lib/cloud/client.js +17 -7
- package/dist/lib/cloud/client.js.map +1 -1
- package/dist/lib/cloud/device_cache.d.ts +38 -0
- package/dist/lib/cloud/device_cache.js +59 -0
- package/dist/lib/cloud/device_cache.js.map +1 -0
- package/dist/lib/cloud/index.d.ts +2 -1
- package/dist/lib/cloud/index.js +4 -1
- package/dist/lib/cloud/index.js.map +1 -1
- package/dist/lib/device_info.d.ts +6 -0
- package/dist/lib/devices/vacuums/vacuum.d.ts +3 -3
- package/dist/lib/devices/vacuums/vacuum.js +13 -3
- package/dist/lib/devices/vacuums/vacuum.js.map +1 -1
- package/dist/lib/devices/vacuums/vacuum_modes.d.ts +2 -0
- package/dist/lib/devices/vacuums/vacuum_modes.js +15 -0
- package/dist/lib/devices/vacuums/vacuum_modes.js.map +1 -1
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +1 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/logger.js +1 -1
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/management.d.ts +2 -2
- package/dist/lib/management.js.map +1 -1
- package/dist/lib/roborock/device.d.ts +118 -0
- package/dist/lib/roborock/device.js +273 -0
- package/dist/lib/roborock/device.js.map +1 -0
- package/dist/lib/roborock/errors.d.ts +18 -0
- package/dist/lib/roborock/errors.js +37 -0
- package/dist/lib/roborock/errors.js.map +1 -0
- package/dist/lib/roborock/hawk.d.ts +39 -0
- package/dist/lib/roborock/hawk.js +48 -0
- package/dist/lib/roborock/hawk.js.map +1 -0
- package/dist/lib/roborock/index.d.ts +9 -0
- package/dist/lib/roborock/index.js +36 -0
- package/dist/lib/roborock/index.js.map +1 -0
- package/dist/lib/roborock/local_connection.d.ts +72 -0
- package/dist/lib/roborock/local_connection.js +232 -0
- package/dist/lib/roborock/local_connection.js.map +1 -0
- package/dist/lib/roborock/map_response.d.ts +26 -0
- package/dist/lib/roborock/map_response.js +104 -0
- package/dist/lib/roborock/map_response.js.map +1 -0
- package/dist/lib/roborock/message.d.ts +110 -0
- package/dist/lib/roborock/message.js +313 -0
- package/dist/lib/roborock/message.js.map +1 -0
- package/dist/lib/roborock/mqtt.d.ts +119 -0
- package/dist/lib/roborock/mqtt.js +305 -0
- package/dist/lib/roborock/mqtt.js.map +1 -0
- package/dist/lib/roborock/rooms.d.ts +17 -0
- package/dist/lib/roborock/rooms.js +23 -0
- package/dist/lib/roborock/rooms.js.map +1 -0
- package/dist/lib/roborock/session_store.d.ts +21 -0
- package/dist/lib/roborock/session_store.js +52 -0
- package/dist/lib/roborock/session_store.js.map +1 -0
- package/dist/lib/roborock/web_api.d.ts +142 -0
- package/dist/lib/roborock/web_api.js +334 -0
- package/dist/lib/roborock/web_api.js.map +1 -0
- package/docs/cloud.md +11 -0
- package/docs/roborock.md +91 -0
- package/package.json +2 -1
- package/snapshots/vacuum-specs.json.gz +0 -0
- package/.claude/settings.json +0 -5
- package/.claude/skills/release/SKILL.md +0 -73
- package/AGENTS.md +0 -140
- package/CONTRIBUTING.md +0 -58
|
@@ -0,0 +1,334 @@
|
|
|
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.RoborockWebApi = exports.RoborockLogin = exports.ROBOROCK_BASE_URLS = void 0;
|
|
7
|
+
exports.toDevices = toDevices;
|
|
8
|
+
/**
|
|
9
|
+
* The Roborock account API: what the Roborock app uses to log in and list the robots of the account.
|
|
10
|
+
*
|
|
11
|
+
* Robots paired with the Roborock app don't use the Xiaomi Cloud or miIO tokens. Instead, the account's home data
|
|
12
|
+
* gives each robot's `duid` and `localKey`, which encrypt the local (TCP 58867) and MQTT connections.
|
|
13
|
+
*
|
|
14
|
+
* The endpoints and their parameters follow python-roborock (Apache-2.0, https://github.com/Python-roborock/python-roborock),
|
|
15
|
+
* `roborock/web_api/`. No code is copied from it.
|
|
16
|
+
*/
|
|
17
|
+
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
18
|
+
const logger_1 = require("../logger");
|
|
19
|
+
const errors_1 = require("./errors");
|
|
20
|
+
const hawk_1 = require("./hawk");
|
|
21
|
+
const debug = (0, logger_1.createDebug)("miio:roborock");
|
|
22
|
+
/** The regional servers that know where an account lives (`getUrlByEmail`) */
|
|
23
|
+
exports.ROBOROCK_BASE_URLS = [
|
|
24
|
+
"https://usiot.roborock.com",
|
|
25
|
+
"https://euiot.roborock.com",
|
|
26
|
+
"https://cniot.roborock.com",
|
|
27
|
+
"https://ruiot.roborock.com",
|
|
28
|
+
];
|
|
29
|
+
class Requester {
|
|
30
|
+
options;
|
|
31
|
+
constructor(options) {
|
|
32
|
+
this.options = options;
|
|
33
|
+
}
|
|
34
|
+
async json(url, { method = "POST", query, form, headers = {} } = {}) {
|
|
35
|
+
const target = new URL(url);
|
|
36
|
+
for (const [key, value] of Object.entries(query ?? {})) {
|
|
37
|
+
target.searchParams.set(key, value);
|
|
38
|
+
}
|
|
39
|
+
const fetchImpl = this.options.fetch ?? fetch;
|
|
40
|
+
const response = await fetchImpl(target.toString(), {
|
|
41
|
+
method,
|
|
42
|
+
headers: form
|
|
43
|
+
? { ...headers, "Content-Type": "application/x-www-form-urlencoded" }
|
|
44
|
+
: headers,
|
|
45
|
+
body: form ? new URLSearchParams(form).toString() : undefined,
|
|
46
|
+
signal: AbortSignal.timeout(this.options.timeoutMs ?? 15_000),
|
|
47
|
+
});
|
|
48
|
+
const text = await response.text();
|
|
49
|
+
try {
|
|
50
|
+
return JSON.parse(text);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
throw new errors_1.RoborockApiError(`Unexpected response from ${target.host}${target.pathname} (HTTP ${response.status})`, response.status);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @param session The session (or the login in progress)
|
|
59
|
+
* @param session.email The email of the account
|
|
60
|
+
* @param session.clientId The random ID of this client
|
|
61
|
+
* @returns The `header_clientid` header: base64(md5(email + clientId))
|
|
62
|
+
*/
|
|
63
|
+
function clientIdHeader({ email, clientId, }) {
|
|
64
|
+
return node_crypto_1.default
|
|
65
|
+
.createHash("md5")
|
|
66
|
+
.update(email)
|
|
67
|
+
.update(clientId)
|
|
68
|
+
.digest("base64");
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* @param response The API response
|
|
72
|
+
* @param what What was requested (for the error message)
|
|
73
|
+
* @returns The response's data
|
|
74
|
+
*/
|
|
75
|
+
function expectOk(response, what) {
|
|
76
|
+
if (response.code === 200 && response.data !== undefined) {
|
|
77
|
+
return response.data;
|
|
78
|
+
}
|
|
79
|
+
throw new errors_1.RoborockApiError(`${what} failed: ${response.msg ?? "unknown error"} (code ${response.code})`, response.code);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Logs in to a Roborock account with a code sent by email (the Roborock app's default login).
|
|
83
|
+
*
|
|
84
|
+
* ```ts
|
|
85
|
+
* const login = await RoborockLogin.start("me@example.com");
|
|
86
|
+
* await login.requestCode();
|
|
87
|
+
* const session = await login.loginWithCode(code);
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
class RoborockLogin {
|
|
91
|
+
http;
|
|
92
|
+
email;
|
|
93
|
+
baseUrl;
|
|
94
|
+
country;
|
|
95
|
+
countryCode;
|
|
96
|
+
clientId;
|
|
97
|
+
constructor(http, email,
|
|
98
|
+
/** The regional server of the account */
|
|
99
|
+
baseUrl, country, countryCode, clientId) {
|
|
100
|
+
this.http = http;
|
|
101
|
+
this.email = email;
|
|
102
|
+
this.baseUrl = baseUrl;
|
|
103
|
+
this.country = country;
|
|
104
|
+
this.countryCode = countryCode;
|
|
105
|
+
this.clientId = clientId;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Finds the regional server of the account.
|
|
109
|
+
*
|
|
110
|
+
* @param email The email of the Roborock account
|
|
111
|
+
* @param options The options
|
|
112
|
+
* @returns The login
|
|
113
|
+
*/
|
|
114
|
+
static async start(email, options = {}) {
|
|
115
|
+
const http = new Requester(options);
|
|
116
|
+
for (const baseUrl of exports.ROBOROCK_BASE_URLS) {
|
|
117
|
+
const response = await http.json(`${baseUrl}/api/v1/getUrlByEmail`, {
|
|
118
|
+
query: { email, needtwostepauth: "false" },
|
|
119
|
+
});
|
|
120
|
+
if (response.code === 2003) {
|
|
121
|
+
throw new errors_1.RoborockAuthError("The email is not valid", response.code);
|
|
122
|
+
}
|
|
123
|
+
const data = expectOk(response, "Finding the account's server");
|
|
124
|
+
if (data.country || data.countrycode) {
|
|
125
|
+
debug(`Account found on ${data.url} (country ${data.country})`);
|
|
126
|
+
return new RoborockLogin(http, email, data.url, data.country, data.countrycode === undefined ? undefined : String(data.countrycode), node_crypto_1.default.randomBytes(16).toString("base64url"));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
throw new errors_1.RoborockAuthError("No Roborock account was found with this email on any region");
|
|
130
|
+
}
|
|
131
|
+
headers(extra = {}) {
|
|
132
|
+
return {
|
|
133
|
+
header_clientid: clientIdHeader({
|
|
134
|
+
email: this.email,
|
|
135
|
+
clientId: this.clientId,
|
|
136
|
+
}),
|
|
137
|
+
header_clientlang: "en",
|
|
138
|
+
...extra,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Asks Roborock to email a verification code.
|
|
143
|
+
*/
|
|
144
|
+
async requestCode() {
|
|
145
|
+
const response = this.country && this.countryCode
|
|
146
|
+
? await this.http.json(`${this.baseUrl}/api/v4/email/code/send`, {
|
|
147
|
+
form: { email: this.email, type: "login", platform: "" },
|
|
148
|
+
headers: this.headers(),
|
|
149
|
+
})
|
|
150
|
+
: await this.http.json(`${this.baseUrl}/api/v1/sendEmailCode`, {
|
|
151
|
+
query: { username: this.email, type: "auth" },
|
|
152
|
+
headers: this.headers(),
|
|
153
|
+
});
|
|
154
|
+
if (response.code === 200)
|
|
155
|
+
return;
|
|
156
|
+
if (response.code === 2008) {
|
|
157
|
+
throw new errors_1.RoborockAuthError("This Roborock account doesn't exist", response.code);
|
|
158
|
+
}
|
|
159
|
+
if (response.code === 9002) {
|
|
160
|
+
throw new errors_1.RoborockAuthError("Too many codes requested: try again later", response.code);
|
|
161
|
+
}
|
|
162
|
+
throw new errors_1.RoborockApiError(`Requesting the code failed: ${response.msg} (code ${response.code})`, response.code);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* @param code The code from the email
|
|
166
|
+
* @returns The session
|
|
167
|
+
*/
|
|
168
|
+
async loginWithCode(code) {
|
|
169
|
+
const response = this.country && this.countryCode
|
|
170
|
+
? await this.loginV4(code, this.country, this.countryCode)
|
|
171
|
+
: await this.http.json(`${this.baseUrl}/api/v1/loginWithCode`, {
|
|
172
|
+
query: {
|
|
173
|
+
username: this.email,
|
|
174
|
+
verifycode: code,
|
|
175
|
+
verifycodetype: "AUTH_EMAIL_CODE",
|
|
176
|
+
},
|
|
177
|
+
headers: this.headers(),
|
|
178
|
+
});
|
|
179
|
+
switch (response.code) {
|
|
180
|
+
case 2018:
|
|
181
|
+
throw new errors_1.RoborockAuthError("The code is not valid", response.code);
|
|
182
|
+
case 3009:
|
|
183
|
+
case 3006:
|
|
184
|
+
throw new errors_1.RoborockAuthError("Accept the user agreement in the Roborock app, then try again", response.code);
|
|
185
|
+
case 3039:
|
|
186
|
+
throw new errors_1.RoborockAuthError("This Roborock account doesn't exist in this region", response.code);
|
|
187
|
+
}
|
|
188
|
+
const userData = expectOk(response, "Logging in");
|
|
189
|
+
if (!userData?.token || !userData.rriot) {
|
|
190
|
+
throw new errors_1.RoborockApiError("The login response has no credentials");
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
193
|
+
email: this.email,
|
|
194
|
+
baseUrl: this.baseUrl,
|
|
195
|
+
clientId: this.clientId,
|
|
196
|
+
userData,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
async loginV4(code, country, countryCode) {
|
|
200
|
+
// Sign a random string: the login needs it (x-mercy-ks / x-mercy-k)
|
|
201
|
+
const ks = node_crypto_1.default
|
|
202
|
+
.randomBytes(12)
|
|
203
|
+
.toString("base64url")
|
|
204
|
+
.replace(/[-_]/g, "a")
|
|
205
|
+
.slice(0, 16);
|
|
206
|
+
const signed = expectOk(await this.http.json(`${this.baseUrl}/api/v3/key/sign`, {
|
|
207
|
+
query: { s: ks },
|
|
208
|
+
headers: this.headers(),
|
|
209
|
+
}), "Signing the login");
|
|
210
|
+
const agreement = await this.agreementVersion(country);
|
|
211
|
+
return this.http.json(`${this.baseUrl}/api/v4/auth/email/login/code`, {
|
|
212
|
+
form: {
|
|
213
|
+
country,
|
|
214
|
+
countryCode,
|
|
215
|
+
email: this.email,
|
|
216
|
+
code,
|
|
217
|
+
majorVersion: String(agreement.majorVersion),
|
|
218
|
+
minorVersion: String(agreement.minorVersion),
|
|
219
|
+
},
|
|
220
|
+
headers: this.headers({
|
|
221
|
+
"x-mercy-ks": ks,
|
|
222
|
+
"x-mercy-k": signed.k,
|
|
223
|
+
header_appversion: "4.54.02",
|
|
224
|
+
header_phonesystem: "iOS",
|
|
225
|
+
header_phonemodel: "iPhone16,1",
|
|
226
|
+
}),
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* @param country The country of the account
|
|
231
|
+
* @returns The current version of the user agreement: the login rejects an outdated one
|
|
232
|
+
*/
|
|
233
|
+
async agreementVersion(country) {
|
|
234
|
+
try {
|
|
235
|
+
const response = await this.http.json(`${this.baseUrl}/api/v3/app/agreement/latest`, {
|
|
236
|
+
method: "GET",
|
|
237
|
+
query: { country },
|
|
238
|
+
headers: { header_clientlang: "en" },
|
|
239
|
+
});
|
|
240
|
+
const { majorVersion, minorVersion } = response.data ?? {};
|
|
241
|
+
if (response.code === 200 &&
|
|
242
|
+
typeof majorVersion === "number" &&
|
|
243
|
+
typeof minorVersion === "number") {
|
|
244
|
+
return { majorVersion, minorVersion };
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
catch (err) {
|
|
248
|
+
debug(`Couldn't get the user agreement version: ${err}`);
|
|
249
|
+
}
|
|
250
|
+
return { majorVersion: 14, minorVersion: 0 };
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
exports.RoborockLogin = RoborockLogin;
|
|
254
|
+
/**
|
|
255
|
+
* The account API, once logged in.
|
|
256
|
+
*/
|
|
257
|
+
class RoborockWebApi {
|
|
258
|
+
session;
|
|
259
|
+
http;
|
|
260
|
+
constructor(session, options = {}) {
|
|
261
|
+
this.session = session;
|
|
262
|
+
this.http = new Requester(options);
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* @returns The ID of the account's home
|
|
266
|
+
*/
|
|
267
|
+
async getHomeId() {
|
|
268
|
+
const response = await this.http.json(`${this.session.baseUrl}/api/v1/getHomeDetail`, {
|
|
269
|
+
method: "GET",
|
|
270
|
+
headers: {
|
|
271
|
+
header_clientid: clientIdHeader(this.session),
|
|
272
|
+
Authorization: this.session.userData.token,
|
|
273
|
+
},
|
|
274
|
+
});
|
|
275
|
+
if (response.code === 2010)
|
|
276
|
+
throw new errors_1.RoborockSessionExpiredError();
|
|
277
|
+
return expectOk(response, "Getting the home").rrHomeId;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* @returns The home data: robots (with their local keys), products and rooms
|
|
281
|
+
*/
|
|
282
|
+
async getHomeData() {
|
|
283
|
+
const homeId = await this.getHomeId();
|
|
284
|
+
const { rriot } = this.session.userData;
|
|
285
|
+
const path = `/v3/user/homes/${homeId}`;
|
|
286
|
+
const response = await this.http.json(`${rriot.r.a.replace(/\/$/, "")}${path}`, {
|
|
287
|
+
method: "GET",
|
|
288
|
+
headers: { Authorization: (0, hawk_1.hawkAuthorization)(rriot, path) },
|
|
289
|
+
});
|
|
290
|
+
if (!response.success || !response.result) {
|
|
291
|
+
throw new errors_1.RoborockApiError(`Getting the home data failed: ${response.msg ?? JSON.stringify(response)}`, response.code);
|
|
292
|
+
}
|
|
293
|
+
return {
|
|
294
|
+
...response.result,
|
|
295
|
+
products: response.result.products ?? [],
|
|
296
|
+
devices: response.result.devices ?? [],
|
|
297
|
+
receivedDevices: response.result.receivedDevices ?? [],
|
|
298
|
+
rooms: response.result.rooms ?? [],
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* @returns The robots of the account (own and shared), with their models
|
|
303
|
+
*/
|
|
304
|
+
async getDevices() {
|
|
305
|
+
return toDevices(await this.getHomeData());
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
exports.RoborockWebApi = RoborockWebApi;
|
|
309
|
+
/**
|
|
310
|
+
* @param home The home data
|
|
311
|
+
* @returns The robots of the home (own and shared), with their product details
|
|
312
|
+
*/
|
|
313
|
+
function toDevices(home) {
|
|
314
|
+
const products = new Map(home.products.map((p) => [p.id, p]));
|
|
315
|
+
const map = (device, shared) => {
|
|
316
|
+
const product = products.get(device.productId);
|
|
317
|
+
return {
|
|
318
|
+
duid: device.duid,
|
|
319
|
+
name: device.name,
|
|
320
|
+
model: product?.model,
|
|
321
|
+
productName: product?.name,
|
|
322
|
+
protocolVersion: device.pv,
|
|
323
|
+
firmwareVersion: device.fv,
|
|
324
|
+
online: device.online,
|
|
325
|
+
localKey: device.localKey,
|
|
326
|
+
shared,
|
|
327
|
+
};
|
|
328
|
+
};
|
|
329
|
+
return [
|
|
330
|
+
...home.devices.map((d) => map(d, false)),
|
|
331
|
+
...home.receivedDevices.map((d) => map(d, true)),
|
|
332
|
+
];
|
|
333
|
+
}
|
|
334
|
+
//# sourceMappingURL=web_api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web_api.js","sourceRoot":"","sources":["../../../src/lib/roborock/web_api.ts"],"names":[],"mappings":";;;;;;AAydA,8BAoBC;AA7eD;;;;;;;;GAQG;AACH,8DAAiC;AAEjC,sCAAwC;AAGxC,qCAIkB;AAClB,iCAA+D;AAE/D,MAAM,KAAK,GAAG,IAAA,oBAAW,EAAC,eAAe,CAAC,CAAC;AAE3C,8EAA8E;AACjE,QAAA,kBAAkB,GAAG;IAChC,4BAA4B;IAC5B,4BAA4B;IAC5B,4BAA4B;IAC5B,4BAA4B;CAC7B,CAAC;AA2FF,MAAM,SAAS;IACgB;IAA7B,YAA6B,OAA8B;QAA9B,YAAO,GAAP,O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E,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9D,MAAM,GAAG,GAAG,CAAC,MAA0B,EAAE,MAAe,EAAE,EAAE;QAC1D,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC/C,OAAO;YACL,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,KAAK,EAAE,OAAO,EAAE,KAAK;YACrB,WAAW,EAAE,OAAO,EAAE,IAAI;YAC1B,eAAe,EAAE,MAAM,CAAC,EAAE;YAC1B,eAAe,EAAE,MAAM,CAAC,EAAE;YAC1B,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,MAAM;SACP,CAAC;IACJ,CAAC,CAAC;IACF,OAAO;QACL,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QACzC,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;KACjD,CAAC;AACJ,CAAC"}
|
package/docs/cloud.md
CHANGED
|
@@ -62,6 +62,17 @@ const devices = await new XiaomiCloud(session!).getDevices({ servers: ["de"] });
|
|
|
62
62
|
// [{ did, name, model, token, localip, mac, server, homeId, homeOwner }]
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
+
To share the device list (e.g. between the devices of a Homebridge or Matterbridge platform), use
|
|
66
|
+
`CloudDeviceCache`: it lists the devices once, and finds them by ID, token or IP.
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import { CloudDeviceCache, MapWatcher } from "node-miio";
|
|
70
|
+
|
|
71
|
+
const devices = new CloudDeviceCache(cloud);
|
|
72
|
+
const robot = await devices.find({ ip: "192.168.1.20" }); // { token, server, … }
|
|
73
|
+
const watcher = new MapWatcher(vacuum, cloud, { server: robot!.server });
|
|
74
|
+
```
|
|
75
|
+
|
|
65
76
|
Errors:
|
|
66
77
|
|
|
67
78
|
- `CloudAuthError`: wrong credentials, captcha or verification code.
|
package/docs/roborock.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Roborock app accounts (experimental)
|
|
2
|
+
|
|
3
|
+
Robots paired with the **Roborock app** (instead of Mi Home) are registered on Roborock's own cloud, not Xiaomi's.
|
|
4
|
+
Their miIO token doesn't work: instead, each robot has a `localKey` that encrypts its local (TCP port 58867) and
|
|
5
|
+
MQTT messages. The Roborock account gives the `localKey` of every robot.
|
|
6
|
+
|
|
7
|
+
Status: node-miio can log in, list the robots and control them with the existing `Vacuum` class: over the local
|
|
8
|
+
network (TCP 58867) when possible, else through Roborock's cloud (MQTT), which also finds the robot's IP and sends its
|
|
9
|
+
status pushes. Maps come over MQTT and are parsed by `parseRoborockMap`, like the Xiaomi Cloud ones.
|
|
10
|
+
([homebridge-xiaomi-roborock-vacuum#104](https://github.com/homebridge-xiaomi-roborock-vacuum/homebridge-xiaomi-roborock-vacuum/issues/104)).
|
|
11
|
+
|
|
12
|
+
## Command line
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npx node-miio roborock login # asks for your email, then for the code Roborock emails you
|
|
16
|
+
npx node-miio roborock devices # name, model, protocol version, firmware, duid and (masked) local key
|
|
17
|
+
npx node-miio roborock rooms # the map's rooms, named as in the Roborock app
|
|
18
|
+
npx node-miio roborock call get_status # any method, e.g. get_consumable, get_room_mapping
|
|
19
|
+
npx node-miio roborock map # rooms, robot and charger positions, current room (--out: save the file)
|
|
20
|
+
npx node-miio roborock logout
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`rooms` and `call` ask the robot for its IP through Roborock's cloud, then talk to it locally (or through the cloud
|
|
24
|
+
if it can't be reached locally). Pass `--ip` to skip the cloud lookup. With several robots, choose one with `--duid`
|
|
25
|
+
(from `roborock devices`).
|
|
26
|
+
|
|
27
|
+
`devices --json` prints JSON; `--show-keys` shows the local keys in full. The session is saved, readable only by
|
|
28
|
+
you, in `roborock-session.json` next to the Xiaomi Cloud session (see `MIIO_CONFIG_DIR` in [Xiaomi Cloud](cloud.md)).
|
|
29
|
+
It's as sensitive as a password.
|
|
30
|
+
|
|
31
|
+
The **protocol version** of `roborock devices` tells which robots node-miio can control:
|
|
32
|
+
|
|
33
|
+
- `1.0` and `L01`: the same commands as miIO (`get_status`, `app_start`, `app_segment_clean`…). Most S, Q and Saros robots.
|
|
34
|
+
- `A01` and `B01`: different command sets (e.g. the Q7/Q10 series, Dyad/Zeo). Not planned yet.
|
|
35
|
+
|
|
36
|
+
Locally, robots speak `1.0` (AES-ECB) or `L01` (AES-GCM), which may differ from that version: the Saros 20
|
|
37
|
+
(`roborock.vacuum.a296`, `pv` 1.0) only answers `L01`. node-miio tries both and remembers the one that works. Robots
|
|
38
|
+
drop requests whose sequence number isn't higher than the previous one.
|
|
39
|
+
|
|
40
|
+
Roborock limits logins and code requests: avoid running `login` repeatedly.
|
|
41
|
+
|
|
42
|
+
## Library
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import {
|
|
46
|
+
RoborockLogin,
|
|
47
|
+
roborockApiOf,
|
|
48
|
+
RoborockMqttSession,
|
|
49
|
+
RoborockWebApi,
|
|
50
|
+
roborockDevice,
|
|
51
|
+
roomNames,
|
|
52
|
+
saveRoborockSession,
|
|
53
|
+
toDevices,
|
|
54
|
+
} from "node-miio";
|
|
55
|
+
|
|
56
|
+
const login = await RoborockLogin.start("me@example.com");
|
|
57
|
+
await login.requestCode();
|
|
58
|
+
const session = await login.loginWithCode(codeFromTheEmail);
|
|
59
|
+
await saveRoborockSession(session);
|
|
60
|
+
|
|
61
|
+
const home = await new RoborockWebApi(session).getHomeData();
|
|
62
|
+
const [robot] = toDevices(home);
|
|
63
|
+
// { duid, name, model: "roborock.vacuum.a296", protocolVersion: "1.0", localKey, shared, … }
|
|
64
|
+
|
|
65
|
+
// One MQTT session per account, shared by its robots
|
|
66
|
+
const mqtt = new RoborockMqttSession(session.userData.rriot);
|
|
67
|
+
|
|
68
|
+
// A `Vacuum`, like the ones of `device()`. Local when possible (`address` is optional with `mqtt`), else MQTT.
|
|
69
|
+
const vacuum = await roborockDevice({
|
|
70
|
+
...robot,
|
|
71
|
+
model: robot.model,
|
|
72
|
+
mqtt,
|
|
73
|
+
localProtocolVersion: savedVersion, // optional: what `roborockApiOf(vacuum).localProtocolVersion` was last time
|
|
74
|
+
});
|
|
75
|
+
console.log(await vacuum.batteryLevel(), vacuum.property("state"));
|
|
76
|
+
const rooms = roomNames(await vacuum.getRoomMap(), home.rooms); // [{ segmentId: 1, roomId, name: "Kitchen" }, …]
|
|
77
|
+
await vacuum.cleanRooms([rooms[0].segmentId]);
|
|
78
|
+
|
|
79
|
+
// The map (over MQTT): the same `RoborockMap` as `parseRoborockMap` (rooms, robot position, current room…)
|
|
80
|
+
const map = await roborockApiOf(vacuum)?.getMap();
|
|
81
|
+
await vacuum.destroy();
|
|
82
|
+
await mqtt.close();
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The robot's status pushes (over both connections) refresh the device's properties, so `stateChanged` events come
|
|
86
|
+
without waiting for the next poll.
|
|
87
|
+
|
|
88
|
+
## Credits
|
|
89
|
+
|
|
90
|
+
The account endpoints, the message format (`1.0` and `L01`), the MQTT topics and the map responses follow [python-roborock](https://github.com/Python-roborock/python-roborock) (Apache-2.0),
|
|
91
|
+
which documents Roborock's API. No code is copied from it.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-miio",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Control Mi Home devices, such as Mi Robot Vacuums, Mi Air Purifiers, Mi Smart Home Gateway (Aqara) and more",
|
|
6
6
|
"author": "https://github.com/afharo",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"chalk": "^4.1.2",
|
|
51
51
|
"debug": "^4.4.3",
|
|
52
52
|
"deep-equal": "^2.2.3",
|
|
53
|
+
"mqtt": "^5.16.1",
|
|
53
54
|
"node-persist": "^4.0.4",
|
|
54
55
|
"tinkerhub-discovery": "^0.6.0",
|
|
55
56
|
"uqr": "^0.1.3",
|
|
Binary file
|
package/.claude/settings.json
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: release
|
|
3
|
-
description: Prepare and publish a new version of node-miio (version bump on main, GitHub release with generated notes, which publishes to npm with a fresh MIoT spec snapshot). Use when asked to release, cut, or prepare a new version (patch, minor, major or a beta).
|
|
4
|
-
argument-hint: "[patch|minor|major|prerelease|preminor --preid beta]"
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Release a new version
|
|
8
|
-
|
|
9
|
-
Argument: the `npm version` level: `patch`, `minor`, `major`, or a beta (`preminor --preid beta` for the first beta of
|
|
10
|
-
the next minor, `prerelease` for the next beta). If it's missing, propose one from the PRs merged since the last tag
|
|
11
|
-
(`git log v$PREV..main --oneline`: new features → `minor`, only fixes → `patch`; betas while a feature set is being
|
|
12
|
-
tested by users) and ask before going on.
|
|
13
|
-
|
|
14
|
-
There's no CHANGELOG: the release notes are generated from the PR labels (`.github/release.yml`). Before releasing,
|
|
15
|
-
check that every PR merged since the last tag has a label (`enhancement`, `bug`, `dependencies`, `documentation`…),
|
|
16
|
-
or it lands in "Other Changes".
|
|
17
|
-
|
|
18
|
-
## Before starting
|
|
19
|
-
|
|
20
|
-
- Start from an up-to-date, clean `main`: `git checkout main && git pull --ff-only`, `git status` clean.
|
|
21
|
-
- Work out:
|
|
22
|
-
- `PREV`: the current version in `package.json`.
|
|
23
|
-
- `NEXT`: the version after applying the level to `PREV`.
|
|
24
|
-
- `DATE`: today, as `YYYY-MM-DD`.
|
|
25
|
-
- `START`: the tag the release notes start from. For a beta: the previous tag (`v$PREV`). For a stable release: the
|
|
26
|
-
previous **stable** tag (e.g. `v0.3.0` for `0.4.0`), so the notes cover all the betas.
|
|
27
|
-
|
|
28
|
-
## 1. Version bump (directly on `main`)
|
|
29
|
-
|
|
30
|
-
```sh
|
|
31
|
-
npm version <level>
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
- `preversion` runs lint, build and tests. If they fail, fix that first (in a PR): don't skip them.
|
|
35
|
-
- It creates the `$NEXT` commit and the `v$NEXT` tag on `main`, and `postversion` pushes both.
|
|
36
|
-
|
|
37
|
-
## 2. GitHub release (publishes to npm)
|
|
38
|
-
|
|
39
|
-
Creating the release triggers `.github/workflows/publish-release-to-npm.yml` (on `release: created`, so **never create
|
|
40
|
-
a draft**: it would publish too). The workflow checks the tag matches `package.json`, lints, tests, builds, refreshes
|
|
41
|
-
the bundled MIoT spec snapshot (`npm run snapshot`) and publishes with npm Trusted Publishing. Betas go to the `beta`
|
|
42
|
-
dist-tag, stable releases to `latest`.
|
|
43
|
-
|
|
44
|
-
```sh
|
|
45
|
-
gh release create v$NEXT --title "v$NEXT - $DATE" --generate-notes --notes-start-tag $START --verify-tag
|
|
46
|
-
# betas: add --prerelease
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
Check the notes: `gh release view v$NEXT` should list only the PRs merged since `$START`.
|
|
50
|
-
|
|
51
|
-
## 3. Check the publish
|
|
52
|
-
|
|
53
|
-
```sh
|
|
54
|
-
gh run list --repo afharo/node-miio --workflow publish-release-to-npm.yml --limit 1
|
|
55
|
-
gh run watch <id> --repo afharo/node-miio --exit-status
|
|
56
|
-
npm view node-miio dist-tags
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
If it fails, report it: don't publish by hand without asking. Once a version is on npm, the plugins'
|
|
60
|
-
Renovate (no cooldown for node-miio) opens their update PRs.
|
|
61
|
-
|
|
62
|
-
## Ask the testers / tell the reporters
|
|
63
|
-
|
|
64
|
-
Once the version is on npm:
|
|
65
|
-
|
|
66
|
-
- **Beta**: comment on the beta testers issue (#18) mentioning the testers whose model or dock matches the
|
|
67
|
-
changes. Give them a short test list (2–3 items: "turn on X, check that Y happens") and ask for ✅ / ❌ per item, with
|
|
68
|
-
debug logs for ❌. Also comment on the issues the beta addresses, asking the reporters to try it. node-miio betas usually come from a plugin issue: also mention the matching testers in the plugins' issues (homebridge #1232, matterbridge #387).
|
|
69
|
-
- **Release**: comment on every issue it addresses: the version, how to enable/use it, and "if it doesn't work, comment
|
|
70
|
-
here and we'll reopen it" (reporters can't reopen issues closed by a maintainer or a PR). Keep them closed: don't
|
|
71
|
-
leave issues open waiting for feedback that may never come.
|
|
72
|
-
|
|
73
|
-
Report the release and npm links to the user.
|