homebridge-melcloud-control 3.3.15 → 3.3.17-beta.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/CHANGELOG.md CHANGED
@@ -16,7 +16,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
16
16
  - do not configure it manually, always using Config UI X
17
17
  - required Homebridge v2.0.0 and above
18
18
 
19
- ## [3.3.15] - (21.09.2024)
19
+ ## [3.3.16] - (23.09.2024)
20
+
21
+ ## Changes
22
+
23
+ - fix report wrong target mode if device is OFF and the plugin or bridge reboots
24
+ - fix [#167](https://github.com/grzegorz914/homebridge-melcloud-control/issues/167)
25
+ - cleanup
26
+
27
+ ## [3.3.15] - (21.09.2024)
20
28
 
21
29
  ## Changes
22
30
 
package/README.md CHANGED
@@ -164,7 +164,7 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
164
164
 
165
165
  ### AUTO Mode
166
166
 
167
- * Heather/Coolert
167
+ * Heather/Cooler
168
168
  * In this mode we can set heathing threshold and cooling threshold temperature:
169
169
  * Target temperature is calculated as a middle value between `LO` and `HI` and the rest is calculated internally.
170
170
  * Thermostat
package/index.js CHANGED
@@ -146,7 +146,7 @@ class MelCloudPlatform {
146
146
  await airConditioner.start();
147
147
  };
148
148
  } catch (error) {
149
- log.error(`Account: ${accountName}, ATA did finish launching error: ${error.message ?? error}`);
149
+ log.error(`Account: ${accountName}, ATA did finish launching error: ${error}`);
150
150
  }
151
151
 
152
152
  //Heat Pump 1
@@ -191,7 +191,7 @@ class MelCloudPlatform {
191
191
  await heatPump.start();
192
192
  };
193
193
  } catch (error) {
194
- log.error(`Account: ${accountName}, ATW did finish launching error: ${error.message ?? error}`);
194
+ log.error(`Account: ${accountName}, ATW did finish launching error: ${error}`);
195
195
  }
196
196
 
197
197
  //Energy Recovery Ventilation 3
@@ -236,10 +236,10 @@ class MelCloudPlatform {
236
236
  await energyRecoveryVentilation.start();
237
237
  };
238
238
  } catch (error) {
239
- log.error(`Account: ${accountName}, ERV did finish launching error: ${error.message ?? error}`);
239
+ log.error(`Account: ${accountName}, ERV did finish launching error: ${error}`);
240
240
  }
241
241
  } catch (error) {
242
- log.error(`Account: ${accountName}, did finish launching error: ${error.message ?? error}`);
242
+ log.error(`Account: ${accountName}, did finish launching error: ${error}`);
243
243
  }
244
244
  };
245
245
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "3.3.15",
4
+ "version": "3.3.17-beta.0",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
package/src/deviceata.js CHANGED
@@ -93,9 +93,6 @@ class DeviceAta extends EventEmitter {
93
93
 
94
94
  //accessory
95
95
  this.accessory = {};
96
- this.accessory.currentOperationMode = 0;
97
- this.accessory.targetOperationMode = 0;
98
- this.accessory.fanSpeed = 0;
99
96
  this.accessory.useFahrenheit = useFahrenheit ? 1 : 0;
100
97
  this.accessory.temperatureUnit = CONSTANTS.TemperatureDisplayUnits[this.accessory.useFahrenheit];
101
98
  };
@@ -129,7 +126,7 @@ class DeviceAta extends EventEmitter {
129
126
  try {
130
127
  await this.setOverExternalIntegration('RESTFul', deviceData, key, value);
131
128
  } catch (error) {
132
- this.emit('warn', `RESTFul set error: ${error}.`);
129
+ this.emit('warn', error);
133
130
  };
134
131
  })
135
132
  .on('debug', (debug) => {
@@ -168,7 +165,7 @@ class DeviceAta extends EventEmitter {
168
165
  try {
169
166
  await this.setOverExternalIntegration('MQTT', deviceData, key, value);
170
167
  } catch (error) {
171
- this.emit('warn', `MQTT set error: ${error}.`);
168
+ this.emit('warn', error);
172
169
  };
173
170
  })
174
171
  .on('debug', (debug) => {
@@ -183,7 +180,7 @@ class DeviceAta extends EventEmitter {
183
180
  }
184
181
 
185
182
  } catch (error) {
186
- this.emit('warn', `External integration start error: ${error.message || error}.`);
183
+ this.emit('warn', `External integration start error: ${error}.`);
187
184
  };
188
185
  })
189
186
  .on('deviceInfo', (manufacturer, modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion) => {
@@ -293,64 +290,51 @@ class DeviceAta extends EventEmitter {
293
290
  switch (this.displayMode) {
294
291
  case 1: //Heater Cooler
295
292
  //operating mode 0, HEAT, DRY, COOL, 4, 5, 6, FAN, AUTO, ISEE HEAT, ISEE DRY, ISEE COOL
296
- switch (power) {
297
- case true:
298
- switch (!inStandbyMode) {
299
- case true:
300
- switch (operationMode) {
301
- case 1: //HEAT
302
- this.accessory.currentOperationMode = roomTemperature > setTemperature ? 1 : 2; //INACTIVE, IDLE, HEATING, COOLING
303
- this.accessory.targetOperationMode = 1; //AUTO, HEAT, COOL
304
- break;
305
- case 2: //DRY
306
- this.accessory.currentOperationMode = 1;
307
- this.accessory.targetOperationMode = this.autoDryFanMode === 2 ? 0 : this.heatDryFanMode === 2 ? 1 : this.coolDryFanMode === 2 ? 2 : this.accessory.targetOperationMode;
308
- break;
309
- case 3: //COOL
310
- this.accessory.currentOperationMode = roomTemperature < setTemperature ? 1 : 3;
311
- this.accessory.targetOperationMode = 2;
312
- break;
313
- case 7: //FAN
314
- this.accessory.currentOperationMode = 1;
315
- this.accessory.targetOperationMode = this.autoDryFanMode === 3 ? 0 : this.heatDryFanMode === 3 ? 1 : this.coolDryFanMode === 3 ? 2 : this.accessory.targetOperationMode;
316
- break;
317
- case 8: //AUTO
318
- this.accessory.currentOperationMode = roomTemperature < setTemperature ? 2 : roomTemperature > setTemperature ? 3 : 1;
319
- this.accessory.targetOperationMode = 0;
320
- break;
321
- case 9: //ISEE HEAT
322
- this.accessory.currentOperationMode = roomTemperature > setTemperature ? 1 : 2
323
- this.accessory.targetOperationMode = 1;
324
- break;
325
- case 10: //ISEE DRY
326
- this.accessory.currentOperationMode = 1;
327
- this.accessory.targetOperationMode = this.autoDryFanMode === 2 ? 0 : this.heatDryFanMode === 2 ? 1 : this.coolDryFanMode === 2 ? 2 : this.accessory.targetOperationMode;
328
- break;
329
- case 11: //ISEE COOL;
330
- this.accessory.currentOperationMode = roomTemperature < setTemperature ? 1 : 3;
331
- this.accessory.targetOperationMode = 2;
332
- break;
333
- default:
334
- this.emit('warn', `Received unknown operating mode: ${operationMode}`);
335
- return
336
- };
337
- break;
338
- case false:
339
- this.accessory.currentOperationMode = 1;
340
- break;
341
- };
293
+ switch (operationMode) {
294
+ case 1: //HEAT
295
+ this.accessory.currentOperationMode = roomTemperature > setTemperature ? 1 : 2; //INACTIVE, IDLE, HEATING, COOLING
296
+ this.accessory.targetOperationMode = 1; //AUTO, HEAT, COOL
342
297
  break;
343
- case false:
344
- this.accessory.currentOperationMode = 0;
298
+ case 2: //DRY
299
+ this.accessory.currentOperationMode = 1;
300
+ this.accessory.targetOperationMode = this.autoDryFanMode === 2 ? 0 : this.heatDryFanMode === 2 ? 1 : this.coolDryFanMode === 2 ? 2 : this.accessory.targetOperationMode;
301
+ break;
302
+ case 3: //COOL
303
+ this.accessory.currentOperationMode = roomTemperature < setTemperature ? 1 : 3;
304
+ this.accessory.targetOperationMode = 2;
305
+ break;
306
+ case 7: //FAN
307
+ this.accessory.currentOperationMode = 1;
308
+ this.accessory.targetOperationMode = this.autoDryFanMode === 3 ? 0 : this.heatDryFanMode === 3 ? 1 : this.coolDryFanMode === 3 ? 2 : this.accessory.targetOperationMode;
309
+ break;
310
+ case 8: //AUTO
311
+ this.accessory.currentOperationMode = roomTemperature < setTemperature ? 2 : roomTemperature > setTemperature ? 3 : 1;
312
+ this.accessory.targetOperationMode = 0;
345
313
  break;
314
+ case 9: //ISEE HEAT
315
+ this.accessory.currentOperationMode = roomTemperature > setTemperature ? 1 : 2
316
+ this.accessory.targetOperationMode = 1;
317
+ break;
318
+ case 10: //ISEE DRY
319
+ this.accessory.currentOperationMode = 1;
320
+ this.accessory.targetOperationMode = this.autoDryFanMode === 2 ? 0 : this.heatDryFanMode === 2 ? 1 : this.coolDryFanMode === 2 ? 2 : this.accessory.targetOperationMode;
321
+ break;
322
+ case 11: //ISEE COOL;
323
+ this.accessory.currentOperationMode = roomTemperature < setTemperature ? 1 : 3;
324
+ this.accessory.targetOperationMode = 2;
325
+ break;
326
+ default:
327
+ this.emit('warn', `Unknown operating mode: ${operationMode}`);
328
+ return
346
329
  };
330
+
331
+ this.accessory.currentOperationMode = !power ? 0 : inStandbyMode ? 1 : this.accessory.currentOperationMode;
347
332
  this.accessory.operationModeSetPropsMinValue = modelSupportsAuto && modelSupportsHeat ? 0 : !modelSupportsAuto && modelSupportsHeat ? 1 : modelSupportsAuto && !modelSupportsHeat ? 0 : 2;
348
333
  this.accessory.operationModeSetPropsMaxValue = 2
349
334
  this.accessory.operationModeSetPropsValidValues = modelSupportsAuto && modelSupportsHeat ? [0, 1, 2] : !modelSupportsAuto && modelSupportsHeat ? [1, 2] : modelSupportsAuto && !modelSupportsHeat ? [0, 2] : [2];
350
335
 
351
336
  //fan speed mode
352
337
  if (modelSupportsFanSpeed) {
353
- this.accessory.fanSpeedSetPropsMaxValue = 2;
354
338
  switch (numberOfFanSpeeds) {
355
339
  case 2: //Fan speed mode 2
356
340
  this.accessory.fanSpeed = hasAutomaticFanSpeed ? [3, 1, 2][fanSpeed] : [0, 1, 2][fanSpeed];
@@ -391,56 +375,46 @@ class DeviceAta extends EventEmitter {
391
375
  };
392
376
  break;
393
377
  case 2: //Thermostat
394
- switch (power) {
395
- case true:
396
- switch (!inStandbyMode) {
397
- case true:
398
- switch (operationMode) {
399
- case 1: //HEAT
400
- this.accessory.currentOperationMode = roomTemperature > setTemperature ? 0 : 1; //OFF, HEATING, COOLING
401
- this.accessory.targetOperationMode = 1; //OFF, HEAT, COOL, AUTO
402
- break;
403
- case 2: //DRY
404
- this.accessory.currentOperationMode = 0;
405
- this.accessory.targetOperationMode = this.autoDryFanMode === 2 ? 3 : this.heatDryFanMode === 2 ? 1 : this.coolDryFanMode === 2 ? 2 : this.accessory.targetOperationMode;
406
- break;
407
- case 3: //COOL
408
- this.accessory.currentOperationMode = roomTemperature < setTemperature ? 0 : 2;
409
- this.accessory.targetOperationMode = 2;
410
- break;
411
- case 7: //FAN
412
- this.accessory.currentOperationMode = 0;
413
- this.accessory.targetOperationMode = this.autoDryFanMode === 3 ? 3 : this.heatDryFanMode === 3 ? 1 : this.coolDryFanMode === 3 ? 2 : this.accessory.targetOperationMode;
414
- break;
415
- case 8: //AUTO
416
- this.accessory.currentOperationMode = roomTemperature < setTemperature ? 1 : roomTemperature > setTemperature ? 2 : 0;
417
- this.accessory.targetOperationMode = 3;
418
- break;
419
- case 9: //ISEE HEAT
420
- this.accessory.currentOperationMode = roomTemperature > setTemperature ? 0 : 1;
421
- this.accessory.targetOperationMode = 1;
422
- break;
423
- case 10: //ISEE DRY
424
- this.accessory.currentOperationMode = 0;
425
- this.accessory.targetOperationMode = this.autoDryFanMode === 2 ? 3 : this.heatDryFanMode === 2 ? 1 : this.coolDryFanMode === 2 ? 2 : this.accessory.targetOperationMode;
426
- break;
427
- case 11: //ISEE COOL;
428
- this.accessory.currentOperationMode = roomTemperature < setTemperature ? 0 : 2;
429
- this.accessory.targetOperationMode = 2;
430
- break;
431
- default:
432
- this.emit('warn', `Unknown operating mode: ${operationMode}`);
433
- break;
434
- };
435
- break;
436
- case false:
437
- this.accessory.currentOperationMode = 0;
438
- break;
439
- };
440
- case false:
378
+ switch (operationMode) {
379
+ case 1: //HEAT
380
+ this.accessory.currentOperationMode = roomTemperature > setTemperature ? 0 : 1; //OFF, HEATING, COOLING
381
+ this.accessory.targetOperationMode = 1; //OFF, HEAT, COOL, AUTO
382
+ break;
383
+ case 2: //DRY
384
+ this.accessory.currentOperationMode = 0;
385
+ this.accessory.targetOperationMode = this.autoDryFanMode === 2 ? 3 : this.heatDryFanMode === 2 ? 1 : this.coolDryFanMode === 2 ? 2 : this.accessory.targetOperationMode;
386
+ break;
387
+ case 3: //COOL
388
+ this.accessory.currentOperationMode = roomTemperature < setTemperature ? 0 : 2;
389
+ this.accessory.targetOperationMode = 2;
390
+ break;
391
+ case 7: //FAN
392
+ this.accessory.currentOperationMode = 0;
393
+ this.accessory.targetOperationMode = this.autoDryFanMode === 3 ? 3 : this.heatDryFanMode === 3 ? 1 : this.coolDryFanMode === 3 ? 2 : this.accessory.targetOperationMode;
394
+ break;
395
+ case 8: //AUTO
396
+ this.accessory.currentOperationMode = roomTemperature < setTemperature ? 1 : roomTemperature > setTemperature ? 2 : 0;
397
+ this.accessory.targetOperationMode = 3;
398
+ break;
399
+ case 9: //ISEE HEAT
400
+ this.accessory.currentOperationMode = roomTemperature > setTemperature ? 0 : 1;
401
+ this.accessory.targetOperationMode = 1;
402
+ break;
403
+ case 10: //ISEE DRY
441
404
  this.accessory.currentOperationMode = 0;
405
+ this.accessory.targetOperationMode = this.autoDryFanMode === 2 ? 3 : this.heatDryFanMode === 2 ? 1 : this.coolDryFanMode === 2 ? 2 : this.accessory.targetOperationMode;
406
+ break;
407
+ case 11: //ISEE COOL;
408
+ this.accessory.currentOperationMode = roomTemperature < setTemperature ? 0 : 2;
409
+ this.accessory.targetOperationMode = 2;
410
+ break;
411
+ default:
412
+ this.emit('warn', `Unknown operating mode: ${operationMode}`);
442
413
  break;
443
414
  };
415
+
416
+ this.accessory.currentOperationMode = !power ? 0 : this.accessory.currentOperationMode;
417
+ this.accessory.targetOperationMode = !power ? 0 : this.accessory.targetOperationMode;
444
418
  this.accessory.operationModeSetPropsMinValue = 0
445
419
  this.accessory.operationModeSetPropsMaxValue = modelSupportsAuto && modelSupportsHeat ? 3 : !modelSupportsAuto && modelSupportsHeat ? 2 : modelSupportsAuto && !modelSupportsHeat ? 3 : 2;
446
420
  this.accessory.operationModeSetPropsValidValues = modelSupportsAuto && modelSupportsHeat ? [0, 1, 2, 3] : !modelSupportsAuto && modelSupportsHeat ? [0, 1, 2] : modelSupportsAuto && !modelSupportsHeat ? [0, 2, 3] : [0, 2];
@@ -640,7 +614,7 @@ class DeviceAta extends EventEmitter {
640
614
  this.emit('publishAccessory', accessory);
641
615
  this.startPrepareAccessory = false;
642
616
  } catch (error) {
643
- this.emit('error', `Prepare accessory error: ${error.message ?? error}`);
617
+ this.emit('error', error);
644
618
  };
645
619
  })
646
620
  .on('message', (message) => {
@@ -664,7 +638,7 @@ class DeviceAta extends EventEmitter {
664
638
 
665
639
  return true;
666
640
  } catch (error) {
667
- throw new Error(`Start error: ${error.message ?? error}`);
641
+ throw new Error(`Start error: ${error}`);
668
642
  };
669
643
  };
670
644
 
@@ -1419,7 +1393,7 @@ class DeviceAta extends EventEmitter {
1419
1393
 
1420
1394
  return accessory;
1421
1395
  } catch (error) {
1422
- throw new Error(error);
1396
+ throw new Error(`Prepare accessory error: ${error.message || error}`);
1423
1397
  };
1424
1398
  };
1425
1399
  };
package/src/deviceatw.js CHANGED
@@ -130,7 +130,7 @@ class DeviceAtw extends EventEmitter {
130
130
  try {
131
131
  await this.setOverExternalIntegration('RESTFul', deviceData, key, value);
132
132
  } catch (error) {
133
- this.emit('warn', `RESTFul set error: ${error}.`);
133
+ this.emit('warn', error);
134
134
  };
135
135
  })
136
136
  .on('debug', (debug) => {
@@ -169,7 +169,7 @@ class DeviceAtw extends EventEmitter {
169
169
  try {
170
170
  await this.setOverExternalIntegration('MQTT', deviceData, key, value);
171
171
  } catch (error) {
172
- this.emit('warn', `MQTT set error: ${error}.`);
172
+ this.emit('warn', error);
173
173
  };
174
174
  })
175
175
  .on('debug', (debug) => {
@@ -183,7 +183,7 @@ class DeviceAtw extends EventEmitter {
183
183
  const mqtt1 = this.mqttConnected ? this.mqtt1.emit('publish', `State`, deviceData.Device) : false;
184
184
  }
185
185
  } catch (error) {
186
- this.emit('warn', `External integration start error: ${error.message || error}.`);
186
+ this.emit('warn', `External integration start error: ${error}.`);
187
187
  };
188
188
  })
189
189
  .on('deviceInfo', (manufacturer, modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion, hasHotWaterTank, hasZone2) => {
@@ -781,7 +781,7 @@ class DeviceAtw extends EventEmitter {
781
781
  button.state = (prohibitZone2 === true);
782
782
  break;
783
783
  default: //Unknown button
784
- this.emit('message', `Unknown button mode: ${mode} detected.`);
784
+ this.emit('warn', `Unknown button mode: ${mode} detected.`);
785
785
  break;
786
786
  };
787
787
 
@@ -804,7 +804,7 @@ class DeviceAtw extends EventEmitter {
804
804
  this.emit('publishAccessory', accessory);
805
805
  this.startPrepareAccessory = false;
806
806
  } catch (error) {
807
- this.emit('error', `Prepare accessory error: ${error}`);
807
+ this.emit('error', error);
808
808
  };
809
809
  })
810
810
  .on('message', (message) => {
@@ -828,7 +828,7 @@ class DeviceAtw extends EventEmitter {
828
828
 
829
829
  return true;
830
830
  } catch (error) {
831
- throw new Error(`start error: ${error}`);
831
+ throw new Error(`Start error: ${error}`);
832
832
  };
833
833
  };
834
834
 
@@ -1934,7 +1934,7 @@ class DeviceAtw extends EventEmitter {
1934
1934
 
1935
1935
  return accessory;
1936
1936
  } catch (error) {
1937
- throw new Error(error.message ?? error);
1937
+ throw new Error(`Prepare accessory error: ${error.message || error}`);
1938
1938
  };
1939
1939
  };
1940
1940
  };
package/src/deviceerv.js CHANGED
@@ -91,9 +91,6 @@ class DeviceErv extends EventEmitter {
91
91
 
92
92
  //accessory
93
93
  this.accessory = {};
94
- this.accessory.currentOperationMode = 0;
95
- this.accessory.targetOperationMode = 0;
96
- this.accessory.fanSpeed = 0;
97
94
  this.accessory.useFahrenheit = useFahrenheit ? 1 : 0;
98
95
  this.accessory.temperatureUnit = CONSTANTS.TemperatureDisplayUnits[this.accessory.useFahrenheit];
99
96
  };
@@ -127,7 +124,7 @@ class DeviceErv extends EventEmitter {
127
124
  try {
128
125
  await this.setOverExternalIntegration('RESTFul', deviceData, key, value);
129
126
  } catch (error) {
130
- this.emit('warn', `RESTFul set error: ${error}.`);
127
+ this.emit('warn', error);
131
128
  };
132
129
  })
133
130
  .on('debug', (debug) => {
@@ -166,7 +163,7 @@ class DeviceErv extends EventEmitter {
166
163
  try {
167
164
  await this.setOverExternalIntegration('MQTT', deviceData, key, value);
168
165
  } catch (error) {
169
- this.emit('warn', `MQTT set error: ${error}.`);
166
+ this.emit('warn', error);
170
167
  };
171
168
  })
172
169
  .on('debug', (debug) => {
@@ -180,7 +177,7 @@ class DeviceErv extends EventEmitter {
180
177
  const mqtt1 = this.mqttConnected ? this.mqtt1.emit('publish', `State`, deviceData.Device) : false;
181
178
  }
182
179
  } catch (error) {
183
- this.emit('warn', `External integration start error: ${error.message || error}.`);
180
+ this.emit('warn', `External integration start error: ${error}.`);
184
181
  };
185
182
  })
186
183
  .on('deviceInfo', (manufacturer, modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion) => {
@@ -295,41 +292,35 @@ class DeviceErv extends EventEmitter {
295
292
  //ventilation mode - 0, HEAT, 2, COOL, 4, 5, 6, FAN, AUTO
296
293
  switch (this.displayMode) {
297
294
  case 1: //Heater Cooler
298
- switch (power) {
299
- case true:
300
- switch (ventilationMode) {
295
+ switch (ventilationMode) {
296
+ case 0: //LOSSNAY
297
+ this.accessory.currentOperationMode = 2; //INACTIVE, IDLE, HEATING, COOLIN
298
+ this.accessory.targetOperationMode = 1; //AUTO, HEAT, COOL
299
+ break;
300
+ case 1: //BYPASS
301
+ this.accessory.currentOperationMode = 3;
302
+ this.accessory.targetOperationMode = 2;
303
+ break;
304
+ case 2: //AUTO
305
+ switch (actualVentilationMode) {
301
306
  case 0: //LOSSNAY
302
- this.accessory.currentOperationMode = 2; //INACTIVE, IDLE, HEATING, COOLIN
303
- this.accessory.targetOperationMode = 1; //AUTO, HEAT, COOL
307
+ this.accessory.currentOperationMode = 2;
304
308
  break;
305
309
  case 1: //BYPASS
306
310
  this.accessory.currentOperationMode = 3;
307
- this.accessory.targetOperationMode = 2;
308
- break;
309
- case 2: //AUTO
310
- switch (actualVentilationMode) {
311
- case 0: //LOSSNAY
312
- this.accessory.currentOperationMode = 2;
313
- break;
314
- case 1: //BYPASS
315
- this.accessory.currentOperationMode = 3;
316
- break;
317
- default:
318
- this.emit('warn', `Unknown actual ventilation mode: ${actualVentilationMode}`);
319
- break;
320
- };
321
- this.accessory.targetOperationMode = 0;
322
311
  break;
323
312
  default:
324
- this.emit('warn', `Unknown ventilation mode: ${ventilationMode}`);
313
+ this.emit('warn', `Unknown actual ventilation mode: ${actualVentilationMode}`);
325
314
  break;
326
315
  };
316
+ this.accessory.targetOperationMode = 0;
327
317
  break;
328
- case false:
329
- this.accessory.currentOperationMode = 0;
318
+ default:
319
+ this.emit('warn', `Unknown ventilation mode: ${ventilationMode}`);
330
320
  break;
331
321
  };
332
322
 
323
+ this.accessory.currentOperationMode = !power ? 0 : this.accessory.currentOperationMode;
333
324
  this.accessory.operationModeSetPropsMinValue = hasAutoVentilationMode ? 0 : 1;
334
325
  this.accessory.operationModeSetPropsMaxValue = hasAutoVentilationMode ? 2 : 2;
335
326
  this.accessory.operationModeSetPropsValidValues = hasAutoVentilationMode ? (hasBypassVentilationMode ? [0, 1, 2] : [0, 2]) : (hasBypassVentilationMode ? [1, 2] : [2]);
@@ -367,41 +358,36 @@ class DeviceErv extends EventEmitter {
367
358
  break;
368
359
  case 2: //Thermostat
369
360
  //operation mode - 0, HEAT, 2, COOL, 4, 5, 6, FAN, AUTO
370
- switch (power) {
371
- case true:
372
- switch (ventilationMode) {
361
+ switch (ventilationMode) {
362
+ case 0: //LOSSNAY
363
+ this.accessory.currentOperationMode = 1; //OFF, HEAT, COOL
364
+ this.accessory.targetOperationMode = 1; //OFF, HEAT, COOL, AUTO
365
+ break;
366
+ case 1: //BYPASS
367
+ this.accessory.currentOperationMode = 2;
368
+ this.accessory.targetOperationMode = 2;
369
+ break;
370
+ case 2: //AUTO
371
+ switch (actualVentilationMode) {
373
372
  case 0: //LOSSNAY
374
- this.accessory.currentOperationMode = 1; //OFF, HEAT, COOL
375
- this.accessory.targetOperationMode = 1; //OFF, HEAT, COOL, AUTO
373
+ this.accessory.currentOperationMode = 1;
376
374
  break;
377
375
  case 1: //BYPASS
378
376
  this.accessory.currentOperationMode = 2;
379
- this.accessory.targetOperationMode = 2;
380
- break;
381
- case 2: //AUTO
382
- switch (actualVentilationMode) {
383
- case 0: //LOSSNAY
384
- this.accessory.currentOperationMode = 1;
385
- break;
386
- case 1: //BYPASS
387
- this.accessory.currentOperationMode = 2;
388
- break;
389
- default:
390
- this.emit('warn', `Unknown actual ventilation mode: ${actualVentilationMode}`);
391
- break;
392
- };
393
- this.accessory.targetOperationMode = 3;
394
377
  break;
395
378
  default:
396
- this.emit('warn', `Unknown ventilation mode: ${ventilationMode}`);
379
+ this.emit('warn', `Unknown actual ventilation mode: ${actualVentilationMode}`);
397
380
  break;
398
381
  };
382
+ this.accessory.targetOperationMode = 3;
399
383
  break;
400
- case false:
401
- this.accessory.currentOperationMode = 0;
402
- this.accessory.targetOperationMode = 0;
384
+ default:
385
+ this.emit('warn', `Unknown ventilation mode: ${ventilationMode}`);
403
386
  break;
404
387
  };
388
+
389
+ this.accessory.currentOperationMode = !power ? 0 : this.accessory.currentOperationMode;
390
+ this.accessory.targetOperationMode = !power ? 0 : this.accessory.targetOperationMode;
405
391
  this.accessory.operationModeSetPropsMinValue = hasAutoVentilationMode ? 0 : 0;
406
392
  this.accessory.operationModeSetPropsMaxValue = hasAutoVentilationMode ? 3 : 2;
407
393
  this.accessory.operationModeSetPropsValidValues = hasAutoVentilationMode ? (hasBypassVentilationMode ? [0, 1, 2, 3] : [0, 2, 3]) : (hasBypassVentilationMode ? [0, 1, 2] : [0, 2]);
@@ -529,7 +515,7 @@ class DeviceErv extends EventEmitter {
529
515
  button.state = (hideOutdoorTemperature === true);
530
516
  break;
531
517
  default: //Unknown button
532
- this.emit('message', `Unknown button mode: ${mode} detected.`);
518
+ this.emit('warn', `Unknown button mode: ${mode} detected.`);
533
519
  break;
534
520
  };
535
521
 
@@ -571,7 +557,7 @@ class DeviceErv extends EventEmitter {
571
557
  this.emit('publishAccessory', accessory);
572
558
  this.startPrepareAccessory = false;
573
559
  } catch (error) {
574
- this.emit('error', `Prepare accessory error: ${error}`);
560
+ this.emit('error', error);
575
561
  };
576
562
  })
577
563
  .on('message', (message) => {
@@ -595,7 +581,7 @@ class DeviceErv extends EventEmitter {
595
581
 
596
582
  return true;
597
583
  } catch (error) {
598
- throw new Error(`start error: ${error}`);
584
+ throw new Error(`Start error: ${error}`);
599
585
  };
600
586
  };
601
587
 
@@ -1268,7 +1254,7 @@ class DeviceErv extends EventEmitter {
1268
1254
 
1269
1255
  return accessory;
1270
1256
  } catch (error) {
1271
- throw new Error(error.message ?? error);
1257
+ throw new Error(`Prepare accessory error: ${error.message || error}`);
1272
1258
  };
1273
1259
  };
1274
1260
  };
package/src/melcloud.js CHANGED
@@ -36,7 +36,7 @@ class MelCloud extends EventEmitter {
36
36
  try {
37
37
  await this.chackDevicesList(this.contextKey);
38
38
  } catch (error) {
39
- this.emit('error', `Check devices list: ${error}.`);
39
+ this.emit('error', `Impulse generator error: ${error}.`);
40
40
  };
41
41
  }).on('state', (state) => { });
42
42
  };
@@ -114,7 +114,7 @@ class MelCloud extends EventEmitter {
114
114
 
115
115
  return obj;
116
116
  } catch (error) {
117
- throw new Error(`Connect to MELCloud error: ${error.message ?? error}.`);
117
+ throw new Error(`Connect to MELCloud error: ${error.message || error}.`);
118
118
  };
119
119
  }
120
120
 
@@ -179,7 +179,7 @@ class MelCloud extends EventEmitter {
179
179
 
180
180
  return devices;
181
181
  } catch (error) {
182
- throw new Error(`Scanning for devices error: ${error.message ?? error}.`);
182
+ throw new Error(`Check devices list error: ${error.message || error}.`);
183
183
  };
184
184
  }
185
185
 
@@ -189,7 +189,7 @@ class MelCloud extends EventEmitter {
189
189
  const debug3 = this.enableDebugMode ? this.emit('debug', `Data saved to: ${path}.`) : false;
190
190
  return true;
191
191
  } catch (error) {
192
- throw new Error(`Save data error: ${error.message ?? error}`);
192
+ throw new Error(`Save data error: ${error.message || error}`);
193
193
  }
194
194
  }
195
195
 
@@ -203,7 +203,7 @@ class MelCloud extends EventEmitter {
203
203
  await this.saveData(this.accountFile, accountInfo);
204
204
  return true;
205
205
  } catch (error) {
206
- throw new Error(error.message ?? error);
206
+ throw new Error(`Send data error: ${error.message || error}`);
207
207
  };
208
208
  };
209
209
  };
@@ -37,7 +37,7 @@ class MelCloudAta extends EventEmitter {
37
37
  try {
38
38
  await this.checkState();
39
39
  } catch (error) {
40
- this.emit('error', `Impulse generator check state error: ${error.message || error}.`);
40
+ this.emit('error', `Impulse generator error: ${error}.`);
41
41
  };
42
42
  }).on('state', (state) => { });
43
43
  };
@@ -363,7 +363,7 @@ class MelCloudAta extends EventEmitter {
363
363
  const data = savedData.length > 0 ? JSON.parse(savedData) : false;
364
364
  return data;
365
365
  } catch (error) {
366
- throw new Error(`Read data error: ${error.message ?? error}`);
366
+ throw new Error(`Read data error: ${error.message || error}`);
367
367
  }
368
368
  }
369
369
 
@@ -432,7 +432,7 @@ class MelCloudAta extends EventEmitter {
432
432
  this.emit('deviceState', deviceData);
433
433
  return true;
434
434
  } catch (error) {
435
- throw new Error(error.message ?? error);
435
+ throw new Error(`Send data error: ${error.message || error}`);
436
436
  };
437
437
  };
438
438
  };
@@ -37,7 +37,7 @@ class MelCloudAtw extends EventEmitter {
37
37
  try {
38
38
  await this.checkState();
39
39
  } catch (error) {
40
- this.emit('error', `Impulse generator check state error: ${error.message || error}.`);
40
+ this.emit('error', `Impulse generator error: ${error}.`);
41
41
  };
42
42
  }).on('state', (state) => { });
43
43
  };
@@ -427,7 +427,7 @@ class MelCloudAtw extends EventEmitter {
427
427
  const data = savedData.length > 0 ? JSON.parse(savedData) : false;
428
428
  return data;
429
429
  } catch (error) {
430
- throw new Error(`Read data error: ${error.message ?? error}`);
430
+ throw new Error(`Read data error: ${error.message || error}`);
431
431
  }
432
432
  }
433
433
 
@@ -483,7 +483,7 @@ class MelCloudAtw extends EventEmitter {
483
483
  this.emit('deviceState', deviceData);
484
484
  return true;
485
485
  } catch (error) {
486
- throw new Error(error.message ?? error);
486
+ throw new Error(`Send data error: ${error.message || error}`);
487
487
  };
488
488
  };
489
489
  };
@@ -37,7 +37,7 @@ class MelCloudErv extends EventEmitter {
37
37
  try {
38
38
  await this.checkState();
39
39
  } catch (error) {
40
- this.emit('error', `Impulse generator check state error: ${error.message || error}.`);
40
+ this.emit('error', `Impulse generator error: ${error}.`);
41
41
  };
42
42
  }).on('state', (state) => { });
43
43
  };
@@ -351,9 +351,10 @@ class MelCloudErv extends EventEmitter {
351
351
  const data = savedData.length > 0 ? JSON.parse(savedData) : false;
352
352
  return data;;
353
353
  } catch (error) {
354
- throw new Error(`Read data error: ${error.message ?? error}`);
354
+ throw new Error(`Read data error: ${error.message || error}`);
355
355
  }
356
356
  }
357
+
357
358
  async send(deviceData, displayMode) {
358
359
  try {
359
360
  //set target temp based on display mode and ventilation mode
@@ -404,7 +405,7 @@ class MelCloudErv extends EventEmitter {
404
405
  this.emit('deviceState', deviceData);
405
406
  return true;
406
407
  } catch (error) {
407
- throw new Error(error.message ?? error);
408
+ throw new Error(`Send data error: ${error.message || error}`);
408
409
  };
409
410
  };
410
411
  };
package/src/mqtt.js CHANGED
@@ -32,11 +32,11 @@ class Mqtt extends EventEmitter {
32
32
  const value = Object.values(obj)[0];
33
33
  this.emit('set', key, value);
34
34
  } catch (error) {
35
- this.emit('error', `MQTT Parse object error: ${error}`);
35
+ this.emit('error', `MQTT Parse object error: ${error.message || error}`);
36
36
  };
37
37
  });
38
38
  } catch (error) {
39
- this.emit('error', `MQTT Connect error: ${error}`);
39
+ this.emit('error', `MQTT Connect error: ${error.message || error}`);
40
40
  };
41
41
  }).on('publish', async (topic, message) => {
42
42
  try {
@@ -45,7 +45,7 @@ class Mqtt extends EventEmitter {
45
45
  await this.mqttClient.publish(fullTopic, publishMessage);
46
46
  const emitDebug = config.debug ? this.emit('debug', `MQTT Publish topic: ${fullTopic}, message: ${publishMessage}`) : false;
47
47
  } catch (error) {
48
- this.emit('error', `MQTT Publish error: ${error}`);
48
+ this.emit('error', `MQTT Publish error: ${error.message || error}`);
49
49
  };
50
50
  });
51
51
 
package/src/restful.js CHANGED
@@ -43,7 +43,7 @@ class RestFul extends EventEmitter {
43
43
  });
44
44
 
45
45
  } catch (error) {
46
- this.emit('error', `RESTful Connect error: ${error}`)
46
+ this.emit('error', `RESTful Connect error: ${error.message || error}`)
47
47
  }
48
48
  };
49
49
 
@@ -56,7 +56,7 @@ class RestFul extends EventEmitter {
56
56
  this.restFulData.state = data;
57
57
  break;
58
58
  default:
59
- this.emit('error', `RESTFul update path: ${path}, data: ${data}`)
59
+ this.emit('error', `Unknown RESTFul update path: ${path}, data: ${data}`)
60
60
  break;
61
61
  };
62
62
  const emitDebug = this.restFulDebug ? this.emit('debug', `RESTFul update path: ${path}, data: ${data}`) : false;