homebridge-melcloud-control 3.3.4 → 3.3.8

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/src/deviceatw.js CHANGED
@@ -40,7 +40,6 @@ class DeviceAtw extends EventEmitter {
40
40
  this.deviceTypeText = deviceTypeText;
41
41
  this.devicesFile = devicesFile;
42
42
  this.refreshInterval = refreshInterval;
43
- this.useFahrenheit = useFahrenheit;
44
43
  this.startPrepareAccessory = true;
45
44
  this.displayDeviceInfo = true;
46
45
 
@@ -98,6 +97,8 @@ class DeviceAtw extends EventEmitter {
98
97
 
99
98
  //accessory
100
99
  this.accessory = { zones: [{}, {}, {}, {}] };
100
+ this.accessory.useFahrenheit = useFahrenheit ? 1 : 0;
101
+ this.accessory.temperatureUnit = CONSTANTS.TemperatureDisplayUnits[this.accessory.useFahrenheit];
101
102
  };
102
103
 
103
104
  async start() {
@@ -213,7 +214,6 @@ class DeviceAtw extends EventEmitter {
213
214
  })
214
215
  .on('deviceState', async (deviceData) => {
215
216
  //device info
216
- const displayMode = this.displayMode;
217
217
  const heatPumpName = 'Heat Pump';
218
218
  const hotWaterName = 'Hot Water';
219
219
  const zone1Name = deviceData.Zone1Name ?? 'Zone 1';
@@ -224,7 +224,6 @@ class DeviceAtw extends EventEmitter {
224
224
  const canCool = deviceData.Device.CanCool ?? false;
225
225
  const heatCoolModes = canHeat && canCool ? 0 : canHeat ? 1 : canCool ? 2 : 3;
226
226
  const temperatureIncrement = deviceData.Device.TemperatureIncrement ?? 1;
227
- const temperatureUnit = CONSTANTS.TemperatureDisplayUnits[this.useFahrenheit];
228
227
  const minSetTemperature = deviceData.Device.MinSetTemperature ?? 10;
229
228
  const maxSetTemperature = deviceData.Device.MaxSetTemperature ?? 30;
230
229
  const maxTankTemperature = deviceData.Device.MaxTankTemperature ?? 70;
@@ -286,8 +285,6 @@ class DeviceAtw extends EventEmitter {
286
285
  this.accessory.unitStatus = unitStatus;
287
286
  this.accessory.idleZone1 = idleZone1;
288
287
  this.accessory.idleZone2 = idleZone2;
289
- this.accessory.useFahrenheit = this.useFahrenheit;
290
- this.accessory.temperatureUnit = temperatureUnit;
291
288
  this.accessory.temperatureIncrement = temperatureIncrement;
292
289
  this.accessory.hasHotWaterTank = hasHotWaterTank;
293
290
  this.accessory.hasZone2 = hasZone2;
@@ -305,10 +302,10 @@ class DeviceAtw extends EventEmitter {
305
302
  let operationModeSetPropsMaxValue = 3;
306
303
  let operationModeSetPropsValidValues = [0];
307
304
  let temperatureSetPropsMinValue = -35;
308
- let temperatureSetPropsMaxValue = 140;
305
+ let temperatureSetPropsMaxValue = 100;
309
306
 
310
307
  for (let i = 0; i < zonesCount; i++) {
311
- switch (displayMode) {
308
+ switch (this.displayMode) {
312
309
  case 1: //Heater Cooler
313
310
  switch (i) {
314
311
  case 0: //Heat Pump Operation Mode - IDLE, HOT WATER, HEATING ZONES, COOLING, HOT WATER STORAGE, FREEZE STAT, LEGIONELLA, HEATING ECO, MODE 1, MODE 2, MODE 3, HEATING UP /// Unit Status - HEAT, COOL
@@ -331,8 +328,28 @@ class DeviceAtw extends EventEmitter {
331
328
  name = zone1Name;
332
329
  currentOperationMode = !power ? 0 : idleZone1 ? 1 : [2, 2, 2, 3, 3, 2][operationModeZone1]; //INACTIVE, IDLE, HEATING, COOLING
333
330
  targetOperationMode = [1, 2, 0, 1, 2, 1][operationModeZone1]; //AUTO, HEAT, COOL
334
- roomTemperature = roomTemperatureZone1;
335
- setTemperature = setTemperatureZone1;
331
+
332
+ switch (operationModeZone1) {
333
+ case 1: //HEAT FLOW
334
+ setTemperature = setHeatFlowTemperatureZone1;
335
+ roomTemperature = flowTemperatureZone1;
336
+ temperatureSetPropsMinValue = 25;
337
+ temperatureSetPropsMaxValue = 60;
338
+ break;
339
+ case 4: //COOL FLOW
340
+ setTemperature = setCoolFlowTemperatureZone1;
341
+ roomTemperature = flowTemperatureZone1;
342
+ temperatureSetPropsMinValue = 16;
343
+ temperatureSetPropsMaxValue = 31;
344
+ break;
345
+ default:
346
+ setTemperature = setTemperatureZone1;
347
+ roomTemperature = roomTemperatureZone1;
348
+ temperatureSetPropsMinValue = 10;
349
+ temperatureSetPropsMaxValue = 31;
350
+ break
351
+ };
352
+
336
353
  lockPhysicalControl = prohibitZone1 ? 1 : 0;
337
354
  flowTemperature = flowTemperatureZone1;
338
355
  returnTemperature = returnTemperatureZone1;
@@ -340,8 +357,6 @@ class DeviceAtw extends EventEmitter {
340
357
  operationModeSetPropsMinValue = [0, 0, 1, 0][heatCoolModes];
341
358
  operationModeSetPropsMaxValue = [2, 2, 2, 0][heatCoolModes];
342
359
  operationModeSetPropsValidValues = [[0, 1, 2], [0, 1, 2], [1, 2], [0]][heatCoolModes];
343
- temperatureSetPropsMinValue = 0;
344
- temperatureSetPropsMaxValue = 31;
345
360
  break;
346
361
  case caseHotWater: //Hot Water - NORMAL, HEAT NOW
347
362
  name = hotWaterName;
@@ -363,8 +378,28 @@ class DeviceAtw extends EventEmitter {
363
378
  name = zone2Name;
364
379
  currentOperationMode = !power ? 0 : idleZone2 ? 1 : [2, 2, 2, 3, 3, 2][operationModeZone2]; //INACTIVE, IDLE, HEATING, COOLING
365
380
  targetOperationMode = [1, 2, 0, 1, 2, 1][operationModeZone2]; //AUTO, HEAT, COOL
366
- roomTemperature = roomTemperatureZone2;
367
- setTemperature = setTemperatureZone2;
381
+
382
+ switch (operationModeZone2) {
383
+ case 1: //HEAT FLOW
384
+ setTemperature = setHeatFlowTemperatureZone2;
385
+ roomTemperature = flowTemperatureZone2;
386
+ temperatureSetPropsMinValue = 25;
387
+ temperatureSetPropsMaxValue = 60;
388
+ break;
389
+ case 4: //COOL FLOW
390
+ setTemperature = setCoolFlowTemperatureZone2;
391
+ roomTemperature = flowTemperatureZone2;
392
+ temperatureSetPropsMinValue = 16;
393
+ temperatureSetPropsMaxValue = 31;
394
+ break;
395
+ default:
396
+ setTemperature = setTemperatureZone2;
397
+ roomTemperature = roomTemperatureZone2;
398
+ temperatureSetPropsMinValue = 10;
399
+ temperatureSetPropsMaxValue = 31;
400
+ break
401
+ };
402
+
368
403
  lockPhysicalControl = prohibitZone2 ? 1 : 0;
369
404
  flowTemperature = flowTemperatureZone2;
370
405
  returnTemperature = returnTemperatureZone2;
@@ -372,8 +407,6 @@ class DeviceAtw extends EventEmitter {
372
407
  operationModeSetPropsMinValue = [0, 0, 1, 0][heatCoolModes];
373
408
  operationModeSetPropsMaxValue = [2, 2, 2, 0][heatCoolModes];
374
409
  operationModeSetPropsValidValues = [[0, 1, 2], [0, 1, 2], [1, 2], [0]][heatCoolModes];
375
- temperatureSetPropsMinValue = 0;
376
- temperatureSetPropsMaxValue = 31;
377
410
  break;
378
411
  default: //unknown zone detected
379
412
  this.emit('message', `Unknown zone: ${i} detected.`);
@@ -383,14 +416,14 @@ class DeviceAtw extends EventEmitter {
383
416
  //update characteristics
384
417
  if (this.melCloudServices) {
385
418
  this.melCloudServices[i]
386
- .updateCharacteristic(Characteristic.Active, power ? 1 : 0)
419
+ .updateCharacteristic(Characteristic.Active, power)
387
420
  .updateCharacteristic(Characteristic.CurrentHeaterCoolerState, currentOperationMode)
388
421
  .updateCharacteristic(Characteristic.TargetHeaterCoolerState, targetOperationMode)
389
422
  .updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature)
390
423
  .updateCharacteristic(Characteristic.LockPhysicalControls, lockPhysicalControl)
391
424
  .updateCharacteristic(Characteristic.TemperatureDisplayUnits, this.accessory.useFahrenheit);
392
- const updateHT = heatCoolModes === 0 || heatCoolModes === 1 ? this.melCloudServices[i].updateCharacteristic(Characteristic.HeatingThresholdTemperature, setTemperature) : false;
393
- const updateCT = heatCoolModes === 0 || heatCoolModes === 2 ? this.melCloudServices[i].updateCharacteristic(Characteristic.CoolingThresholdTemperature, setTemperature) : false;
425
+ const updateDefHeat = heatCoolModes === 0 || heatCoolModes === 1 ? this.melCloudServices[i].updateCharacteristic(Characteristic.HeatingThresholdTemperature, setTemperature) : false;
426
+ const updateDefCool = heatCoolModes === 0 || heatCoolModes === 2 ? this.melCloudServices[i].updateCharacteristic(Characteristic.CoolingThresholdTemperature, setTemperature) : false;
394
427
  }
395
428
  break;
396
429
  case 2: //Thermostat
@@ -404,21 +437,38 @@ class DeviceAtw extends EventEmitter {
404
437
  operationModeSetPropsMinValue = [0, 0, 0, 0][heatCoolModes];
405
438
  operationModeSetPropsMaxValue = [2, 1, 2, 0][heatCoolModes];
406
439
  operationModeSetPropsValidValues = [[0, 1, 2], [0, 1], [0, 2], [0]][heatCoolModes];
407
- temperatureSetPropsMinValue = -35;
408
- temperatureSetPropsMaxValue = 100;
440
+ temperatureSetPropsMinValue = 10;
441
+ temperatureSetPropsMaxValue = 70;
409
442
  this.accessory.zones[i].name = heatPumpName;
410
443
  break;
411
444
  case 1: //Zone 1 - HEAT THERMOSTAT, HEAT FLOW, HEAT CURVE, COOL THERMOSTAT, COOL FLOW, FLOOR DRY UP
412
445
  currentOperationMode = !power ? 0 : idleZone1 ? 0 : [1, 1, 1, 2, 2, 1][operationModeZone1]; //OFF, HEAT, COOL
413
446
  targetOperationMode = [1, 2, 3, 1, 2, 1][operationModeZone1]; //OFF, HEAT, COOL, AUTO
414
- roomTemperature = roomTemperatureZone1;
415
- setTemperature = setTemperatureZone1;
447
+
448
+ switch (operationModeZone1) {
449
+ case 1: //HEAT FLOW
450
+ setTemperature = setHeatFlowTemperatureZone1;
451
+ roomTemperature = flowTemperatureZone1;
452
+ temperatureSetPropsMinValue = 25;
453
+ temperatureSetPropsMaxValue = 60;
454
+ break;
455
+ case 4: //COOL FLOW
456
+ setTemperature = setCoolFlowTemperatureZone1;
457
+ roomTemperature = flowTemperatureZone1;
458
+ temperatureSetPropsMinValue = 16;
459
+ temperatureSetPropsMaxValue = 31;
460
+ break;
461
+ default:
462
+ setTemperature = setTemperatureZone1;
463
+ roomTemperature = roomTemperatureZone1;
464
+ temperatureSetPropsMinValue = 10;
465
+ temperatureSetPropsMaxValue = 31;
466
+ break
467
+ };
416
468
 
417
469
  operationModeSetPropsMinValue = [1, 1, 1, 0][heatCoolModes];
418
470
  operationModeSetPropsMaxValue = [3, 3, 2, 0][heatCoolModes];
419
471
  operationModeSetPropsValidValues = [[1, 2, 3], [1, 2, 3], [1, 2], [0]][heatCoolModes];
420
- temperatureSetPropsMinValue = 0;
421
- temperatureSetPropsMaxValue = 31;
422
472
  this.accessory.zones[i].name = heatPumpName;
423
473
  break;
424
474
  case caseHotWater: //Hot Water - NORMAL, HEAT NOW
@@ -437,14 +487,31 @@ class DeviceAtw extends EventEmitter {
437
487
  case caseZone2: //Zone 2 - HEAT THERMOSTAT, HEAT FLOW, HEAT CURVE, COOL THERMOSTAT, COOL FLOW, FLOOR DRY UP
438
488
  currentOperationMode = !power ? 0 : idleZone2 ? 0 : [1, 1, 1, 2, 2, 1][operationModeZone2]; //OFF, HEAT, COOL
439
489
  targetOperationMode = [1, 2, 3, 1, 2, 1][operationModeZone2]; //OFF, HEAT, COOL, AUTO
440
- roomTemperature = roomTemperatureZone2;
441
- setTemperature = setTemperatureZone2;
490
+
491
+ switch (operationModeZone2) {
492
+ case 1: //HEAT FLOW
493
+ setTemperature = setHeatFlowTemperatureZone2;
494
+ roomTemperature = flowTemperatureZone2;
495
+ temperatureSetPropsMinValue = 25;
496
+ temperatureSetPropsMaxValue = 60;
497
+ break;
498
+ case 4: //COOL FLOW
499
+ setTemperature = setCoolFlowTemperatureZone2;
500
+ roomTemperature = flowTemperatureZone2;
501
+ temperatureSetPropsMinValue = 16;
502
+ temperatureSetPropsMaxValue = 31;
503
+ break;
504
+ default:
505
+ setTemperature = setTemperatureZone2;
506
+ roomTemperature = roomTemperatureZone2;
507
+ temperatureSetPropsMinValue = 10;
508
+ temperatureSetPropsMaxValue = 31;
509
+ break
510
+ };
442
511
 
443
512
  operationModeSetPropsMinValue = [1, 1, 1, 0][heatCoolModes];
444
513
  operationModeSetPropsMaxValue = [3, 3, 2, 0][heatCoolModes];
445
514
  operationModeSetPropsValidValues = [[1, 2, 3], [1, 2, 3], [1, 2], [0]][heatCoolModes];
446
- temperatureSetPropsMinValue = 0;
447
- temperatureSetPropsMaxValue = 31;
448
515
  this.accessory.zones[i].name = heatPumpName;
449
516
  break;
450
517
  default: //unknown zone detected
@@ -473,14 +540,14 @@ class DeviceAtw extends EventEmitter {
473
540
  this.accessory.zones[i].lockPhysicalControl = lockPhysicalControl;
474
541
  this.accessory.zones[i].flowTemperature = flowTemperature;
475
542
  this.accessory.zones[i].returnTemperature = returnTemperature;
543
+ this.accessory.zones[i].temperaturesSetPropsMinValue = temperatureSetPropsMinValue;
544
+ this.accessory.zones[i].temperaturesSetPropsMaxValue = temperatureSetPropsMaxValue;
476
545
 
477
546
  //only on first run
478
547
  if (this.startPrepareAccessory) {
479
548
  this.accessory.zones[i].operationModesSetPropsMinValue = operationModeSetPropsMinValue;
480
549
  this.accessory.zones[i].operationModesSetPropsMaxValue = operationModeSetPropsMaxValue;
481
550
  this.accessory.zones[i].operationModesSetPropsValidValues = operationModeSetPropsValidValues;
482
- this.accessory.zones[i].temperaturesSetPropsMinValue = temperatureSetPropsMinValue;
483
- this.accessory.zones[i].temperaturesSetPropsMaxValue = temperatureSetPropsMaxValue;
484
551
  };
485
552
 
486
553
  //update temperature sensors
@@ -558,40 +625,40 @@ class DeviceAtw extends EventEmitter {
558
625
  case 0: //Heat Pump - HEAT, COOL, OFF
559
626
  this.emit('message', `${heatPumpName}, Power: ${power ? 'ON' : 'OFF'}`)
560
627
  this.emit('message', `${heatPumpName}, Operation mode: ${CONSTANTS.HeatPump.System[unitStatus]}`);
561
- this.emit('message', `${heatPumpName},'Outdoor temperature: ${roomTemperature}${temperatureUnit}`);
562
- const info = flowTemperature !== null ? this.emit('message', `${heatPumpName}, Flow temperature: ${flowTemperature}${temperatureUnit}`) : false;
563
- const info1 = returnTemperature !== null ? this.emit('message', `${heatPumpName}, Return temperature: ${returnTemperature}${temperatureUnit}`) : false;
564
- this.emit('message', `${heatPumpName}, Temperature display unit: ${temperatureUnit}`);
628
+ this.emit('message', `${heatPumpName},'Outdoor temperature: ${roomTemperature}${this.accessory.temperatureUnit}`);
629
+ const info = flowTemperature !== null ? this.emit('message', `${heatPumpName}, Flow temperature: ${flowTemperature}${this.accessory.temperatureUnit}`) : false;
630
+ const info1 = returnTemperature !== null ? this.emit('message', `${heatPumpName}, Return temperature: ${returnTemperature}${this.accessory.temperatureUnit}`) : false;
631
+ this.emit('message', `${heatPumpName}, Temperature display unit: ${this.accessory.temperatureUnit}`);
565
632
  this.emit('message', `${heatPumpName}, Lock physical controls: ${lockPhysicalControl ? 'LOCKED' : 'UNLOCKED'}`);
566
633
  break;
567
634
  case 1: //Zone 1 - HEAT THERMOSTAT, HEAT FLOW, HEAT CURVE, COOL THERMOSTAT, COOL FLOW, FLOOR DRY UP
568
635
  operationModeText = idleZone1 ? CONSTANTS.HeatPump.ZoneOperation[6] : CONSTANTS.HeatPump.ZoneOperation[operationModeZone1];
569
636
  this.emit('message', `${zone1Name}, Operation mode: ${operationModeText}`);
570
- this.emit('message', `${zone1Name}, Temperature: ${roomTemperature}${temperatureUnit}`);
571
- this.emit('message', `${zone1Name}, Target temperature: ${setTemperature}${temperatureUnit}`)
572
- const info2 = flowTemperatureZone1 !== null ? this.emit('message', `${zone1Name}, Flow temperature: ${flowTemperatureZone1}${temperatureUnit}`) : false;
573
- const info3 = returnTemperatureZone1 !== null ? this.emit('message', `${zone1Name}, Return temperature: ${returnTemperatureZone1}${temperatureUnit}`) : false;
574
- this.emit('message', `${zone1Name}, Temperature display unit: ${temperatureUnit}`);
637
+ this.emit('message', `${zone1Name}, Temperature: ${roomTemperature}${this.accessory.temperatureUnit}`);
638
+ this.emit('message', `${zone1Name}, Target temperature: ${setTemperature}${this.accessory.temperatureUnit}`)
639
+ const info2 = flowTemperatureZone1 !== null ? this.emit('message', `${zone1Name}, Flow temperature: ${flowTemperatureZone1}${this.accessory.temperatureUnit}`) : false;
640
+ const info3 = returnTemperatureZone1 !== null ? this.emit('message', `${zone1Name}, Return temperature: ${returnTemperatureZone1}${this.accessory.temperatureUnit}`) : false;
641
+ this.emit('message', `${zone1Name}, Temperature display unit: ${this.accessory.temperatureUnit}`);
575
642
  this.emit('message', `${zone1Name}, Lock physical controls: ${lockPhysicalControl ? 'LOCKED' : 'UNLOCKED'}`);
576
643
  break;
577
644
  case caseHotWater: //Hot Water - AUTO, HEAT NOW
578
645
  operationModeText = operationMode === 1 ? CONSTANTS.HeatPump.ForceDhw[1] : CONSTANTS.HeatPump.ForceDhw[forcedHotWaterMode ? 1 : 0];
579
646
  this.emit('message', `${hotWaterName}, Operation mode: ${operationModeText}`);
580
- this.emit('message', `${hotWaterName}, Temperature: ${roomTemperature}${temperatureUnit}`);
581
- this.emit('message', `${hotWaterName}, Target temperature: ${setTemperature}${temperatureUnit}`)
582
- const info4 = flowTemperatureWaterTank !== null ? this.emit('message', `${hotWaterName}, Flow temperature: ${flowTemperatureWaterTank}${temperatureUnit}`) : false;
583
- const info5 = returnTemperatureWaterTank !== null ? this.emit('message', `${hotWaterName}, Return temperature: ${returnTemperatureWaterTank}${temperatureUnit}`) : false;
584
- this.emit('message', `${hotWaterName}, Temperature display unit: ${temperatureUnit}`);
647
+ this.emit('message', `${hotWaterName}, Temperature: ${roomTemperature}${this.accessory.temperatureUnit}`);
648
+ this.emit('message', `${hotWaterName}, Target temperature: ${setTemperature}${this.accessory.temperatureUnit}`)
649
+ const info4 = flowTemperatureWaterTank !== null ? this.emit('message', `${hotWaterName}, Flow temperature: ${flowTemperatureWaterTank}${this.accessory.temperatureUnit}`) : false;
650
+ const info5 = returnTemperatureWaterTank !== null ? this.emit('message', `${hotWaterName}, Return temperature: ${returnTemperatureWaterTank}${this.accessory.temperatureUnit}`) : false;
651
+ this.emit('message', `${hotWaterName}, Temperature display unit: ${this.accessory.temperatureUnit}`);
585
652
  this.emit('message', `${hotWaterName}, Lock physical controls: ${lockPhysicalControl ? 'LOCKED' : 'UNLOCKED'}`);
586
653
  break;
587
654
  case caseZone2: //Zone 2 - HEAT THERMOSTAT, HEAT FLOW, HEAT CURVE, COOL THERMOSTAT, COOL FLOW, FLOOR DRY UP
588
655
  operationModeText = idleZone2 ? CONSTANTS.HeatPump.ZoneOperation[6] : CONSTANTS.HeatPump.ZoneOperation[operationModeZone2];
589
656
  this.emit('message', `${zone2Name}, Operation mode: ${operationModeText}`);
590
- this.emit('message', `${zone2Name}, Temperature: ${roomTemperature}${temperatureUnit}`);
591
- this.emit('message', `${zone2Name}, Target temperature: ${setTemperature}${temperatureUnit}`)
592
- const info6 = flowTemperatureZone2 !== null ? this.emit('message', `${zone2Name}, Flow temperature: ${flowTemperatureZone2}${temperatureUnit}`) : false;
593
- const info7 = roomTemperatureZone2 !== null ? this.emit('message', `${zone2Name}, Return temperature: ${roomTemperatureZone2}${temperatureUnit}`) : false;
594
- this.emit('message', `${zone2Name}, Temperature display unit: ${temperatureUnit}`);
657
+ this.emit('message', `${zone2Name}, Temperature: ${roomTemperature}${this.accessory.temperatureUnit}`);
658
+ this.emit('message', `${zone2Name}, Target temperature: ${setTemperature}${this.accessory.temperatureUnit}`)
659
+ const info6 = flowTemperatureZone2 !== null ? this.emit('message', `${zone2Name}, Flow temperature: ${flowTemperatureZone2}${this.accessory.temperatureUnit}`) : false;
660
+ const info7 = roomTemperatureZone2 !== null ? this.emit('message', `${zone2Name}, Return temperature: ${roomTemperatureZone2}${this.accessory.temperatureUnit}`) : false;
661
+ this.emit('message', `${zone2Name}, Temperature display unit: ${this.accessory.temperatureUnit}`);
595
662
  this.emit('message', `${zone2Name}, Lock physical controls: ${lockPhysicalControl ? 'LOCKED' : 'UNLOCKED'}`);
596
663
  break;
597
664
  };
@@ -869,7 +936,6 @@ class DeviceAtw extends EventEmitter {
869
936
  .setCharacteristic(Characteristic.FirmwareRevision, this.firmwareRevision);
870
937
 
871
938
  //melcloud services
872
- const displayMode = this.displayMode;
873
939
  const zonesCount = this.zonesCount;
874
940
  const caseHotWater = this.caseHotWater;
875
941
  const caseZone2 = this.caseZone2;
@@ -889,13 +955,13 @@ class DeviceAtw extends EventEmitter {
889
955
  for (let i = 0; i < zonesCount; i++) {
890
956
  const zoneName = this.accessory.zones[i].name
891
957
  const serviceName = `${deviceTypeText} ${accessoryName}: ${zoneName}`;
892
- switch (displayMode) {
958
+ switch (this.displayMode) {
893
959
  case 1: //Heater Cooler
894
960
  const debug = this.enableDebugMode ? this.emit('debug', `Prepare heather/cooler ${zoneName} service`) : false;
895
961
  const melCloudService = new Service.HeaterCooler(serviceName, `HeaterCooler ${deviceId} ${i}`);
896
962
  melCloudService.getCharacteristic(Characteristic.Active)
897
963
  .onGet(async () => {
898
- const state = this.accessory.power;
964
+ const state = deviceData.Device.Power;
899
965
  return state;
900
966
  })
901
967
  .onSet(async (state) => {
@@ -1019,46 +1085,6 @@ class DeviceAtw extends EventEmitter {
1019
1085
  const value = this.accessory.zones[i].roomTemperature;
1020
1086
  return value;
1021
1087
  });
1022
- //device can heat/cool or only heat
1023
- if (heatCoolModes === 0 || heatCoolModes === 1) {
1024
- melCloudService.getCharacteristic(Characteristic.HeatingThresholdTemperature)
1025
- .setProps({
1026
- minValue: this.accessory.zones[i].temperaturesSetPropsMinValue,
1027
- maxValue: this.accessory.zones[i].temperaturesSetPropsMaxValue,
1028
- minStep: this.accessory.temperatureIncrement
1029
- })
1030
- .onGet(async () => {
1031
- const value = this.accessory.zones[i].setTemperature;
1032
- return value;
1033
- })
1034
- .onSet(async (value) => {
1035
- try {
1036
- switch (i) {
1037
- case 0: //Heat Pump
1038
- //deviceData.Device.SetTemperatureZone1 = value;
1039
- //deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetTemperatureZone1;
1040
- break;
1041
- case 1: //Zone 1
1042
- deviceData.Device.SetTemperatureZone1 = value;
1043
- deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetTemperatureZone1;
1044
- break;
1045
- case caseHotWater: //Hot Water
1046
- deviceData.Device.SetTankWaterTemperature = value;
1047
- deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetTankWaterTemperature;
1048
- break;
1049
- case caseZone2: //Zone 2
1050
- deviceData.Device.SetTemperatureZone2 = value;
1051
- deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetTemperatureZone2;
1052
- break;
1053
- };
1054
-
1055
- const set = i > 0 ? await this.melCloudAtw.send(deviceData) : false;
1056
- const info = this.disableLogInfo || i === 0 ? false : this.emit('message', `${zoneName}, Set heating threshold temperature: ${value}${this.accessory.temperatureUnit}`);
1057
- } catch (error) {
1058
- this.emit('warn', `${zoneName}, Set heating threshold temperature error: ${error}`);
1059
- };
1060
- });
1061
- };
1062
1088
  //only for heat/cool, only cool and not for hot water tank
1063
1089
  if ((heatCoolModes === 0 || heatCoolModes === 2) && i !== caseHotWater) {
1064
1090
  melCloudService.getCharacteristic(Characteristic.CoolingThresholdTemperature)
@@ -1079,16 +1105,40 @@ class DeviceAtw extends EventEmitter {
1079
1105
  //deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetTemperatureZone1;
1080
1106
  break;
1081
1107
  case 1: //Zone 1
1082
- deviceData.Device.SetTemperatureZone1 = value;
1083
- deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetTemperatureZone1;
1108
+ switch (deviceData.Device.OperationModeZone1) {
1109
+ case 1: //HEAT FLOW
1110
+ deviceData.Device.SetHeatFlowTemperatureZone1 = value;
1111
+ deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetHeatFlowTemperatureZone1;
1112
+ break;
1113
+ case 4: //COOL FLOW
1114
+ deviceData.Device.SetCoolFlowTemperatureZone1 = value;
1115
+ deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetCoolFlowTemperatureZone1;
1116
+ break;
1117
+ default:
1118
+ deviceData.Device.SetTemperatureZone1 = value;
1119
+ deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetTemperatureZone1;
1120
+ break
1121
+ };
1084
1122
  break;
1085
1123
  case caseHotWater: //Hot Water
1086
1124
  deviceData.Device.SetTankWaterTemperature = value;
1087
1125
  deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetTankWaterTemperature;
1088
1126
  break;
1089
1127
  case caseZone2: //Zone 2
1090
- deviceData.Device.SetTemperatureZone2 = value;
1091
- deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetTemperatureZone2;
1128
+ switch (deviceData.Device.OperationModeZone2) {
1129
+ case 1: //HEAT FLOW
1130
+ deviceData.Device.SetHeatFlowTemperatureZone2 = value;
1131
+ deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetHeatFlowTemperatureZone2;
1132
+ break;
1133
+ case 4: //COOL FLOW
1134
+ deviceData.Device.SetCoolFlowTemperatureZone2 = value;
1135
+ deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetCoolFlowTemperatureZone2;
1136
+ break;
1137
+ default:
1138
+ deviceData.Device.SetTemperatureZone2 = value;
1139
+ deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetTemperatureZone2;
1140
+ break
1141
+ };
1092
1142
  break;
1093
1143
  };
1094
1144
 
@@ -1099,6 +1149,68 @@ class DeviceAtw extends EventEmitter {
1099
1149
  };
1100
1150
  });
1101
1151
  };
1152
+ //device can heat/cool or only heat
1153
+ melCloudService.getCharacteristic(Characteristic.HeatingThresholdTemperature)
1154
+ .setProps({
1155
+ minValue: this.accessory.zones[i].temperaturesSetPropsMinValue,
1156
+ maxValue: this.accessory.zones[i].temperaturesSetPropsMaxValue,
1157
+ minStep: this.accessory.temperatureIncrement
1158
+ })
1159
+ .onGet(async () => {
1160
+ const value = this.accessory.zones[i].setTemperature;
1161
+ return value;
1162
+ })
1163
+ .onSet(async (value) => {
1164
+ try {
1165
+ switch (i) {
1166
+ case 0: //Heat Pump
1167
+ //deviceData.Device.SetTemperatureZone1 = value;
1168
+ //deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetTemperatureZone1;
1169
+ break;
1170
+ case 1: //Zone 1
1171
+ switch (deviceData.Device.OperationModeZone1) {
1172
+ case 1: //HEAT FLOW
1173
+ deviceData.Device.SetHeatFlowTemperatureZone1 = value;
1174
+ deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetHeatFlowTemperatureZone1;
1175
+ break;
1176
+ case 4: //COOL FLOW
1177
+ deviceData.Device.SetCoolFlowTemperatureZone1 = value;
1178
+ deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetCoolFlowTemperatureZone1;
1179
+ break;
1180
+ default:
1181
+ deviceData.Device.SetTemperatureZone1 = value;
1182
+ deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetTemperatureZone1;
1183
+ break
1184
+ };
1185
+ break;
1186
+ case caseHotWater: //Hot Water
1187
+ deviceData.Device.SetTankWaterTemperature = value;
1188
+ deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetTankWaterTemperature;
1189
+ break;
1190
+ case caseZone2: //Zone 2
1191
+ switch (deviceData.Device.OperationModeZone2) {
1192
+ case 1: //HEAT FLOW
1193
+ deviceData.Device.SetHeatFlowTemperatureZone2 = value;
1194
+ deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetHeatFlowTemperatureZone2;
1195
+ break;
1196
+ case 4: //COOL FLOW
1197
+ deviceData.Device.SetCoolFlowTemperatureZone2 = value;
1198
+ deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetCoolFlowTemperatureZone2;
1199
+ break;
1200
+ default:
1201
+ deviceData.Device.SetTemperatureZone2 = value;
1202
+ deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetTemperatureZone2;
1203
+ break
1204
+ };
1205
+ break;
1206
+ };
1207
+
1208
+ const set = i > 0 ? await this.melCloudAtw.send(deviceData) : false;
1209
+ const info = this.disableLogInfo || i === 0 ? false : this.emit('message', `${zoneName}, Set heating threshold temperature: ${value}${this.accessory.temperatureUnit}`);
1210
+ } catch (error) {
1211
+ this.emit('warn', `${zoneName}, Set heating threshold temperature error: ${error}`);
1212
+ };
1213
+ });
1102
1214
  melCloudService.getCharacteristic(Characteristic.LockPhysicalControls)
1103
1215
  .onGet(async () => {
1104
1216
  const value = this.accessory.zones[i].lockPhysicalControl;
@@ -1141,7 +1253,7 @@ class DeviceAtw extends EventEmitter {
1141
1253
  })
1142
1254
  .onSet(async (value) => {
1143
1255
  try {
1144
- accountInfo.UseFahrenheit = value ? true : false;
1256
+ accountInfo.UseFahrenheit = [false, true][value];
1145
1257
  await this.melCloud.send(accountInfo);
1146
1258
  const info = this.disableLogInfo ? false : this.emit('message', `Set temperature display unit: ${CONSTANTS.TemperatureDisplayUnits[value]}`);
1147
1259
  } catch (error) {
@@ -1295,16 +1407,40 @@ class DeviceAtw extends EventEmitter {
1295
1407
  //deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetTemperatureZone1;
1296
1408
  break;
1297
1409
  case 1: //Zone 1
1298
- deviceData.Device.SetTemperatureZone1 = value;
1299
- deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetTemperatureZone1;
1410
+ switch (deviceData.Device.OperationModeZone1) {
1411
+ case 1: //HEAT FLOW
1412
+ deviceData.Device.SetHeatFlowTemperatureZone1 = value;
1413
+ deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetHeatFlowTemperatureZone1;
1414
+ break;
1415
+ case 4: //COOL FLOW
1416
+ deviceData.Device.SetCoolFlowTemperatureZone1 = value;
1417
+ deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetCoolFlowTemperatureZone1;
1418
+ break;
1419
+ default:
1420
+ deviceData.Device.SetTemperatureZone1 = value;
1421
+ deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetTemperatureZone1;
1422
+ break
1423
+ };
1300
1424
  break;
1301
1425
  case caseHotWater: //Hot Water
1302
1426
  deviceData.Device.SetTankWaterTemperature = value;
1303
1427
  deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetTankWaterTemperature;
1304
1428
  break;
1305
1429
  case caseZone2: //Zone 2
1306
- deviceData.Device.SetTemperatureZone2 = value;
1307
- deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetTemperatureZone2;
1430
+ switch (deviceData.Device.OperationModeZone2) {
1431
+ case 1: //HEAT FLOW
1432
+ deviceData.Device.SetHeatFlowTemperatureZone2 = value;
1433
+ deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetHeatFlowTemperatureZone2;
1434
+ break;
1435
+ case 4: //COOL FLOW
1436
+ deviceData.Device.SetCoolFlowTemperatureZone2 = value;
1437
+ deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetCoolFlowTemperatureZone2;
1438
+ break;
1439
+ default:
1440
+ deviceData.Device.SetTemperatureZone2 = value;
1441
+ deviceData.Device.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.SetTemperatureZone2;
1442
+ break
1443
+ };
1308
1444
  break;
1309
1445
  };
1310
1446
 
@@ -1321,7 +1457,7 @@ class DeviceAtw extends EventEmitter {
1321
1457
  })
1322
1458
  .onSet(async (value) => {
1323
1459
  try {
1324
- accountInfo.UseFahrenheit = value ? true : false;
1460
+ accountInfo.UseFahrenheit = [false, true][value];
1325
1461
  await this.melCloud.send(accountInfo);
1326
1462
  const info = this.disableLogInfo ? false : this.emit('message', `Set temperature display unit: ${CONSTANTS.TemperatureDisplayUnits[value]}`);
1327
1463
  } catch (error) {