homebridge-roborock-vacuum 0.1.1 → 0.1.2
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/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"val": "{\"uid\":1466357,\"tokentype\":\"\",\"token\":\"d8fe0bd712334ee585bc2145140f07d1-1JZxT5AINkUhb5JDyL8S+w==\",\"rruid\":\"rr6238c899155830\",\"region\":\"us\",\"countrycode\":\"886\",\"country\":\"TW\",\"nickname\":\"tasict\",\"rriot\":{\"u\":\"1RQsQJ2o8bxMCo6F45pICu\",\"s\":\"
|
|
2
|
+
"val": "{\"uid\":1466357,\"tokentype\":\"\",\"token\":\"d8fe0bd712334ee585bc2145140f07d1-1JZxT5AINkUhb5JDyL8S+w==\",\"rruid\":\"rr6238c899155830\",\"region\":\"us\",\"countrycode\":\"886\",\"country\":\"TW\",\"nickname\":\"tasict\",\"rriot\":{\"u\":\"1RQsQJ2o8bxMCo6F45pICu\",\"s\":\"l5UDP7\",\"h\":\"7h2O8mNvkt\",\"k\":\"kxF1J95i\",\"r\":{\"r\":\"US\",\"a\":\"https://api-us.roborock.com\",\"m\":\"ssl://mqtt-us.roborock.com:8883\",\"l\":\"https://wood-us.roborock.com\"}},\"tuyaDeviceState\":0,\"avatarurl\":\"https://files.roborock.com/iottest/default_avatar.png\"}",
|
|
3
3
|
"ack": true
|
|
4
4
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const rrMessage = require("./message").message;
|
|
4
4
|
const RRMapParser = require("./RRMapParser");
|
|
5
|
-
const MapCreator = require("./mapCreator");
|
|
6
5
|
const fs = require("fs");
|
|
7
6
|
const zlib = require("zlib");
|
|
8
7
|
|
|
@@ -36,7 +35,6 @@ class vacuum {
|
|
|
36
35
|
this.message = new rrMessage(this.adapter);
|
|
37
36
|
|
|
38
37
|
this.mapParser = new RRMapParser(this.adapter);
|
|
39
|
-
this.mapCreator = new MapCreator(this.adapter);
|
|
40
38
|
|
|
41
39
|
this.parameterFolders = {
|
|
42
40
|
get_mop_mode: "deviceStatus",
|
|
@@ -50,94 +48,10 @@ class vacuum {
|
|
|
50
48
|
};
|
|
51
49
|
}
|
|
52
50
|
|
|
53
|
-
async getMap(duid) {
|
|
54
|
-
if (this.adapter.config.enable_map_creation) {
|
|
55
|
-
this.adapter.log.debug(`Update map`);
|
|
56
|
-
|
|
57
|
-
try {
|
|
58
|
-
// const map = await connector.sendRequest(duid, "get_map_v1", [], true);
|
|
59
|
-
// const map = await this.adapter.rr_mqtt_connector.sendRequest(duid, "get_map_v1", [], true);
|
|
60
|
-
const map = await this.adapter.messageQueueHandler.sendRequest(duid, "get_map_v1", [], true);
|
|
61
|
-
// this.adapter.log.debug(`Map received: ${map}`);
|
|
62
|
-
if (map != "retry") {
|
|
63
|
-
const mappedRooms = await this.adapter.messageQueueHandler.sendRequest(duid, "get_room_mapping", []);
|
|
64
|
-
|
|
65
|
-
// const deviceStatus = await this.adapter.messageQueueHandler.sendRequest(duid, "get_status", []);
|
|
66
|
-
const deviceStatus = await this.adapter.messageQueueHandler.sendRequest(duid, "get_prop", ["get_status"]);
|
|
67
|
-
const selectedMap = deviceStatus[0].map_status >> 2 ?? -1; // to get the currently selected map perform bitwise right shift
|
|
68
|
-
|
|
69
|
-
// This is for testing and debugging maps. This can't be stored in a state.
|
|
70
|
-
zlib.gzip(map, (error, buffer) => {
|
|
71
|
-
if (error) {
|
|
72
|
-
this.adapter.log.error(`Error compressing map to gz ${error}`);
|
|
73
|
-
} else {
|
|
74
|
-
fs.writeFile("./test.rrmap.gz", buffer, (error) => {
|
|
75
|
-
if (error) {
|
|
76
|
-
this.adapter.log.error(`Error writing map file ${error}`);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
const parsedData = await this.mapParser.parsedata(map);
|
|
83
|
-
|
|
84
|
-
const [mapBase64, mapBase64Truncated] = this.mapCreator.canvasMap(parsedData, duid, selectedMap, mappedRooms);
|
|
85
|
-
|
|
86
|
-
await this.adapter.setStateAsync(`Devices.${duid}.map.mapData`, { val: JSON.stringify(parsedData), ack: true });
|
|
87
|
-
await this.adapter.setStateAsync(`Devices.${duid}.map.mapBase64`, { val: mapBase64, ack: true });
|
|
88
|
-
await this.adapter.setStateAsync(`Devices.${duid}.map.mapBase64Truncated`, { val: mapBase64Truncated, ack: true });
|
|
89
|
-
|
|
90
|
-
// Send current map with Scale factor
|
|
91
|
-
const mapToSend = {
|
|
92
|
-
duid: duid,
|
|
93
|
-
command: "map",
|
|
94
|
-
base64: mapBase64,
|
|
95
|
-
map: parsedData,
|
|
96
|
-
scale: this.adapter.config.map_scale,
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
if (this.adapter.socket != null) {
|
|
100
|
-
this.adapter.socket.send(JSON.stringify(mapToSend));
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
} catch (error) {
|
|
104
|
-
this.adapter.catchError(error, "get_map_v1", duid), this.robotModel;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
async getCleaningRecordMap(duid, startTime) {
|
|
110
|
-
try {
|
|
111
|
-
const cleaningRecordMap = await this.adapter.messageQueueHandler.sendRequest(duid, "get_clean_record_map", { start_time: startTime }, true);
|
|
112
|
-
const parsedData = await this.mapParser.parsedata(cleaningRecordMap);
|
|
113
|
-
const [mapBase64, mapBase64Truncated] = this.mapCreator.canvasMap(parsedData, duid);
|
|
114
|
-
|
|
115
|
-
return {
|
|
116
|
-
mapBase64: mapBase64,
|
|
117
|
-
mapBase64Truncated: mapBase64Truncated,
|
|
118
|
-
mapData: JSON.stringify(parsedData),
|
|
119
|
-
};
|
|
120
|
-
} catch (error) {
|
|
121
|
-
this.adapter.catchError(error, "get_clean_record_map", duid, this.robotModel);
|
|
122
|
-
|
|
123
|
-
return null;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
51
|
|
|
127
52
|
async command(duid, parameter, value) {
|
|
128
53
|
try {
|
|
129
54
|
switch (parameter) {
|
|
130
|
-
case "load_multi_map": {
|
|
131
|
-
const result = await this.adapter.messageQueueHandler.sendRequest(duid, "load_multi_map", value);
|
|
132
|
-
|
|
133
|
-
if (result[0] == "ok") {
|
|
134
|
-
await this.getMap(duid).then(async () => {
|
|
135
|
-
await this.getParameter(duid, "get_room_mapping");
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
55
|
case "app_segment_clean": {
|
|
142
56
|
this.adapter.log.debug("Start room cleaning");
|
|
143
57
|
|
|
@@ -304,7 +218,6 @@ class vacuum {
|
|
|
304
218
|
|
|
305
219
|
if (mapFromCommand && mapFromCommand.val != currentMap) {
|
|
306
220
|
await this.adapter.setStateAsync(`Devices.${duid}.commands.load_multi_map`, currentMap, true);
|
|
307
|
-
await this.adapter.vacuums[duid].getMap(duid);
|
|
308
221
|
}
|
|
309
222
|
}
|
|
310
223
|
}
|
|
@@ -549,13 +462,6 @@ class vacuum {
|
|
|
549
462
|
});
|
|
550
463
|
}
|
|
551
464
|
|
|
552
|
-
if (this.adapter.config.enable_map_creation == true) {
|
|
553
|
-
const mapArray = await this.getCleaningRecordMap(duid, cleaningAttributes[cleaningAttribute][cleaningRecord]);
|
|
554
|
-
for (const mapType in mapArray) {
|
|
555
|
-
const val = mapArray[mapType];
|
|
556
|
-
this.adapter.setStateAsync(`Devices.${duid}.cleaningInfo.records.${cleaningRecord}.map.${mapType}`, { val: val, ack: true });
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
465
|
}
|
|
560
466
|
|
|
561
467
|
const objectString = `Devices.${duid}.cleaningInfo.JSON`;
|