homebridge-roborock-matter 2.1.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/.gitattributes +13 -0
- package/CHANGELOG.md +469 -0
- package/LICENSE +23 -0
- package/README.md +45 -0
- package/__tests__/testdata/b01_q7_get_prop_response.json +1 -0
- package/__tests__/testdata/b01_q7_map_fixture.json +16 -0
- package/config.schema.json +118 -0
- package/dist/crypto.js +65 -0
- package/dist/crypto.js.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/live_message.js +25 -0
- package/dist/live_message.js.map +1 -0
- package/dist/logger.js +37 -0
- package/dist/logger.js.map +1 -0
- package/dist/matter_vacuum_accessory.js +1877 -0
- package/dist/matter_vacuum_accessory.js.map +1 -0
- package/dist/platform.js +441 -0
- package/dist/platform.js.map +1 -0
- package/dist/settings.js +8 -0
- package/dist/settings.js.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/index.js +741 -0
- package/dist/ui/index.js.map +1 -0
- package/docs/matter-rvc-updating-homebridge-report.md +120 -0
- package/homebridge-roborock-vacuum.code-workspace +7 -0
- package/homebridge-ui/public/index.html +257 -0
- package/homebridge-ui/public/index.js +1276 -0
- package/homebridge-ui/public/styles.css +611 -0
- package/homebridge-ui/server.js +3 -0
- package/package.json +91 -0
- package/roborockLib/i18n/de/translations.json +188 -0
- package/roborockLib/i18n/en/translations.json +208 -0
- package/roborockLib/i18n/es/translations.json +188 -0
- package/roborockLib/i18n/fr/translations.json +188 -0
- package/roborockLib/i18n/it/translations.json +188 -0
- package/roborockLib/i18n/nl/translations.json +188 -0
- package/roborockLib/i18n/pl/translations.json +188 -0
- package/roborockLib/i18n/pt/translations.json +188 -0
- package/roborockLib/i18n/ru/translations.json +188 -0
- package/roborockLib/i18n/uk/translations.json +188 -0
- package/roborockLib/i18n/zh-cn/translations.json +188 -0
- package/roborockLib/lib/RRMapParser.js +459 -0
- package/roborockLib/lib/b01Q7Adapter.js +468 -0
- package/roborockLib/lib/deviceFeatures.js +1349 -0
- package/roborockLib/lib/localConnector.js +629 -0
- package/roborockLib/lib/map/map.html +137 -0
- package/roborockLib/lib/map/zones.js +851 -0
- package/roborockLib/lib/message.js +402 -0
- package/roborockLib/lib/messageQueueHandler.js +411 -0
- package/roborockLib/lib/roborockAuth.js +178 -0
- package/roborockLib/lib/roborockCrypto.js +55 -0
- package/roborockLib/lib/roborockPackageHelper.js +142 -0
- package/roborockLib/lib/roborock_mqtt_connector.js +567 -0
- package/roborockLib/lib/sniffing/mitmproxy_roborock.py +300 -0
- package/roborockLib/lib/vacuum.js +992 -0
- package/roborockLib/roborockAPI.js +3635 -0
- package/tsconfig.roborockLib.json +17 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pluginAlias": "RoborockVacuumPlatform",
|
|
3
|
+
"pluginType": "platform",
|
|
4
|
+
"singular": true,
|
|
5
|
+
"customUi": true,
|
|
6
|
+
"customUiPath": "./homebridge-ui",
|
|
7
|
+
"schema": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"email": {
|
|
11
|
+
"title": "Email",
|
|
12
|
+
"type": "string",
|
|
13
|
+
"format": "email",
|
|
14
|
+
"description": "Email address for the Roborock account that owns or has access to the vacuum."
|
|
15
|
+
},
|
|
16
|
+
"password": {
|
|
17
|
+
"title": "Password",
|
|
18
|
+
"type": "string",
|
|
19
|
+
"format": "password",
|
|
20
|
+
"placeholder": "Password",
|
|
21
|
+
"description": "Roborock account password. Used for password login or as a fallback when no encrypted token is available."
|
|
22
|
+
},
|
|
23
|
+
"encryptedToken": {
|
|
24
|
+
"title": "Encrypted Token",
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "Encrypted Roborock session data. This is created and managed by the plugin UI after a successful login.",
|
|
27
|
+
"readOnly": true
|
|
28
|
+
},
|
|
29
|
+
"skipDevices": {
|
|
30
|
+
"title": "Skip Devices",
|
|
31
|
+
"type": "string",
|
|
32
|
+
"description": "Comma-separated Roborock serial numbers or DUIDs to ignore during discovery."
|
|
33
|
+
},
|
|
34
|
+
"baseURL": {
|
|
35
|
+
"title": "Region",
|
|
36
|
+
"type": "string",
|
|
37
|
+
"default": "https://usiot.roborock.com",
|
|
38
|
+
"enum": [
|
|
39
|
+
"https://usiot.roborock.com",
|
|
40
|
+
"https://euiot.roborock.com",
|
|
41
|
+
"https://cniot.roborock.com",
|
|
42
|
+
"https://api.roborock.com"
|
|
43
|
+
],
|
|
44
|
+
"enumNames": [
|
|
45
|
+
"US (usiot.roborock.com)",
|
|
46
|
+
"EU (euiot.roborock.com)",
|
|
47
|
+
"CN (cniot.roborock.com)",
|
|
48
|
+
"Asia (api.roborock.com)"
|
|
49
|
+
],
|
|
50
|
+
"description": "Roborock cloud region endpoint. Choose the region used by your Roborock account."
|
|
51
|
+
},
|
|
52
|
+
"debugMode": {
|
|
53
|
+
"title": "Debug Mode",
|
|
54
|
+
"description": "Write verbose Roborock API, discovery, and transport diagnostics to the Homebridge log.",
|
|
55
|
+
"type": "boolean",
|
|
56
|
+
"default": false
|
|
57
|
+
},
|
|
58
|
+
"transientWarningThrottleHours": {
|
|
59
|
+
"title": "Transient Warning Interval",
|
|
60
|
+
"description": "Hours between repeated transient timeout warnings for each vacuum. Use 0 to hide these recurring warnings unless debug logging is enabled.",
|
|
61
|
+
"type": "number",
|
|
62
|
+
"default": 6,
|
|
63
|
+
"minimum": 0
|
|
64
|
+
},
|
|
65
|
+
"enableMatterServiceArea": {
|
|
66
|
+
"title": "Enable Matter Room/Map Selection",
|
|
67
|
+
"description": "Adds Matter Service Area room and map selection to the Matter vacuum for clients that support it. Disable this if a Matter controller gets stuck showing the vacuum as Updating.",
|
|
68
|
+
"type": "boolean",
|
|
69
|
+
"default": true
|
|
70
|
+
},
|
|
71
|
+
"enableMatterPowerSource": {
|
|
72
|
+
"title": "Enable Matter Battery",
|
|
73
|
+
"description": "Adds the Matter battery/power-source cluster to the Matter vacuum. Disable this if a Matter controller gets stuck showing the vacuum as Updating.",
|
|
74
|
+
"type": "boolean",
|
|
75
|
+
"default": true
|
|
76
|
+
},
|
|
77
|
+
"enableMatterCleanMode": {
|
|
78
|
+
"title": "Enable Matter Cleaning Mode Selection",
|
|
79
|
+
"description": "Adds Matter vacuum/mop cleaning mode selection to the Matter vacuum. Disable this if a Matter controller shows the vacuum as No Response after pairing.",
|
|
80
|
+
"type": "boolean",
|
|
81
|
+
"default": true
|
|
82
|
+
},
|
|
83
|
+
"enableMatterExtendedOperationalStates": {
|
|
84
|
+
"title": "Enable Matter Returning Status",
|
|
85
|
+
"description": "Opt in to the extended Matter Returning status while the vacuum is heading back to the dock. Unless Charging/Docked status is also enabled below, docked and charging still report as Ready for Apple Home compatibility.",
|
|
86
|
+
"type": "boolean",
|
|
87
|
+
"default": false
|
|
88
|
+
},
|
|
89
|
+
"enableMatterChargingDockedStates": {
|
|
90
|
+
"title": "Enable Matter Charging/Docked Status",
|
|
91
|
+
"description": "Report real Charging and Docked states so the Apple Home tile shows Charging/Docked instead of Ready. Requires a recent iOS/tvOS; if the tile shows odd status text or pairing misbehaves after enabling, turn this off again and restart the Roborock bridge.",
|
|
92
|
+
"type": "boolean",
|
|
93
|
+
"default": false
|
|
94
|
+
},
|
|
95
|
+
"matterChargedBatteryThreshold": {
|
|
96
|
+
"title": "Charged Battery Threshold (%)",
|
|
97
|
+
"description": "Battery percentage at which a docked robot switches from Charging to Docked on the Apple Home tile. Default 100. Lower it (e.g. 90) if a worn battery makes the robot report fully charged early.",
|
|
98
|
+
"type": "number",
|
|
99
|
+
"minimum": 1,
|
|
100
|
+
"maximum": 100,
|
|
101
|
+
"default": 100
|
|
102
|
+
},
|
|
103
|
+
"cloudOnlyMode": {
|
|
104
|
+
"title": "Use Roborock Cloud Only",
|
|
105
|
+
"description": "Disables local LAN discovery and local TCP commands for this plugin, routing commands and status polling through Roborock cloud when available. Useful when local LAN connections appear connected but consistently time out. Restart the Roborock child bridge after changing this setting.",
|
|
106
|
+
"type": "boolean",
|
|
107
|
+
"default": false
|
|
108
|
+
},
|
|
109
|
+
"preferCloudForMatterCommands": {
|
|
110
|
+
"title": "Prefer Roborock Cloud for Matter Commands",
|
|
111
|
+
"description": "Sends Matter vacuum commands through the Roborock cloud when cloud transport is connected. This can avoid local LAN command timeouts on some models, such as S8, while keeping the legacy HomeKit accessories unchanged.",
|
|
112
|
+
"type": "boolean",
|
|
113
|
+
"default": false
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"required": ["email"]
|
|
117
|
+
}
|
|
118
|
+
}
|
package/dist/crypto.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
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.encryptSession = encryptSession;
|
|
7
|
+
exports.decryptSession = decryptSession;
|
|
8
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const KEY_FILENAME = "roborock.token.key";
|
|
12
|
+
function loadOrCreateKey(storagePath) {
|
|
13
|
+
const keyPath = path_1.default.join(storagePath, KEY_FILENAME);
|
|
14
|
+
try {
|
|
15
|
+
const existing = fs_1.default.readFileSync(keyPath);
|
|
16
|
+
if (existing.length === 32) {
|
|
17
|
+
return existing;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
// Ignore and create a new key.
|
|
22
|
+
}
|
|
23
|
+
const key = crypto_1.default.randomBytes(32);
|
|
24
|
+
fs_1.default.mkdirSync(storagePath, { recursive: true });
|
|
25
|
+
fs_1.default.writeFileSync(keyPath, key, { mode: 0o600 });
|
|
26
|
+
return key;
|
|
27
|
+
}
|
|
28
|
+
function encryptSession(session, storagePath) {
|
|
29
|
+
const key = loadOrCreateKey(storagePath);
|
|
30
|
+
const iv = crypto_1.default.randomBytes(12);
|
|
31
|
+
const cipher = crypto_1.default.createCipheriv("aes-256-gcm", key, iv);
|
|
32
|
+
const plaintext = Buffer.from(JSON.stringify(session), "utf8");
|
|
33
|
+
const ciphertext = Buffer.concat([cipher.update(plaintext), cipher.final()]);
|
|
34
|
+
const tag = cipher.getAuthTag();
|
|
35
|
+
const payload = {
|
|
36
|
+
iv: iv.toString("base64"),
|
|
37
|
+
tag: tag.toString("base64"),
|
|
38
|
+
data: ciphertext.toString("base64"),
|
|
39
|
+
};
|
|
40
|
+
return Buffer.from(JSON.stringify(payload), "utf8").toString("base64");
|
|
41
|
+
}
|
|
42
|
+
function decryptSession(encrypted, storagePath) {
|
|
43
|
+
if (!encrypted) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const key = loadOrCreateKey(storagePath);
|
|
48
|
+
const raw = Buffer.from(encrypted, "base64").toString("utf8");
|
|
49
|
+
const payload = JSON.parse(raw);
|
|
50
|
+
const iv = Buffer.from(payload.iv, "base64");
|
|
51
|
+
const tag = Buffer.from(payload.tag, "base64");
|
|
52
|
+
const ciphertext = Buffer.from(payload.data, "base64");
|
|
53
|
+
const decipher = crypto_1.default.createDecipheriv("aes-256-gcm", key, iv);
|
|
54
|
+
decipher.setAuthTag(tag);
|
|
55
|
+
const plaintext = Buffer.concat([
|
|
56
|
+
decipher.update(ciphertext),
|
|
57
|
+
decipher.final(),
|
|
58
|
+
]).toString("utf8");
|
|
59
|
+
return JSON.parse(plaintext);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=crypto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../src/crypto.ts"],"names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AAC;QAEzB,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC;YAC9B,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC;YAC3B,QAAQ,CAAC,KAAK,EAAE;SACjB,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAA4B,CAAC;IAC1D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const platform_1 = __importDefault(require("./platform"));
|
|
6
|
+
const settings_1 = require("./settings");
|
|
7
|
+
module.exports = (api) => {
|
|
8
|
+
api.registerPlatform(settings_1.PLATFORM_NAME, platform_1.default);
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AACA,0DAA0C;AAC1C,yCAA2C;AAK3C,iBAAS,CAAC,GAAQ,EAAE,EAAE;IACpB,GAAG,CAAC,gBAAgB,CAAC,wBAAa,EAAE,kBAAgB,CAAC,CAAC;AACxD,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLiveMessageForThisAccessory = getLiveMessageForThisAccessory;
|
|
4
|
+
function getLiveMessageForThisAccessory(data, context) {
|
|
5
|
+
if (!data || typeof data !== "object") {
|
|
6
|
+
return data;
|
|
7
|
+
}
|
|
8
|
+
if (Array.isArray(data)) {
|
|
9
|
+
if (!context.shouldAcceptUnscopedLiveMessage()) {
|
|
10
|
+
context.logDebug(`Ignoring unscoped live Roborock update for ${context.getVacuumName()} because multiple vacuums are configured.`);
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
const message = data;
|
|
16
|
+
if (Object.prototype.hasOwnProperty.call(message, "duid") &&
|
|
17
|
+
Object.prototype.hasOwnProperty.call(message, "payload")) {
|
|
18
|
+
if (String(message.duid) !== context.getDuid()) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return message.payload;
|
|
22
|
+
}
|
|
23
|
+
return data;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=live_message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live_message.js","sourceRoot":"","sources":["../src/live_message.ts"],"names":[],"mappings":";;AAoBA,wEAgCC;AAhCD,SAAgB,8BAA8B,CAC5C,IAAa,EACb,OAAoC;IAEpC,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,+BAA+B,EAAE,EAAE,CAAC;YAC/C,OAAO,CAAC,QAAQ,CACd,8CAA8C,OAAO,CAAC,aAAa,EAAE,2CAA2C,CACjH,CAAC;YACF,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,OAAO,GAAG,IAA+B,CAAC;IAChD,IACE,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC;QACrD,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,EACxD,CAAC;QACD,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;YAC/C,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,OAAO,CAAC,OAAO,CAAC;IACzB,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Decorates the Homebridge logger to only log debug messages when debug mode is enabled.
|
|
5
|
+
*/
|
|
6
|
+
class RoborockPlatformLogger {
|
|
7
|
+
constructor(logger, debugMode) {
|
|
8
|
+
this.logger = logger;
|
|
9
|
+
this.debugMode = debugMode;
|
|
10
|
+
}
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
emit(fn, messages) {
|
|
13
|
+
for (let i = 0; i < messages.length; i++) {
|
|
14
|
+
fn(messages[i]);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
debug(...messages) {
|
|
19
|
+
if (this.debugMode) {
|
|
20
|
+
this.emit((message) => this.logger.debug(message), messages);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
info(...messages) {
|
|
25
|
+
this.emit((message) => this.logger.info(message), messages);
|
|
26
|
+
}
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
+
warn(...messages) {
|
|
29
|
+
this.emit((message) => this.logger.warn(message), messages);
|
|
30
|
+
}
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
|
+
error(...messages) {
|
|
33
|
+
this.emit((message) => this.logger.error(message), messages);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.default = RoborockPlatformLogger;
|
|
37
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0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