iobroker.idm-multitalent_002 1.2.2 → 1.2.4
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 +6 -0
- package/io-package.json +7 -1
- package/lib/idm-protocol.js +14 -6
- package/lib/idm_datablocks.js +6 -0
- package/main.js +57 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -48,6 +48,12 @@ Settings of the serial adapter:
|
|
|
48
48
|
```
|
|
49
49
|
|
|
50
50
|
## Changelog
|
|
51
|
+
### 1.2.4 (2024-01-21)
|
|
52
|
+
* (zloe) further improve logging and handling of transmission errors
|
|
53
|
+
|
|
54
|
+
### 1.2.3 (2024-01-21)
|
|
55
|
+
* (zloe) improve handling of data transmission problems
|
|
56
|
+
|
|
51
57
|
### 1.2.2 (2024-01-21)
|
|
52
58
|
* (zloe) fix handling of data transmission problems which lead to stopping requesting data
|
|
53
59
|
|
package/io-package.json
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"name": "idm-multitalent_002",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.4",
|
|
5
5
|
"news": {
|
|
6
|
+
"1.2.4": {
|
|
7
|
+
"en": "* improve logging and handling of data transmission problems\n\n## License\nMIT License\n\nCopyright (c) 2024 zloe <klaus@zloebl.net>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE."
|
|
8
|
+
},
|
|
9
|
+
"1.2.3": {
|
|
10
|
+
"en": "* improve handling of data transmission problems\n\n## License\nMIT License\n\nCopyright (c) 2024 zloe <klaus@zloebl.net>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE."
|
|
11
|
+
},
|
|
6
12
|
"1.2.2": {
|
|
7
13
|
"en": "* fix handling of data transmission problems which lead to stopping requesting data\n\n## License\nMIT License\n\nCopyright (c) 2024 zloe <klaus@zloebl.net>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE."
|
|
8
14
|
},
|
package/lib/idm-protocol.js
CHANGED
|
@@ -7,6 +7,7 @@ const idm_protocol = {
|
|
|
7
7
|
dataDefinitions: new Map(),
|
|
8
8
|
sensorDataBlocks: new Map(),
|
|
9
9
|
settingsDataBlocks: new Map(),
|
|
10
|
+
speed: new Map(),
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
initialize: function () {
|
|
@@ -14,31 +15,37 @@ const idm_protocol = {
|
|
|
14
15
|
idm_protocol.dataBlocks.set('idm701100', idm_datablocks.idm701100);
|
|
15
16
|
idm_protocol.sensorDataBlocks.set('idm701100', idm_datablocks.idm701100_sensors);
|
|
16
17
|
idm_protocol.settingsDataBlocks.set('idm701100', idm_datablocks.idm701100_settings);
|
|
18
|
+
idm_protocol.speed.set('idm701100', idm_datablocks.idm701100_speed);
|
|
17
19
|
|
|
18
20
|
idm_protocol.dataDefinitions.set('idm712100', idm_datablocks.idm712100_data);
|
|
19
21
|
idm_protocol.dataBlocks.set('idm712100', idm_datablocks.idm712100);
|
|
20
22
|
idm_protocol.sensorDataBlocks.set('idm712100', idm_datablocks.idm712100_sensors);
|
|
21
23
|
idm_protocol.settingsDataBlocks.set('idm712100', idm_datablocks.idm712100_settings);
|
|
24
|
+
idm_protocol.speed.set('idm712100', idm_datablocks.idm712100_speed);
|
|
22
25
|
|
|
23
26
|
idm_protocol.dataDefinitions.set('idm722100', idm_datablocks.idm722100_data);
|
|
24
27
|
idm_protocol.dataBlocks.set('idm722100', idm_datablocks.idm722100);
|
|
25
28
|
idm_protocol.sensorDataBlocks.set('idm722100', idm_datablocks.idm722100_sensors);
|
|
26
29
|
idm_protocol.settingsDataBlocks.set('idm722100', idm_datablocks.idm722100_settings);
|
|
30
|
+
idm_protocol.speed.set('idm722100', idm_datablocks.idm722100_speed);
|
|
27
31
|
|
|
28
32
|
idm_protocol.dataDefinitions.set('S_H726100', idm_datablocks.S_H726100_data);
|
|
29
33
|
idm_protocol.dataBlocks.set('S_H726100', idm_datablocks.S_H726100);
|
|
30
34
|
idm_protocol.sensorDataBlocks.set('S_H726100', idm_datablocks.S_H726100_sensors);
|
|
31
35
|
idm_protocol.settingsDataBlocks.set('S_H726100', idm_datablocks.S_H726100_settings);
|
|
36
|
+
idm_protocol.speed.set('S_H726100', idm_datablocks.S_H726100_speed);
|
|
32
37
|
|
|
33
38
|
idm_protocol.dataDefinitions.set('idm750100', idm_datablocks.idm750100_data);
|
|
34
39
|
idm_protocol.dataBlocks.set('idm750100', idm_datablocks.idm750100);
|
|
35
40
|
idm_protocol.sensorDataBlocks.set('idm750100', idm_datablocks.idm750100_sensors);
|
|
36
41
|
idm_protocol.settingsDataBlocks.set('idm750100', idm_datablocks.idm750100_settings);
|
|
42
|
+
idm_protocol.speed.set('idm750100', idm_datablocks.idm750100_speed);
|
|
37
43
|
|
|
38
44
|
idm_protocol.dataDefinitions.set('EVR752101', idm_datablocks.evr752101_data);
|
|
39
45
|
idm_protocol.dataBlocks.set('EVR752101', idm_datablocks.evr752101);
|
|
40
46
|
idm_protocol.sensorDataBlocks.set('EVR752101', idm_datablocks.evr752101_sensors);
|
|
41
47
|
idm_protocol.settingsDataBlocks.set('EVR752101', idm_datablocks.evr752101_settings);
|
|
48
|
+
idm_protocol.speed.set('EVR752101', idm_datablocks.EVR752101_speed);
|
|
42
49
|
|
|
43
50
|
},
|
|
44
51
|
|
|
@@ -148,32 +155,33 @@ const idm_protocol = {
|
|
|
148
155
|
|
|
149
156
|
if (idm_utils.ord(ch) === 1) {
|
|
150
157
|
if (idm_protocol.receive_state !== 0) {
|
|
151
|
-
return 11;
|
|
158
|
+
return 11 + idm_protocol.receive_state * 100;
|
|
152
159
|
}
|
|
153
160
|
|
|
154
161
|
idm_protocol.receive_state = 1;
|
|
155
162
|
} else {
|
|
156
163
|
if (idm_utils.ord(ch) === 3) {
|
|
157
164
|
if (idm_protocol.receive_state !== 1) {
|
|
158
|
-
return 13;
|
|
165
|
+
return 13 + idm_protocol.receive_state * 100;
|
|
159
166
|
}
|
|
160
167
|
|
|
161
168
|
idm_protocol.receive_state = 2;
|
|
162
169
|
} else {
|
|
163
170
|
if (idm_utils.ord(ch) === 4) {
|
|
171
|
+
if (idm_protocol.receive_state == 0) { continue; } // ignore end end of text at the start
|
|
164
172
|
if (idm_protocol.receive_state !== 2) {
|
|
165
|
-
return 14;
|
|
173
|
+
return 14 + idm_protocol.receive_state * 100;
|
|
166
174
|
}
|
|
167
175
|
|
|
168
176
|
if (idm_protocol.receive_chksum.length !== 3) {
|
|
169
|
-
return 15;
|
|
177
|
+
return 15 + idm_protocol.receive_state * 100;
|
|
170
178
|
}
|
|
171
179
|
|
|
172
180
|
chksum_c = idm_utils.calc_checksum(idm_protocol.received_data_packet);
|
|
173
181
|
chksum_r = idm_utils.read_val(3, idm_protocol.receive_chksum);
|
|
174
182
|
|
|
175
183
|
if (chksum_c !== chksum_r) {
|
|
176
|
-
return 16;
|
|
184
|
+
return 16 + idm_protocol.receive_state * 100;
|
|
177
185
|
}
|
|
178
186
|
|
|
179
187
|
idm_protocol.receive_state = 3;
|
|
@@ -189,7 +197,7 @@ const idm_protocol = {
|
|
|
189
197
|
}
|
|
190
198
|
|
|
191
199
|
if (idm_protocol.receive_state === 3) {
|
|
192
|
-
return 20;
|
|
200
|
+
return 20 + idm_protocol.receive_state * 100;
|
|
193
201
|
}
|
|
194
202
|
}
|
|
195
203
|
}
|
package/lib/idm_datablocks.js
CHANGED
|
@@ -9,6 +9,7 @@ const idm_datablocks = {
|
|
|
9
9
|
idm701100: ['03', '04', '05', '06', '07', '08', '09', '0A', '0B'],
|
|
10
10
|
idm701100_sensors: ['07', '09', '0A', '0B'],
|
|
11
11
|
idm701100_settings: [ '03', '04', '05', '06', '08' ],
|
|
12
|
+
idm701100_speed: 100,
|
|
12
13
|
idm701100_data: {
|
|
13
14
|
version: 'idm701100',
|
|
14
15
|
data_blocks: [
|
|
@@ -191,6 +192,7 @@ const idm_datablocks = {
|
|
|
191
192
|
idm712100: ['03', '04', '05', '06', '07', '08', '09', '0A', '0B', '0C'],
|
|
192
193
|
idm712100_sensors: ['07', '09', '0B', '0C'],
|
|
193
194
|
idm712100_settings: [ '03', '04', '05', '06', '08', '0A' ],
|
|
195
|
+
idm712100_speed: 100,
|
|
194
196
|
idm712100_data: {
|
|
195
197
|
version: 'idm712100',
|
|
196
198
|
data_blocks: [
|
|
@@ -383,6 +385,7 @@ const idm_datablocks = {
|
|
|
383
385
|
idm722100: ['03', '04', '05', '06', '07', '08', '09', '0A', '0B', '0C', '0D'],
|
|
384
386
|
idm722100_sensors: ['07', '0B', '0C', '0D'],
|
|
385
387
|
idm722100_settings: [ '03', '04', '05', '06', '08', '09', '0A' ],
|
|
388
|
+
idm722100_speed: 75,
|
|
386
389
|
idm722100_data: {
|
|
387
390
|
version: 'idm722100',
|
|
388
391
|
data_blocks: [
|
|
@@ -585,6 +588,7 @@ const idm_datablocks = {
|
|
|
585
588
|
S_H726100: ['03', '04', '05', '06', '07', '08', '09', '0A', '0B', '0C', '0D'],
|
|
586
589
|
S_H726100_sensors: ['07', '0B', '0C', '0D'],
|
|
587
590
|
S_H726100_settings: [ '03', '04', '05', '06', '08', '09', '0A' ],
|
|
591
|
+
S_H726100_speed: 100,
|
|
588
592
|
S_H726100_data: {
|
|
589
593
|
version: 'S_H726100',
|
|
590
594
|
data_blocks: [
|
|
@@ -832,6 +836,7 @@ const idm_datablocks = {
|
|
|
832
836
|
idm750100: ['03', '04', '05', '06', '07', '09', '0B', '0C', '0D', '0E'],
|
|
833
837
|
idm750100_sensors: ['07', '0B', '0C', '0D', '0E'],
|
|
834
838
|
idm750100_settings: [ '03', '04', '05', '06', '09' ],
|
|
839
|
+
idm750100_speed: 100,
|
|
835
840
|
idm750100_data: {
|
|
836
841
|
version: 'idm750100',
|
|
837
842
|
data_blocks: [
|
|
@@ -1044,6 +1049,7 @@ const idm_datablocks = {
|
|
|
1044
1049
|
evr752101: ['03', '04', '05', '06', '07', '09', '0B', '0C', '0D', '0E'],
|
|
1045
1050
|
evr752101_sensors: ['07', '0B', '0C', '0D', '0E'],
|
|
1046
1051
|
evr752101_settings: [ '03', '04', '05', '06', '09' ],
|
|
1052
|
+
evr752101_speed: 100,
|
|
1047
1053
|
evr752101_data: {
|
|
1048
1054
|
version: 'EVR752101',
|
|
1049
1055
|
data_blocks: [
|
package/main.js
CHANGED
|
@@ -50,7 +50,7 @@ class IdmMultitalent002 extends utils.Adapter {
|
|
|
50
50
|
sendQueue = new Queue();
|
|
51
51
|
maxWrites = 5; // max values to be set in one "loop"
|
|
52
52
|
requestInitDelay = 600;
|
|
53
|
-
requestDataBlockDelay =
|
|
53
|
+
requestDataBlockDelay = 1000;
|
|
54
54
|
normalDataContentDelay = 850; // for all datablocks
|
|
55
55
|
retryDataContentDelay = 250; // for all datablocks
|
|
56
56
|
currentRequests = 0;
|
|
@@ -83,6 +83,22 @@ class IdmMultitalent002 extends utils.Adapter {
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
speedAdjusted = false;
|
|
87
|
+
AdjustSpeed() {
|
|
88
|
+
if (this.speedAdjusted) return;
|
|
89
|
+
var factor = idm.speed[this.version];
|
|
90
|
+
if (factor != null) {
|
|
91
|
+
if (factor != 100 && factor > 0) {
|
|
92
|
+
this.log.info('adjusting speed to ' + factor + '%');
|
|
93
|
+
factor = 100 / factor;
|
|
94
|
+
this.requestInitDelay = Math.round(this.requestInitDelay * factor);
|
|
95
|
+
this.requestDataBlockDelay = Math.round(this.requestDataBlockDelay * factor);
|
|
96
|
+
this.normalDataContentDelay = Math.round(this.normalDataContentDelay * factor);
|
|
97
|
+
this.retryDataContentDelay = Math.round(this.retryDataContentDelay * factor);
|
|
98
|
+
this.speedAdjusted = true;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
86
102
|
setIDMState(stateName, value) {
|
|
87
103
|
this.setStateAsync(stateName, value, true);
|
|
88
104
|
}
|
|
@@ -159,6 +175,11 @@ class IdmMultitalent002 extends utils.Adapter {
|
|
|
159
175
|
}
|
|
160
176
|
|
|
161
177
|
sendSetValueMessage(item) {
|
|
178
|
+
if (this.sendSetValueMessageTimeout1 == null) {
|
|
179
|
+
this.sendSetValueMessageTimeout2 = null;
|
|
180
|
+
} else {
|
|
181
|
+
this.sendSetValueMessageTimeout1 = null;
|
|
182
|
+
}
|
|
162
183
|
if (this.idmProtocolState !== 2 && this.idmProtocolState !== 0) {
|
|
163
184
|
this.log.warn('wrong state, should be in 2 but we are in ' + this.idmProtocolState + ' resetting connection');
|
|
164
185
|
this.setConnected(false, true);
|
|
@@ -196,13 +217,13 @@ class IdmMultitalent002 extends utils.Adapter {
|
|
|
196
217
|
if (this.send_state === 0) {
|
|
197
218
|
this.itemToBeSent = this.sendQueue.dequeue();
|
|
198
219
|
this.log.info('setting values: ' + idm.get_protocol_string(this.itemToBeSent));
|
|
199
|
-
if (this.client) setTimeout(this.send_init.bind(this), this.setValueDelay);
|
|
220
|
+
if (this.client) this.sendInitTimer = setTimeout(this.send_init.bind(this), this.setValueDelay);
|
|
200
221
|
this.send_state++;
|
|
201
222
|
} else if (this.send_state === 1) {
|
|
202
|
-
if (this.client) setTimeout(this.sendSetValueMessage.bind(this, this.itemToBeSent), this.setValueDelay);
|
|
223
|
+
if (this.client) this.sendSetValueMessageTimeout1 = setTimeout(this.sendSetValueMessage.bind(this, this.itemToBeSent), this.setValueDelay);
|
|
203
224
|
this.send_state++;
|
|
204
225
|
} else if (this.send_state === 2) {
|
|
205
|
-
if (this.client) setTimeout(this.sendSetValueMessage.bind(this, this.itemToBeSent), this.secondSetValueOffset);
|
|
226
|
+
if (this.client) this.sendSetValueMessageTimeout2 = setTimeout(this.sendSetValueMessage.bind(this, this.itemToBeSent), this.secondSetValueOffset);
|
|
206
227
|
this.send_state=0;
|
|
207
228
|
this.send_count++;
|
|
208
229
|
}
|
|
@@ -218,8 +239,15 @@ class IdmMultitalent002 extends utils.Adapter {
|
|
|
218
239
|
this.send_init();
|
|
219
240
|
}
|
|
220
241
|
|
|
242
|
+
sendInitTimer;
|
|
243
|
+
sendDataBlockRequestTimer;
|
|
244
|
+
sendDataContentTimer;
|
|
245
|
+
sendSetValueMessageTimeout1;
|
|
246
|
+
sendSetValueMessageTimeout2;
|
|
247
|
+
|
|
221
248
|
// send the init message to the control
|
|
222
249
|
send_init() {
|
|
250
|
+
this.sendInitTimer = null;
|
|
223
251
|
if (this.connectedToIDM === false) {
|
|
224
252
|
this.log.info('sending initial init message to heatpump');
|
|
225
253
|
}
|
|
@@ -244,6 +272,7 @@ class IdmMultitalent002 extends utils.Adapter {
|
|
|
244
272
|
* @param {string} dataBlock
|
|
245
273
|
*/
|
|
246
274
|
send_data_block_request(dataBlock) {
|
|
275
|
+
this.sendDataBlockRequestTimer = null;
|
|
247
276
|
if (this.idmProtocolState !== 2) {
|
|
248
277
|
if (this.idmProtocolState == -1) { this.log.info('send_data_block_request: not connected, ignore'); return;}
|
|
249
278
|
this.log.warn('send_data_block_request: wrong state, should be in 2 but we are in ' + this.idmProtocolState + ' resetting connection');
|
|
@@ -273,7 +302,7 @@ class IdmMultitalent002 extends utils.Adapter {
|
|
|
273
302
|
} else {
|
|
274
303
|
this.log.debug('requesting data block ' + dataBlock);
|
|
275
304
|
}
|
|
276
|
-
setTimeout(this.send_data_block_request.bind(this, dataBlock), this.requestDataBlockDelay);
|
|
305
|
+
this.sendDataBlockRequestTimer = setTimeout(this.send_data_block_request.bind(this, dataBlock), this.requestDataBlockDelay);
|
|
277
306
|
}
|
|
278
307
|
|
|
279
308
|
lastSettingsIndex = 0; // used to iterate settings data blocks
|
|
@@ -316,12 +345,13 @@ class IdmMultitalent002 extends utils.Adapter {
|
|
|
316
345
|
this.requestingSensorData = true;
|
|
317
346
|
}
|
|
318
347
|
|
|
319
|
-
|
|
348
|
+
this.request_data_block(datablockToRequest);
|
|
320
349
|
|
|
321
350
|
}
|
|
322
351
|
|
|
323
352
|
// send a data content request to the control
|
|
324
353
|
request_data_content() {
|
|
354
|
+
this.sendDataContentTimer = null;
|
|
325
355
|
if (this.idmProtocolState !== 4) {
|
|
326
356
|
if (this.idmProtocolState == -1) { this.log.info('request_data_content: not connected, ignore'); return;}
|
|
327
357
|
this.log.warn('request_data_content: wrong state, should be in 4 but we are in ' + this.idmProtocolState + ' resetting connection');
|
|
@@ -341,7 +371,7 @@ class IdmMultitalent002 extends utils.Adapter {
|
|
|
341
371
|
// callback for data received from control
|
|
342
372
|
// this will be the main method for handling the state machine and communication with the heatpump
|
|
343
373
|
// we have the "internal" receiving state ( 1.. receiving data, 2.. receiving checksum, 3.. finished, all above 3 are error states)
|
|
344
|
-
// then the protocolState (
|
|
374
|
+
// then the protocolState (derived from received data) (
|
|
345
375
|
// NR.. data request not ready, retry!
|
|
346
376
|
// E0.. too short packet,
|
|
347
377
|
// E1.. request data error,
|
|
@@ -350,7 +380,7 @@ class IdmMultitalent002 extends utils.Adapter {
|
|
|
350
380
|
// R1.. request data ok,
|
|
351
381
|
// S1.. set value ok,
|
|
352
382
|
// U1.. unknown response)
|
|
353
|
-
// and the idmProtocolState
|
|
383
|
+
// and the idmProtocolState (derived from what "we" requested)
|
|
354
384
|
// -1.. not connected
|
|
355
385
|
// 0.. idle or data received --> 1 or 6
|
|
356
386
|
// 1.. init sent, waiting for answer --> 2
|
|
@@ -361,8 +391,8 @@ class IdmMultitalent002 extends utils.Adapter {
|
|
|
361
391
|
// 6.. data set value sent, waiting for ack --> 0
|
|
362
392
|
receive_data(data) {
|
|
363
393
|
var state = idm.add_to_packet(data);
|
|
364
|
-
this.log.silly('************* receiving **************** state ' + state + ' data=' + idm.get_protocol_string(data));
|
|
365
394
|
if (state == 3) { // data packed received completely, let's check what we've got
|
|
395
|
+
this.log.silly('************* receiving **************** state ' + state + ' data=' + idm.get_protocol_string(data));
|
|
366
396
|
var received_data = idm.get_data_packet();
|
|
367
397
|
idm.reset(); // reset the packet reader to be ready for the next packet
|
|
368
398
|
var protocolState = idm.protocol_state(received_data);
|
|
@@ -377,7 +407,7 @@ class IdmMultitalent002 extends utils.Adapter {
|
|
|
377
407
|
this.retry_count = 0;
|
|
378
408
|
this.totalRequests ++;
|
|
379
409
|
this.currentRequests ++;
|
|
380
|
-
setTimeout(this.request_data_content.bind(this), this.normalDataContentDelay); // request the data content
|
|
410
|
+
this.sendDataContentTimer = setTimeout(this.request_data_content.bind(this), this.normalDataContentDelay); // request the data content
|
|
381
411
|
return;
|
|
382
412
|
}
|
|
383
413
|
if (protocolState === 'NR') {
|
|
@@ -389,7 +419,7 @@ class IdmMultitalent002 extends utils.Adapter {
|
|
|
389
419
|
if (this.retry_count > this.maxRetries) {
|
|
390
420
|
this.log.warn('too many data content request retries (' + this.retry_count + '), retry whole request.');
|
|
391
421
|
this.idmProtocolState = 0;
|
|
392
|
-
this.setTimeout(this.send_init.bind(this), this.requestInitDelay);
|
|
422
|
+
this.sendInitTimer = this.setTimeout(this.send_init.bind(this), this.requestInitDelay);
|
|
393
423
|
return;
|
|
394
424
|
}
|
|
395
425
|
this.retry_count++;
|
|
@@ -397,7 +427,7 @@ class IdmMultitalent002 extends utils.Adapter {
|
|
|
397
427
|
this.currentRetries++;
|
|
398
428
|
this.log.debug('retry data request ' + this.retry_count);
|
|
399
429
|
this.idmProtocolState = 4;
|
|
400
|
-
setTimeout(this.request_data_content.bind(this), this.retryDataContentDelay); // request the data content again
|
|
430
|
+
this.sendDataContentTimer = setTimeout(this.request_data_content.bind(this), this.retryDataContentDelay); // request the data content again
|
|
401
431
|
return;
|
|
402
432
|
}
|
|
403
433
|
if (protocolState === 'S1') { // have to be in idmProtocolState 6
|
|
@@ -409,8 +439,8 @@ class IdmMultitalent002 extends utils.Adapter {
|
|
|
409
439
|
this.idmProtocolState = 0;
|
|
410
440
|
this.need_to_send_data = this.write_data_to_heatpump(!this.need_to_send_data);
|
|
411
441
|
if (!this.need_to_send_data) {
|
|
412
|
-
this.setTimeout(this.send_init.bind(this), this.requestInitDelay);
|
|
413
|
-
this.log.debug('set
|
|
442
|
+
this.sendInitTimer = this.setTimeout(this.send_init.bind(this), this.requestInitDelay);
|
|
443
|
+
this.log.debug('set timer to send init in order to request next data block');
|
|
414
444
|
}
|
|
415
445
|
return;
|
|
416
446
|
}
|
|
@@ -427,7 +457,7 @@ class IdmMultitalent002 extends utils.Adapter {
|
|
|
427
457
|
this.idmProtocolState = 0;
|
|
428
458
|
this.need_to_send_data= this.write_data_to_heatpump(!this.need_to_send_data);
|
|
429
459
|
if (!this.need_to_send_data) {
|
|
430
|
-
this.setTimeout(this.send_init.bind(this), this.requestInitDelay);
|
|
460
|
+
this.sendInitTimer = this.setTimeout(this.send_init.bind(this), this.requestInitDelay);
|
|
431
461
|
this.log.debug('set time to send init in order to request next data block');
|
|
432
462
|
}
|
|
433
463
|
return;
|
|
@@ -444,6 +474,7 @@ class IdmMultitalent002 extends utils.Adapter {
|
|
|
444
474
|
this.setStateAsync('idm_control_version', this.version, true);
|
|
445
475
|
this.setConnected(true);
|
|
446
476
|
this.CreateStates();
|
|
477
|
+
this.AdjustSpeed();
|
|
447
478
|
}
|
|
448
479
|
if (this.need_to_send_data) {
|
|
449
480
|
this.need_to_send_data = this.write_data_to_heatpump(false);
|
|
@@ -456,20 +487,27 @@ class IdmMultitalent002 extends utils.Adapter {
|
|
|
456
487
|
if (protocolState ==='E1' || protocolState === 'E2') {
|
|
457
488
|
this.log.warn('data content request error, retry whole request.');
|
|
458
489
|
this.idmProtocolState = 0;
|
|
459
|
-
this.setTimeout(this.send_init.bind(this), this.requestInitDelay);
|
|
490
|
+
this.sendInitTimer = this.setTimeout(this.send_init.bind(this), this.requestInitDelay);
|
|
460
491
|
return;
|
|
461
492
|
}
|
|
462
493
|
this.log.warn('not sure what to do, idm-protocol-state ' + this.idmProtocolStateToText());
|
|
463
494
|
this.log.warn('unknown protocol state ' + protocolState + ' data=' + text);
|
|
464
495
|
this.log.warn('trying to send init message to restart communication');
|
|
465
496
|
this.idmProtocolState = 0;
|
|
466
|
-
this.setTimeout(this.send_init.bind(this), this.requestInitDelay * 2);
|
|
497
|
+
this.sendInitTimer = this.setTimeout(this.send_init.bind(this), this.requestInitDelay * 2);
|
|
467
498
|
}
|
|
468
499
|
} else if (state > 3) {
|
|
500
|
+
this.log.debug('************* receiving **************** state ' + state + ' data=' + idm.get_protocol_string(data));
|
|
469
501
|
this.log.warn('wrong state in receiving data, state is ' + state + ' resetting the transmission and retrying to continue communication');
|
|
470
502
|
idm.reset();
|
|
471
|
-
|
|
472
|
-
|
|
503
|
+
// clear all timers to avoid confusion
|
|
504
|
+
if (this.sendInitTimer) {this.clearTimeout(this.sendInitTimer);this.sendInitTimer = null;}
|
|
505
|
+
if (this.sendDataBlockRequestTimer) {this.clearTimeout(this.sendDataBlockRequestTimer);this.sendDataBlockRequestTimer = null;}
|
|
506
|
+
if (this.sendDataContentTimer) {this.clearTimeout(this.sendDataContentTimer);this.sendDataContentTimer = null;}
|
|
507
|
+
if (this.sendSetValueMessageTimeout1) {this.clearTimeout(this.sendSetValueMessageTimeout1);this.sendSetValueMessageTimeout1 = null;}
|
|
508
|
+
if (this.sendSetValueMessageTimeout2) {this.clearTimeout(this.sendSetValueMessageTimeout2);this.sendSetValueMessageTimeout2 = null;}
|
|
509
|
+
this.sendInitTimer = this.setTimeout(this.send_init.bind(this), this.requestInitDelay * 2);
|
|
510
|
+
}
|
|
473
511
|
|
|
474
512
|
}
|
|
475
513
|
|