homebridge-roborock-vacuum 0.1.1 → 0.1.3

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.
@@ -11,6 +11,7 @@
11
11
  },
12
12
  "password": {
13
13
  "type": "string",
14
+ "placeholder": "Password",
14
15
  "description": "Roborock account password"
15
16
  },
16
17
  "baseURL": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homebridge-roborock-vacuum",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Roborock Vacuum Cleaner - plugin for Homebridge.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -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\":\"cPt6Ps\",\"h\":\"Gm0QssB0Qa\",\"k\":\"R3Z3cNUh\",\"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\"}",
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`;
@@ -443,8 +443,6 @@ class Roborock {
443
443
 
444
444
  await this.vacuums[duid].getCleanSummary(duid);
445
445
 
446
- // get map once at start of adapter
447
- await this.vacuums[duid].getMap(duid);
448
446
  }
449
447
  }
450
448
 
@@ -522,28 +520,6 @@ class Roborock {
522
520
  }
523
521
  }
524
522
 
525
- async startMapUpdater(duid) {
526
- if (!this.vacuums[duid].mapUpdater) {
527
- this.log.debug(`Started map updater on robot: ${duid}`);
528
- this.vacuums[duid].mapUpdater = this.setInterval(() => {
529
- this.vacuums[duid].getMap(duid);
530
- }, this.config.map_creation_interval * 1000);
531
- } else {
532
- this.log.debug(`Map updater on robot: ${duid} already running!`);
533
- }
534
- }
535
-
536
- async stopMapUpdater(duid) {
537
- this.log.debug(`Stopping map updater on robot: ${duid}`);
538
-
539
- if (this.vacuums[duid].mapUpdater) {
540
- this.clearInterval(this.vacuums[duid].mapUpdater);
541
- this.vacuums[duid].mapUpdater = null;
542
-
543
- await this.vacuums[duid].getCleanSummary(duid);
544
- }
545
- }
546
-
547
523
  getProductAttribute(duid, attribute) {
548
524
  const products = this.products;
549
525
  const productID = this.devices.find((device) => device.duid == duid).productId;
@@ -642,7 +618,6 @@ class Roborock {
642
618
  if (!onlineState && this.vacuums[duid].mainUpdateInterval) {
643
619
  this.clearInterval(this.vacuums[duid].getStatusIntervall);
644
620
  this.clearInterval(this.vacuums[duid].mainUpdateInterval);
645
- this.clearInterval(this.vacuums[duid].mapUpdater);
646
621
  } else if (!this.vacuums[duid].mainUpdateInterval) {
647
622
  this.vacuums[duid].getStatusIntervall();
648
623
  this.startMainUpdateInterval(duid, onlineState);
@@ -722,7 +697,6 @@ class Roborock {
722
697
  for (const duid in this.vacuums) {
723
698
  this.clearInterval(this.vacuums[duid].getStatusIntervall);
724
699
  this.clearInterval(this.vacuums[duid].mainUpdateInterval);
725
- this.clearInterval(this.vacuums[duid].mapUpdater);
726
700
  }
727
701
 
728
702
  this.messageQueue.forEach(({ timeout102, timeout301 }) => {
@@ -1110,10 +1084,6 @@ class Roborock {
1110
1084
  this.vacuums[duid].command(duid, command, parameters);
1111
1085
  break;
1112
1086
 
1113
- case "getMap":
1114
- this.vacuums[duid].getMap(duid);
1115
- break;
1116
-
1117
1087
  case "get_photo":
1118
1088
  this.vacuums[duid].getParameter(duid, "get_photo", parameters);
1119
1089
  break;