homebridge-melcloud-control 2.3.0-beta.8 → 2.3.1-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/src/deviceatw.js CHANGED
@@ -35,15 +35,12 @@ class DeviceAtw extends EventEmitter {
35
35
 
36
36
  //external integrations
37
37
  const restFul = account.restFul ?? {};
38
- const restFulEnabled = restFul.enable || false;
39
38
  this.restFulConnected = false;
40
39
  const mqtt = account.mqtt ?? {};
41
- const mqttEnabled = mqtt.enable || false;
42
40
  this.mqttConnected = false;
43
41
 
44
- //variables
42
+ //function
45
43
  this.melCloud = melCloud; //function
46
- this.startPrepareAccessory = true;
47
44
 
48
45
  //buttons configured
49
46
  this.buttonsConfigured = [];
@@ -66,6 +63,21 @@ class DeviceAtw extends EventEmitter {
66
63
  }
67
64
  this.buttonsConfiguredCount = this.buttonsConfigured.length || 0;
68
65
 
66
+ //variables
67
+ this.startPrepareAccessory = true;
68
+ this.accessory = {
69
+ power: false,
70
+ offline: false,
71
+ unitStatus: 0,
72
+ idleZone1: false,
73
+ idleZone2: false,
74
+ useFahrenheit: 0,
75
+ temperatureUnit: '°C',
76
+ temperatureIncrement: 1,
77
+ presets: [],
78
+ zones: [{}, {}, {}, {}]
79
+ };
80
+
69
81
  //melcloud device
70
82
  this.melCloudAtw = new MelCloudAtw({
71
83
  contextKey: contextKey,
@@ -77,6 +89,7 @@ class DeviceAtw extends EventEmitter {
77
89
 
78
90
  this.melCloudAtw.on('externalIntegrations', (deviceData, deviceState) => {
79
91
  //RESTFul server
92
+ const restFulEnabled = restFul.enable || false;
80
93
  if (restFulEnabled) {
81
94
  if (!this.restFulConnected) {
82
95
  this.restFul = new RestFul({
@@ -107,6 +120,7 @@ class DeviceAtw extends EventEmitter {
107
120
  }
108
121
 
109
122
  //MQTT client
123
+ const mqttEnabled = mqtt.enable || false;
110
124
  if (mqttEnabled) {
111
125
  if (!this.mqttConnected) {
112
126
  this.mqtt = new Mqtt({
@@ -178,6 +192,7 @@ class DeviceAtw extends EventEmitter {
178
192
  const canCool = deviceData.Device.CanCool ?? false;
179
193
  const heatCoolModes = canHeat && canCool ? 0 : canHeat ? 1 : canCool ? 2 : 3;
180
194
  const temperatureIncrement = deviceData.Device.TemperatureIncrement ?? 1;
195
+ const temperatureUnit = CONSTANTS.TemperatureDisplayUnits[useFahrenheit];
181
196
  const minSetTemperature = deviceData.Device.MinSetTemperature ?? 10;
182
197
  const maxSetTemperature = deviceData.Device.MaxSetTemperature ?? 30;
183
198
  const maxTankTemperature = deviceData.Device.MaxTankTemperature ?? 70;
@@ -209,16 +224,9 @@ class DeviceAtw extends EventEmitter {
209
224
  const caseZone2 = hasZone2 ? hasHotWaterTank ? 3 : 2 : -1;
210
225
 
211
226
  this.zonesCount = zonesCount;
212
- this.heatPumpName = heatPumpName;
213
- this.hotWaterName = hotWaterName;
214
- this.zone1Name = zone1Name
215
- this.zone2Name = zone2Name;
216
227
  this.heatCoolModes = heatCoolModes;
217
228
  this.caseHotWater = caseHotWater;
218
229
  this.caseZone2 = caseZone2;
219
- this.temperatureIncrement = temperatureIncrement;
220
- this.temperatureUnit = CONSTANTS.TemperatureDisplayUnits[useFahrenheit];
221
- this.useFahrenheit = useFahrenheit;
222
230
 
223
231
  //device state
224
232
  const setTemperatureZone1 = deviceState.SetTemperatureZone1;
@@ -249,32 +257,29 @@ class DeviceAtw extends EventEmitter {
249
257
 
250
258
  //presets
251
259
  const presets = deviceData.Presets ?? [];
252
- this.presets = presets;
253
260
  this.presetsCount = this.presetsEnabled ? presets.length : 0;
254
261
 
255
- //zones array
256
- this.currentOperationModes = [];
257
- this.targetOperationModes = [];
258
- this.roomTemperatures = [];
259
- this.setTemperatures = [];
260
- this.lockPhysicalsControls = [];
261
-
262
- this.operationModesSetPropsMinValue = [];
263
- this.operationModesSetPropsMaxValue = [];
264
- this.operationModesSetPropsValidValues = [];
265
- this.temperaturesSetPropsMinValue = [];
266
- this.temperaturesSetPropsMaxValue = [];
262
+ //accessory
263
+ this.accessory.power = power;
264
+ this.accessory.offline = offline;
265
+ this.accessory.unitStatus = unitStatus;
266
+ this.accessory.idleZone1 = idleZone1;
267
+ this.accessory.idleZone2 = idleZone2;
268
+ this.accessory.useFahrenheit = useFahrenheit;
269
+ this.accessory.temperatureUnit = temperatureUnit;
270
+ this.accessory.temperatureIncrement = temperatureIncrement;
271
+ this.accessory.presets = presets;
267
272
 
268
273
  //default values
269
274
  let currentOperationMode = 0;
270
275
  let targetOperationMode = 0;
271
276
  let roomTemperature = 20;
272
277
  let setTemperature = 20;
273
- let lockPhysicalControls = 0;
278
+ let lockPhysicalControl = 0;
274
279
 
275
280
  let operationModeSetPropsMinValue = 0;
276
281
  let operationModeSetPropsMaxValue = 3;
277
- let operationModeSetPropsValidValues = [];
282
+ let operationModeSetPropsValidValues = [0];
278
283
  let temperatureSetPropsMinValue = -35;
279
284
  let temperatureSetPropsMaxValue = 140;
280
285
 
@@ -287,52 +292,56 @@ class DeviceAtw extends EventEmitter {
287
292
  targetOperationMode = [1, 2][unitStatus]; //AUTO, HEAT, COOL
288
293
  roomTemperature = outdoorTemperature;
289
294
  setTemperature = outdoorTemperature;
290
- lockPhysicalControls = hasHotWaterTank && hasZone2 ? (prohibitZone1 && prohibitHotWater && prohibitZone2 ? 1 : 0) : hasHotWaterTank ? (prohibitZone1 && prohibitHotWater ? 1 : 0) : hasZone2 ? (prohibitZone1 && prohibitZone2 ? 1 : 0) : 0;
295
+ lockPhysicalControl = hasHotWaterTank && hasZone2 ? (prohibitZone1 && prohibitHotWater && prohibitZone2 ? 1 : 0) : hasHotWaterTank ? (prohibitZone1 && prohibitHotWater ? 1 : 0) : hasZone2 ? (prohibitZone1 && prohibitZone2 ? 1 : 0) : 0;
291
296
 
292
297
  operationModeSetPropsMinValue = [1, 1, 2, 0][heatCoolModes];
293
298
  operationModeSetPropsMaxValue = [2, 1, 2, 0][heatCoolModes];
294
299
  operationModeSetPropsValidValues = [[1, 2], [1], [2], [0]][heatCoolModes];
295
300
  temperatureSetPropsMinValue = -35;
296
301
  temperatureSetPropsMaxValue = 100;
302
+ this.accessory.zones[i].name = heatPumpName;
297
303
  break;
298
304
  case 1: //Zone 1 - HEAT THERMOSTAT, HEAT FLOW, HEAT CURVE, COOL THERMOSTAT, COOL FLOW, FLOOR DRY UP
299
305
  currentOperationMode = !power ? 0 : idleZone1 ? 1 : [2, 2, 2, 3, 3, 2][operationModeZone1]; //INACTIVE, IDLE, HEATING, COOLING
300
306
  targetOperationMode = [1, 2, 0, 1, 2, 1][operationModeZone1]; //AUTO, HEAT, COOL
301
307
  roomTemperature = roomTemperatureZone1;
302
308
  setTemperature = setTemperatureZone1;
303
- lockPhysicalControls = prohibitZone1 ? 1 : 0;
309
+ lockPhysicalControl = prohibitZone1 ? 1 : 0;
304
310
 
305
311
  operationModeSetPropsMinValue = [0, 0, 1, 0][heatCoolModes];
306
312
  operationModeSetPropsMaxValue = [2, 2, 2, 0][heatCoolModes];
307
313
  operationModeSetPropsValidValues = [[0, 1, 2], [0, 1, 2], [1, 2], [0]][heatCoolModes];
308
314
  temperatureSetPropsMinValue = 0;
309
315
  temperatureSetPropsMaxValue = 31;
316
+ this.accessory.zones[i].name = zone1Name;
310
317
  break;
311
318
  case caseHotWater: //Hot Water - NORMAL, HEAT NOW
312
319
  currentOperationMode = !power ? 0 : operationMode === 1 ? 2 : [1, 2][forcedHotWaterMode]; //INACTIVE, IDLE, HEATING, COOLING
313
320
  targetOperationMode = [0, 1][forcedHotWaterMode] //AUTO, HEAT, COOL
314
321
  roomTemperature = tankWaterTemperature;
315
322
  setTemperature = setTankWaterTemperature;
316
- lockPhysicalControls = prohibitHotWater ? 1 : 0;
323
+ lockPhysicalControl = prohibitHotWater ? 1 : 0;
317
324
 
318
325
  operationModeSetPropsMinValue = 0;
319
326
  operationModeSetPropsMaxValue = 1;
320
327
  operationModeSetPropsValidValues = [0, 1];
321
328
  temperatureSetPropsMinValue = 0;
322
329
  temperatureSetPropsMaxValue = maxTankTemperature;
330
+ this.accessory.zones[i].name = hotWaterName;
323
331
  break;
324
332
  case caseZone2: //Zone 2 - HEAT THERMOSTAT, HEAT FLOW, HEAT CURVE, COOL THERMOSTAT, COOL FLOW, FLOOR DRY UP
325
333
  currentOperationMode = !power ? 0 : idleZone2 ? 1 : [2, 2, 2, 3, 3, 2][operationModeZone2]; //INACTIVE, IDLE, HEATING, COOLING
326
334
  targetOperationMode = [1, 2, 0, 1, 2, 1][operationModeZone2]; //AUTO, HEAT, COOL
327
335
  roomTemperature = roomTemperatureZone2;
328
336
  setTemperature = setTemperatureZone2;
329
- lockPhysicalControls = prohibitZone2 ? 1 : 0;
337
+ lockPhysicalControl = prohibitZone2 ? 1 : 0;
330
338
 
331
339
  operationModeSetPropsMinValue = [0, 0, 1, 0][heatCoolModes];
332
340
  operationModeSetPropsMaxValue = [2, 2, 2, 0][heatCoolModes];
333
341
  operationModeSetPropsValidValues = [[0, 1, 2], [0, 1, 2], [1, 2], [0]][heatCoolModes];
334
342
  temperatureSetPropsMinValue = 0;
335
343
  temperatureSetPropsMaxValue = 31;
344
+ this.accessory.zones[i].name = zone2Name;
336
345
  break;
337
346
  default: //unknown zone detected
338
347
  this.emit('message', `Unknown zone: ${i} detected.`);
@@ -346,7 +355,7 @@ class DeviceAtw extends EventEmitter {
346
355
  .updateCharacteristic(Characteristic.CurrentHeaterCoolerState, currentOperationMode)
347
356
  .updateCharacteristic(Characteristic.TargetHeaterCoolerState, targetOperationMode)
348
357
  .updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature)
349
- .updateCharacteristic(Characteristic.LockPhysicalControls, lockPhysicalControls)
358
+ .updateCharacteristic(Characteristic.LockPhysicalControls, lockPhysicalControl)
350
359
  .updateCharacteristic(Characteristic.TemperatureDisplayUnits, useFahrenheit);
351
360
  const updateHT = heatCoolModes === 0 || heatCoolModes === 1 ? this.melCloudServices[i].updateCharacteristic(Characteristic.HeatingThresholdTemperature, setTemperature) : false;
352
361
  const updateCT = heatCoolModes === 0 || heatCoolModes === 2 ? this.melCloudServices[i].updateCharacteristic(Characteristic.CoolingThresholdTemperature, setTemperature) : false;
@@ -423,18 +432,16 @@ class DeviceAtw extends EventEmitter {
423
432
  };
424
433
 
425
434
  //push value to arrays
426
- this.currentOperationModes.push(currentOperationMode);
427
- this.targetOperationModes.push(targetOperationMode);
428
- this.roomTemperatures.push(roomTemperature);
429
- this.setTemperatures.push(setTemperature);
430
- this.lockPhysicalsControls.push(lockPhysicalControls);
431
-
432
- //push only 1 time for every zone
433
- const push = this.startPrepareAccessory ? this.operationModesSetPropsMinValue.push(operationModeSetPropsMinValue) : false;
434
- const push1 = this.startPrepareAccessory ? this.operationModesSetPropsMaxValue.push(operationModeSetPropsMaxValue) : false;
435
- const push2 = this.startPrepareAccessory ? this.operationModesSetPropsValidValues.push(operationModeSetPropsValidValues) : false;
436
- const push3 = this.startPrepareAccessory ? this.temperaturesSetPropsMinValue.push(temperatureSetPropsMinValue) : false;
437
- const push4 = this.startPrepareAccessory ? this.temperaturesSetPropsMaxValue.push(temperatureSetPropsMaxValue) : false;
435
+ this.accessory.zones[i].currentOperationMode = currentOperationMode;
436
+ this.accessory.zones[i].targetOperationMode = targetOperationMode;
437
+ this.accessory.zones[i].roomTemperature = roomTemperature;
438
+ this.accessory.zones[i].setTemperature = setTemperature;
439
+ this.accessory.zones[i].lockPhysicalControl = lockPhysicalControl;
440
+ this.accessory.zones[i].operationModesSetPropsMinValue = operationModeSetPropsMinValue;
441
+ this.accessory.zones[i].operationModesSetPropsMaxValue = operationModeSetPropsMaxValue;
442
+ this.accessory.zones[i].operationModesSetPropsValidValues = operationModeSetPropsValidValues;
443
+ this.accessory.zones[i].temperaturesSetPropsMinValue = temperatureSetPropsMinValue;
444
+ this.accessory.zones[i].temperaturesSetPropsMaxValue = temperatureSetPropsMaxValue;
438
445
 
439
446
  //update temperature sensors
440
447
  switch (i) {
@@ -511,52 +518,46 @@ class DeviceAtw extends EventEmitter {
511
518
  case 0: //Heat Pump - HEAT, COOL, OFF
512
519
  this.emit('message', `${heatPumpName}, Power: ${power ? 'ON' : 'OFF'}`)
513
520
  this.emit('message', `${heatPumpName}, Operation mode: ${!power ? CONSTANTS.HeatPump.System[0] : CONSTANTS.HeatPump.System[unitStatus]}`);
514
- this.emit('message', `${heatPumpName},'Outdoor temperature: ${roomTemperature}${this.temperatureUnit}`);
515
- const info = flowTemperature !== null ? this.emit('message', `${heatPumpName}, Flow temperature: ${flowTemperature}${this.temperatureUnit}`) : false;
516
- const info1 = returnTemperature !== null ? this.emit('message', `${heatPumpName}, Return temperature: ${returnTemperature}${this.temperatureUnit}`) : false;
517
- this.emit('message', `${heatPumpName}, Temperature display unit: ${this.temperatureUnit}`);
518
- this.emit('message', `${heatPumpName}, Lock physical controls: ${lockPhysicalControls ? 'LOCKED' : 'UNLOCKED'}`);
521
+ this.emit('message', `${heatPumpName},'Outdoor temperature: ${roomTemperature}${temperatureUnit}`);
522
+ const info = flowTemperature !== null ? this.emit('message', `${heatPumpName}, Flow temperature: ${flowTemperature}${temperatureUnit}`) : false;
523
+ const info1 = returnTemperature !== null ? this.emit('message', `${heatPumpName}, Return temperature: ${returnTemperature}${temperatureUnit}`) : false;
524
+ this.emit('message', `${heatPumpName}, Temperature display unit: ${temperatureUnit}`);
525
+ this.emit('message', `${heatPumpName}, Lock physical controls: ${lockPhysicalControl ? 'LOCKED' : 'UNLOCKED'}`);
519
526
  break;
520
527
  case 1: //Zone 1 - HEAT THERMOSTAT, HEAT FLOW, HEAT CURVE, COOL THERMOSTAT, COOL FLOW, FLOOR DRY UP
521
528
  operationModeText = idleZone1 ? CONSTANTS.HeatPump.ZoneOperation[6] : CONSTANTS.HeatPump.ZoneOperation[operationModeZone1];
522
529
  this.emit('message', `${zone1Name}, Operation mode: ${!power ? CONSTANTS.HeatPump.System[0] : operationModeText}`);
523
- this.emit('message', `${zone1Name}, Temperature: ${roomTemperature}${this.temperatureUnit}`);
524
- this.emit('message', `${zone1Name}, Target temperature: ${setTemperature}${this.temperatureUnit}`)
525
- const info2 = flowTemperatureZone1 !== null ? this.emit('message', `${zone1Name}, Flow temperature: ${flowTemperatureZone1}${this.temperatureUnit}`) : false;
526
- const info3 = returnTemperatureZone1 !== null ? this.emit('message', `${zone1Name}, Return temperature: ${returnTemperatureZone1}${this.temperatureUnit}`) : false;
527
- this.emit('message', `${zone1Name}, Temperature display unit: ${this.temperatureUnit}`);
528
- this.emit('message', `${zone1Name}, Lock physical controls: ${lockPhysicalControls ? 'LOCKED' : 'UNLOCKED'}`);
530
+ this.emit('message', `${zone1Name}, Temperature: ${roomTemperature}${temperatureUnit}`);
531
+ this.emit('message', `${zone1Name}, Target temperature: ${setTemperature}${temperatureUnit}`)
532
+ const info2 = flowTemperatureZone1 !== null ? this.emit('message', `${zone1Name}, Flow temperature: ${flowTemperatureZone1}${temperatureUnit}`) : false;
533
+ const info3 = returnTemperatureZone1 !== null ? this.emit('message', `${zone1Name}, Return temperature: ${returnTemperatureZone1}${temperatureUnit}`) : false;
534
+ this.emit('message', `${zone1Name}, Temperature display unit: ${temperatureUnit}`);
535
+ this.emit('message', `${zone1Name}, Lock physical controls: ${lockPhysicalControl ? 'LOCKED' : 'UNLOCKED'}`);
529
536
  break;
530
537
  case caseHotWater: //Hot Water - AUTO, HEAT NOW
531
538
  operationModeText = operationMode === 1 ? CONSTANTS.HeatPump.ForceDhw[1] : CONSTANTS.HeatPump.ForceDhw[forcedHotWaterMode ? 1 : 0];
532
539
  this.emit('message', `${hotWaterName}, Operation mode: ${!power ? CONSTANTS.HeatPump.System[0] : operationModeText}`);
533
- this.emit('message', `${hotWaterName}, Temperature: ${roomTemperature}${this.temperatureUnit}`);
534
- this.emit('message', `${hotWaterName}, Target temperature: ${setTemperature}${this.temperatureUnit}`)
535
- const info4 = flowTemperatureWaterTank !== null ? this.emit('message', `${hotWaterName}, Flow temperature: ${flowTemperatureWaterTank}${this.temperatureUnit}`) : false;
536
- const info5 = returnTemperatureWaterTank !== null ? this.emit('message', `${hotWaterName}, Return temperature: ${returnTemperatureWaterTank}${this.temperatureUnit}`) : false;
537
- this.emit('message', `${hotWaterName}, Temperature display unit: ${this.temperatureUnit}`);
538
- this.emit('message', `${hotWaterName}, Lock physical controls: ${lockPhysicalControls ? 'LOCKED' : 'UNLOCKED'}`);
540
+ this.emit('message', `${hotWaterName}, Temperature: ${roomTemperature}${temperatureUnit}`);
541
+ this.emit('message', `${hotWaterName}, Target temperature: ${setTemperature}${temperatureUnit}`)
542
+ const info4 = flowTemperatureWaterTank !== null ? this.emit('message', `${hotWaterName}, Flow temperature: ${flowTemperatureWaterTank}${temperatureUnit}`) : false;
543
+ const info5 = returnTemperatureWaterTank !== null ? this.emit('message', `${hotWaterName}, Return temperature: ${returnTemperatureWaterTank}${temperatureUnit}`) : false;
544
+ this.emit('message', `${hotWaterName}, Temperature display unit: ${temperatureUnit}`);
545
+ this.emit('message', `${hotWaterName}, Lock physical controls: ${lockPhysicalControl ? 'LOCKED' : 'UNLOCKED'}`);
539
546
  break;
540
547
  case caseZone2: //Zone 2 - HEAT THERMOSTAT, HEAT FLOW, HEAT CURVE, COOL THERMOSTAT, COOL FLOW, FLOOR DRY UP
541
548
  operationModeText = idleZone2 ? CONSTANTS.HeatPump.ZoneOperation[6] : CONSTANTS.HeatPump.ZoneOperation[operationModeZone2];
542
549
  this.emit('message', `${zone2Name}, Operation mode: ${!power ? CONSTANTS.HeatPump.System[0] : operationModeText}`);
543
- this.emit('message', `${zone2Name}, Temperature: ${roomTemperature}${this.temperatureUnit}`);
544
- this.emit('message', `${zone2Name}, Target temperature: ${setTemperature}${this.temperatureUnit}`)
545
- const info6 = flowTemperatureZone2 !== null ? this.emit('message', `${zone2Name}, Flow temperature: ${flowTemperatureZone2}${this.temperatureUnit}`) : false;
546
- const info7 = roomTemperatureZone2 !== null ? this.emit('message', `${zone2Name}, Return temperature: ${roomTemperatureZone2}${this.temperatureUnit}`) : false;
547
- this.emit('message', `${zone2Name}, Temperature display unit: ${this.temperatureUnit}`);
548
- this.emit('message', `${zone2Name}, Lock physical controls: ${lockPhysicalControls ? 'LOCKED' : 'UNLOCKED'}`);
550
+ this.emit('message', `${zone2Name}, Temperature: ${roomTemperature}${temperatureUnit}`);
551
+ this.emit('message', `${zone2Name}, Target temperature: ${setTemperature}${temperatureUnit}`)
552
+ const info6 = flowTemperatureZone2 !== null ? this.emit('message', `${zone2Name}, Flow temperature: ${flowTemperatureZone2}${temperatureUnit}`) : false;
553
+ const info7 = roomTemperatureZone2 !== null ? this.emit('message', `${zone2Name}, Return temperature: ${roomTemperatureZone2}${temperatureUnit}`) : false;
554
+ this.emit('message', `${zone2Name}, Temperature display unit: ${temperatureUnit}`);
555
+ this.emit('message', `${zone2Name}, Lock physical controls: ${lockPhysicalControl ? 'LOCKED' : 'UNLOCKED'}`);
549
556
  break;
550
557
  };
551
558
  };
552
559
  };
553
560
 
554
- this.unitStatus = unitStatus;
555
- this.idleZone1 = idleZone1;
556
- this.idleZone2 = idleZone2;
557
- this.power = power;
558
- this.offline = offline;
559
-
560
561
  //update buttons state
561
562
  if (this.buttonsConfiguredCount > 0) {
562
563
  for (let i = 0; i < this.buttonsConfiguredCount; i++) {
@@ -676,7 +677,6 @@ class DeviceAtw extends EventEmitter {
676
677
  //start prepare accessory
677
678
  if (this.startPrepareAccessory) {
678
679
  try {
679
- await new Promise(resolve => setTimeout(resolve, 150));
680
680
  const accessory = await this.prepareAccessory(accountInfo, deviceState, deviceId, deviceTypeText, deviceName, accountName);
681
681
  this.emit('publishAccessory', accessory);
682
682
  this.startPrepareAccessory = false;
@@ -828,7 +828,7 @@ class DeviceAtw extends EventEmitter {
828
828
  const temperatureSensorReturnZone2 = this.temperatureSensorReturnZone2;
829
829
  const buttonsConfigured = this.buttonsConfigured;
830
830
  const buttonsConfiguredCount = this.buttonsConfiguredCount;
831
- const presets = this.presets;
831
+ const presets = this.accessory.presets;
832
832
  const presetsCount = this.presetsCount;
833
833
  const displayMode = this.displayMode;
834
834
  const caseHotWater = this.caseHotWater;
@@ -837,7 +837,7 @@ class DeviceAtw extends EventEmitter {
837
837
 
838
838
  this.melCloudServices = [];
839
839
  for (let i = 0; i < zonesCount; i++) {
840
- const zoneName = [this.heatPumpName, this.zone1Name, this.hotWaterName, this.zone2Name][i];
840
+ const zoneName = this.accessory.zones[i].name
841
841
  const serviceName = `${deviceTypeText} ${accessoryName}: ${zoneName}`;
842
842
  switch (displayMode) {
843
843
  case 0: //Heater Cooler
@@ -845,7 +845,7 @@ class DeviceAtw extends EventEmitter {
845
845
  const melCloudService = new Service.HeaterCooler(serviceName, `HeaterCooler ${deviceId} ${i}`);
846
846
  melCloudService.getCharacteristic(Characteristic.Active)
847
847
  .onGet(async () => {
848
- const state = this.power;
848
+ const state = this.accessory.power;
849
849
  return state;
850
850
  })
851
851
  .onSet(async (state) => {
@@ -865,17 +865,17 @@ class DeviceAtw extends EventEmitter {
865
865
  });
866
866
  melCloudService.getCharacteristic(Characteristic.CurrentHeaterCoolerState)
867
867
  .onGet(async () => {
868
- const value = this.currentOperationModes[i];
868
+ const value = this.accessory.zones[i].currentOperationMode;
869
869
  return value;
870
870
  });
871
871
  melCloudService.getCharacteristic(Characteristic.TargetHeaterCoolerState)
872
872
  .setProps({
873
- minValue: this.operationModesSetPropsMinValue[i],
874
- maxValue: this.operationModesSetPropsMaxValue[i],
875
- validValues: this.operationModesSetPropsValidValues[i]
873
+ minValue: this.accessory.zones[i].operationModesSetPropsMinValue,
874
+ maxValue: this.accessory.zones[i].operationModesSetPropsMaxValue,
875
+ validValues: this.accessory.zones[i].operationModesSetPropsValidValues
876
876
  })
877
877
  .onGet(async () => {
878
- const value = this.targetOperationModes[i];
878
+ const value = this.accessory.zones[i].targetOperationMode;
879
879
  return value;
880
880
  })
881
881
  .onSet(async (value) => {
@@ -899,7 +899,7 @@ class DeviceAtw extends EventEmitter {
899
899
  deviceState.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.Power + CONSTANTS.HeatPump.EffectiveFlags.OperationMode;
900
900
  break;
901
901
  };
902
- operationModeText = !this.power ? CONSTANTS.HeatPump.System[0] : CONSTANTS.HeatPump.System[deviceState.UnitStatus];
902
+ operationModeText = !this.accessory.power ? CONSTANTS.HeatPump.System[0] : CONSTANTS.HeatPump.System[deviceState.UnitStatus];
903
903
  break;
904
904
  case 1: //Zone 1 - HEAT THERMOSTAT, HEAT FLOW, HEAT CURVE, COOL THERMOSTAT, COOL FLOW, FLOOR DRY UP
905
905
  switch (value) {
@@ -967,19 +967,19 @@ class DeviceAtw extends EventEmitter {
967
967
  minStep: 0.5
968
968
  })
969
969
  .onGet(async () => {
970
- const value = this.roomTemperatures[i];
970
+ const value = this.accessory.zones[i].roomTemperature;
971
971
  return value;
972
972
  });
973
973
  //device can heat/cool or only heat
974
974
  if (heatCoolModes === 0 || heatCoolModes === 1) {
975
975
  melCloudService.getCharacteristic(Characteristic.HeatingThresholdTemperature)
976
976
  .setProps({
977
- minValue: this.temperaturesSetPropsMinValue[i],
978
- maxValue: this.temperaturesSetPropsMaxValue[i],
979
- minStep: this.temperatureIncrement
977
+ minValue: this.accessory.zones[i].temperaturesSetPropsMinValue,
978
+ maxValue: this.accessory.zones[i].temperaturesSetPropsMaxValue,
979
+ minStep: this.accessory.temperatureIncrement
980
980
  })
981
981
  .onGet(async () => {
982
- const value = this.setTemperatures[i];
982
+ const value = this.accessory.zones[i].setTemperature;
983
983
  return value;
984
984
  })
985
985
  .onSet(async (value) => {
@@ -1004,7 +1004,7 @@ class DeviceAtw extends EventEmitter {
1004
1004
  };
1005
1005
 
1006
1006
  const set = i > 0 ? await this.melCloudAtw.send(deviceState) : false;
1007
- const info = this.disableLogInfo || i === 0 ? false : this.emit('message', `${zoneName}, Set heating threshold temperature: ${value}${this.temperatureUnit}`);
1007
+ const info = this.disableLogInfo || i === 0 ? false : this.emit('message', `${zoneName}, Set heating threshold temperature: ${value}${this.accessory.temperatureUnit}`);
1008
1008
  } catch (error) {
1009
1009
  this.emit('warn', `${zoneName}, Set heating threshold temperature error: ${error}`);
1010
1010
  };
@@ -1014,12 +1014,12 @@ class DeviceAtw extends EventEmitter {
1014
1014
  if ((heatCoolModes === 0 || heatCoolModes === 2) && i !== caseHotWater) {
1015
1015
  melCloudService.getCharacteristic(Characteristic.CoolingThresholdTemperature)
1016
1016
  .setProps({
1017
- minValue: this.temperaturesSetPropsMinValue[i],
1018
- maxValue: this.temperaturesSetPropsMaxValue[i],
1019
- minStep: this.temperatureIncrement
1017
+ minValue: this.accessory.zones[i].temperaturesSetPropsMinValue,
1018
+ maxValue: this.accessory.zones[i].temperaturesSetPropsMaxValue,
1019
+ minStep: this.accessory.temperatureIncrement
1020
1020
  })
1021
1021
  .onGet(async () => {
1022
- const value = this.setTemperatures[i];
1022
+ const value = this.accessory.zones[i].setTemperature;
1023
1023
  return value;
1024
1024
  })
1025
1025
  .onSet(async (value) => {
@@ -1044,7 +1044,7 @@ class DeviceAtw extends EventEmitter {
1044
1044
  };
1045
1045
 
1046
1046
  const set = i > 0 ? await this.melCloudAtw.send(deviceState) : false;
1047
- const info = this.disableLogInfo || i === 0 ? false : this.emit('message', `${zoneName}, Set cooling threshold temperature: ${value}${this.temperatureUnit}`);
1047
+ const info = this.disableLogInfo || i === 0 ? false : this.emit('message', `${zoneName}, Set cooling threshold temperature: ${value}${this.accessory.temperatureUnit}`);
1048
1048
  } catch (error) {
1049
1049
  this.emit('warn', `${zoneName}, Set cooling threshold temperature error: ${error}`);
1050
1050
  };
@@ -1052,7 +1052,7 @@ class DeviceAtw extends EventEmitter {
1052
1052
  };
1053
1053
  melCloudService.getCharacteristic(Characteristic.LockPhysicalControls)
1054
1054
  .onGet(async () => {
1055
- const value = this.lockPhysicalsControls[i];
1055
+ const value = this.accessory.zones[i].lockPhysicalControl;
1056
1056
  return value;
1057
1057
  })
1058
1058
  .onSet(async (value) => {
@@ -1087,13 +1087,13 @@ class DeviceAtw extends EventEmitter {
1087
1087
  });
1088
1088
  melCloudService.getCharacteristic(Characteristic.TemperatureDisplayUnits)
1089
1089
  .onGet(async () => {
1090
- const value = this.useFahrenheit;
1090
+ const value = this.accessory.useFahrenheit;
1091
1091
  return value;
1092
1092
  })
1093
1093
  .onSet(async (value) => {
1094
1094
  try {
1095
- this.useFahrenheit = value ? true : false;
1096
- accountInfo.UseFahrenheit = this.useFahrenheit;
1095
+ this.accessory.useFahrenheit = value ? true : false;
1096
+ accountInfo.UseFahrenheit = this.accessory.useFahrenheit;
1097
1097
  await this.melCloud.send(accountInfo);
1098
1098
  const info = this.disableLogInfo ? false : this.emit('message', `Set temperature display unit: ${CONSTANTS.TemperatureDisplayUnits[value]}`);
1099
1099
  } catch (error) {
@@ -1108,17 +1108,17 @@ class DeviceAtw extends EventEmitter {
1108
1108
  const melCloudServiceT = new Service.Thermostat(serviceName, `Thermostat ${deviceId} ${i}`);
1109
1109
  melCloudServiceT.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
1110
1110
  .onGet(async () => {
1111
- const value = this.currentOperationModes[i];
1111
+ const value = this.accessory.zones[i].currentOperationMode;
1112
1112
  return value;
1113
1113
  });
1114
1114
  melCloudServiceT.getCharacteristic(Characteristic.TargetHeatingCoolingState)
1115
1115
  .setProps({
1116
- minValue: this.operationModesSetPropsMinValue[i],
1117
- maxValue: this.operationModesSetPropsMaxValue[i],
1118
- validValues: this.operationModesSetPropsValidValues[i]
1116
+ minValue: this.accessory.zones[i].operationModesSetPropsMinValue,
1117
+ maxValue: this.accessory.zones[i].operationModesSetPropsMaxValue,
1118
+ validValues: this.accessory.zones[i].operationModesSetPropsValidValues
1119
1119
  })
1120
1120
  .onGet(async () => {
1121
- const value = this.targetOperationModes[i];
1121
+ const value = this.accessory.zones[i].targetOperationMode;
1122
1122
  return value;
1123
1123
  })
1124
1124
  .onSet(async (value) => {
@@ -1146,7 +1146,7 @@ class DeviceAtw extends EventEmitter {
1146
1146
  deviceState.EffectiveFlags = CONSTANTS.HeatPump.EffectiveFlags.Power;
1147
1147
  break;
1148
1148
  };
1149
- operationModeText = !this.power ? CONSTANTS.HeatPump.System[0] : CONSTANTS.HeatPump.System[deviceState.UnitStatus];
1149
+ operationModeText = !this.accessory.power ? CONSTANTS.HeatPump.System[0] : CONSTANTS.HeatPump.System[deviceState.UnitStatus];
1150
1150
  break;
1151
1151
  case 1: //Zone 1 - HEAT THERMOSTAT, HEAT FLOW, HEAT CURVE, COOL THERMOSTAT, COOL FLOW, FLOOR DRY UP
1152
1152
  switch (value) {
@@ -1226,17 +1226,17 @@ class DeviceAtw extends EventEmitter {
1226
1226
  minStep: 0.5
1227
1227
  })
1228
1228
  .onGet(async () => {
1229
- const value = this.roomTemperatures[i];
1229
+ const value = this.accessory.zones[i].roomTemperature;
1230
1230
  return value;
1231
1231
  });
1232
1232
  melCloudServiceT.getCharacteristic(Characteristic.TargetTemperature)
1233
1233
  .setProps({
1234
- minValue: this.temperaturesSetPropsMinValue[i],
1235
- maxValue: this.temperaturesSetPropsMaxValue[i],
1236
- minStep: this.temperatureIncrement
1234
+ minValue: this.accessory.zones[i].temperaturesSetPropsMinValue,
1235
+ maxValue: this.accessory.zones[i].temperaturesSetPropsMaxValue,
1236
+ minStep: this.accessory.temperatureIncrement
1237
1237
  })
1238
1238
  .onGet(async () => {
1239
- const value = this.setTemperatures[i];
1239
+ const value = this.accessory.zones[i].setTemperature;
1240
1240
  return value;
1241
1241
  })
1242
1242
  .onSet(async (value) => {
@@ -1261,20 +1261,20 @@ class DeviceAtw extends EventEmitter {
1261
1261
  };
1262
1262
 
1263
1263
  const set = i > 0 ? await this.melCloudAtw.send(deviceState) : false;
1264
- const info = this.disableLogInfo || i === 0 ? false : this.emit('message', `${zoneName}, Set temperature: ${value}${this.temperatureUnit}`);
1264
+ const info = this.disableLogInfo || i === 0 ? false : this.emit('message', `${zoneName}, Set temperature: ${value}${this.accessory.temperatureUnit}`);
1265
1265
  } catch (error) {
1266
1266
  this.emit('warn', `${zoneName}, Set temperature error: ${error}`);
1267
1267
  };
1268
1268
  });
1269
1269
  melCloudServiceT.getCharacteristic(Characteristic.TemperatureDisplayUnits)
1270
1270
  .onGet(async () => {
1271
- const value = this.useFahrenheit;
1271
+ const value = this.accessory.useFahrenheit;
1272
1272
  return value;
1273
1273
  })
1274
1274
  .onSet(async (value) => {
1275
1275
  try {
1276
- this.useFahrenheit = value ? true : false;
1277
- accountInfo.UseFahrenheit = this.useFahrenheit;
1276
+ this.accessory.useFahrenheit = value ? true : false;
1277
+ accountInfo.UseFahrenheit = this.accessory.useFahrenheit;
1278
1278
  await this.melCloud.send(accountInfo);
1279
1279
  const info = this.disableLogInfo ? false : this.emit('message', `Set temperature display unit: ${CONSTANTS.TemperatureDisplayUnits[value]}`);
1280
1280
  } catch (error) {
@@ -1289,7 +1289,7 @@ class DeviceAtw extends EventEmitter {
1289
1289
  //temperature sensor services zones
1290
1290
  switch (i) {
1291
1291
  case 0: //Heat Pump
1292
- if (temperatureSensor && this.roomTemperatures[i] !== null) {
1292
+ if (temperatureSensor && this.accessory.zones[i].roomTemperature !== null) {
1293
1293
  const debug = this.enableDebugMode ? this.emit('debug', `${zoneName}, Prepare temperature sensor service`) : false;
1294
1294
  this.roomTemperatureSensorService = new Service.TemperatureSensor(`${serviceName}`, `${zoneName} Temperature Sensor ${deviceId} ${i}`);
1295
1295
  this.roomTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
@@ -1301,7 +1301,7 @@ class DeviceAtw extends EventEmitter {
1301
1301
  minStep: 0.5
1302
1302
  })
1303
1303
  .onGet(async () => {
1304
- const state = this.roomTemperatures[i];
1304
+ const state = this.accessory.zones[i].roomTemperature;
1305
1305
  return state;
1306
1306
  })
1307
1307
  accessory.addService(this.roomTemperatureSensorService);
@@ -1344,7 +1344,7 @@ class DeviceAtw extends EventEmitter {
1344
1344
  };
1345
1345
  break;
1346
1346
  case 1: //Zone 1
1347
- if (temperatureSensor && this.roomTemperatures[i] !== null) {
1347
+ if (temperatureSensor && this.accessory.zones[i].roomTemperature !== null) {
1348
1348
  const debug = this.enableDebugMode ? this.emit('debug', `${zoneName}, Prepare temperature sensor service`) : false;
1349
1349
  this.roomTemperatureZone1SensorService = new Service.TemperatureSensor(`${serviceName}`, `${zoneName} Temperature Sensor ${deviceId} ${i}`);
1350
1350
  this.roomTemperatureZone1SensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
@@ -1356,7 +1356,7 @@ class DeviceAtw extends EventEmitter {
1356
1356
  minStep: 0.5
1357
1357
  })
1358
1358
  .onGet(async () => {
1359
- const state = this.roomTemperatures[i];
1359
+ const state = this.accessory.zones[i].roomTemperature;
1360
1360
  return state;
1361
1361
  })
1362
1362
  accessory.addService(this.roomTemperatureZone1SensorService);
@@ -1399,7 +1399,7 @@ class DeviceAtw extends EventEmitter {
1399
1399
  };
1400
1400
  break;
1401
1401
  case caseHotWater: //Hot Water
1402
- if (temperatureSensor && this.roomTemperatures[i] !== null) {
1402
+ if (temperatureSensor && this.accessory.zones[i].roomTemperature !== null) {
1403
1403
  const debug = this.enableDebugMode ? this.emit('debug', `${zoneName}, Prepare temperature sensor service`) : false;
1404
1404
  this.roomTemperatureWaterTankSensorService = new Service.TemperatureSensor(`${serviceName}`, `${zoneName} Temperature Sensor ${deviceId} ${i}`);
1405
1405
  this.roomTemperatureWaterTankSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
@@ -1411,7 +1411,7 @@ class DeviceAtw extends EventEmitter {
1411
1411
  minStep: 0.5
1412
1412
  })
1413
1413
  .onGet(async () => {
1414
- const state = this.roomTemperatures[i];
1414
+ const state = this.accessory.zones[i].roomTemperature;
1415
1415
  return state;
1416
1416
  })
1417
1417
  accessory.addService(this.roomTemperatureWaterTankSensorService);
@@ -1454,7 +1454,7 @@ class DeviceAtw extends EventEmitter {
1454
1454
  };
1455
1455
  break;
1456
1456
  case caseZone2: //Zone 2
1457
- if (temperatureSensor && this.roomTemperatures[i] !== null) {
1457
+ if (temperatureSensor && this.accessory.zones[i].roomTemperature !== null) {
1458
1458
  const debug = this.enableDebugMode ? this.emit('debug', `${zoneName}, Prepare temperature sensor service`) : false;
1459
1459
  this.roomTemperatureZone2SensorService = new Service.TemperatureSensor(`${serviceName}`, `${zoneName} Temperature Sensor ${deviceId} ${i}`);
1460
1460
  this.roomTemperatureZone2SensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
@@ -1466,7 +1466,7 @@ class DeviceAtw extends EventEmitter {
1466
1466
  minStep: 0.5
1467
1467
  })
1468
1468
  .onGet(async () => {
1469
- const state = this.roomTemperatures[i];
1469
+ const state = this.accessory.zones[i].roomTemperature;
1470
1470
  return state;
1471
1471
  })
1472
1472
  accessory.addService(this.roomTemperatureZone2SensorService);