homebridge-melcloud-control 2.3.1-beta.0 → 2.3.1-beta.2

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "2.3.1-beta.0",
4
+ "version": "2.3.1-beta.2",
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
@@ -60,6 +60,7 @@ class DeviceAta extends EventEmitter {
60
60
  this.buttonsConfiguredCount = this.buttonsConfigured.length || 0;
61
61
 
62
62
  //accessory
63
+ this.startPrepareAccessory = true;
63
64
  this.accessory = {};
64
65
 
65
66
  //melcloud device
@@ -221,6 +222,10 @@ class DeviceAta extends EventEmitter {
221
222
  this.accessory.modelSupportsFanSpeed = modelSupportsFanSpeed;
222
223
  this.accessory.modelSupportsDry = modelSupportsDry;
223
224
  this.accessory.presets = presets;
225
+ this.accessory.operationModeSetPropsMinValue = 0;
226
+ this.accessory.operationModeSetPropsMaxValue = 3;
227
+ this.accessory.operationModeSetPropsValidValues = [0];
228
+ this.accessory.fanSpeedSetPropsMaxValue = 2;
224
229
 
225
230
  //operating mode
226
231
  switch (displayMode) {
package/src/deviceatw.js CHANGED
@@ -63,7 +63,7 @@ class DeviceAtw extends EventEmitter {
63
63
  }
64
64
  this.buttonsConfiguredCount = this.buttonsConfigured.length || 0;
65
65
 
66
- //variables
66
+ //accessory
67
67
  this.startPrepareAccessory = true;
68
68
  this.accessory = {
69
69
  power: false,
package/src/deviceerv.js CHANGED
@@ -57,18 +57,9 @@ class DeviceErv extends EventEmitter {
57
57
  }
58
58
  this.buttonsConfiguredCount = this.buttonsConfigured.length || 0;
59
59
 
60
- //variables
60
+ //accessory
61
61
  this.startPrepareAccessory = true;
62
- this.currentOperationMode = 0;
63
- this.targetOperationMode = 0;
64
- this.fanSpeed = 0;
65
- this.lockPhysicalControl = 0;
66
- this.useFahrenheit = 0;
67
-
68
- this.operationModeSetPropsMinValue = 0;
69
- this.operationModeSetPropsMaxValue = 3;
70
- this.operationModeSetPropsValidValues = [0];
71
- this.fanSpeedSetPropsMaxValue = 2;
62
+ this.accessory = {};
72
63
 
73
64
  //melcloud device
74
65
  this.melCloudErv = new MelCloudErv({
@@ -196,30 +187,6 @@ class DeviceErv extends EventEmitter {
196
187
  const numberOfFanSpeeds = deviceData.Device.NumberOfFanSpeeds ?? 0;
197
188
  const temperatureIncrement = deviceData.Device.TemperatureIncrement ?? 1;
198
189
 
199
- this.hasCoolOperationMode = hasCoolOperationMode;
200
- this.hasHeatOperationMode = hasHeatOperationMode;
201
- this.hasAutoOperationMode = hasAutoOperationMode;
202
- this.hasRoomTemperature = hasRoomTemperature;
203
- this.hasSupplyTemperature = hasSupplyTemperature;
204
- this.hasOutdoorTemperature = hasOutdoorTemperature;
205
- this.hasCO2Sensor = hasCO2Sensor;
206
- this.roomCO2Level = roomCO2Level;
207
- this.roomCO2Detected = roomCO2Detected;
208
- this.hasPM25Sensor = hasPM25Sensor;
209
- this.pM25SensorStatus = pM25SensorStatus;
210
- this.pM25Level = pM25Level;
211
- this.pM25AirQuality = pM25AirQuality;
212
- this.hasAutoVentilationMode = hasAutoVentilationMode;
213
- this.hasBypassVentilationMode = hasBypassVentilationMode;
214
- this.hasAutomaticFanSpeed = hasAutomaticFanSpeed;
215
- this.coreMaintenanceRequired = coreMaintenanceRequired;
216
- this.filterMaintenanceRequired = filterMaintenanceRequired;
217
- this.actualVentilationMode = actualVentilationMode;
218
- this.numberOfFanSpeeds = numberOfFanSpeeds;
219
- this.temperatureIncrement = temperatureIncrement;
220
- this.temperatureUnit = CONSTANTS.TemperatureDisplayUnits[useFahrenheit];
221
- this.useFahrenheit = useFahrenheit;
222
-
223
190
  //device state
224
191
  const roomTemperature = deviceState.RoomTemperature;
225
192
  const supplyTemperature = deviceState.SupplyTemperature;
@@ -234,15 +201,58 @@ class DeviceErv extends EventEmitter {
234
201
  const hideOutdoorTemperature = deviceState.HideOutdoorTemperature;
235
202
  const power = deviceState.Power;
236
203
  const offline = deviceState.Offline;
204
+ const temperatureUnit = CONSTANTS.TemperatureDisplayUnits[useFahrenheit];
237
205
 
238
206
  //presets
239
207
  const presets = deviceData.Presets ?? [];
240
- this.presets = presets;
241
208
  this.presetsCount = this.presetsEnabled ? presets.length : 0;
242
209
 
210
+
243
211
  //set temperature
244
212
  const targetTemperature = hasCoolOperationMode || hasHeatOperationMode ? setTemperature : 20;
245
213
 
214
+ //accessory
215
+ this.accessory.power = power;
216
+ this.accessory.offline = offline;
217
+ this.accessory.roomTemperature = roomTemperature;
218
+ this.accessory.outdoorTemperature = outdoorTemperature;
219
+ this.accessory.supplyTemperature = supplyTemperature;
220
+ this.accessory.setTemperature = targetTemperature;
221
+ this.accessory.fanSpeed = 0;
222
+ this.accessory.setFanSpeed = setFanSpeed;
223
+ this.accessory.currentOperationMode = 0;
224
+ this.accessory.targetOperationMode = 0;
225
+ this.accessory.temperatureIncrement = temperatureIncrement;
226
+ this.accessory.useFahrenheit = useFahrenheit;
227
+ this.accessory.temperatureUnit = temperatureUnit;
228
+ this.accessory.lockPhysicalControl = 0;
229
+ this.accessory.hasAutomaticFanSpeed = hasAutomaticFanSpeed;
230
+ this.accessory.hasOutdoorTemperature = hasOutdoorTemperature;
231
+ this.accessory.numberOfFanSpeeds = numberOfFanSpeeds;
232
+ this.accessory.hasCoolOperationMode = hasCoolOperationMode;
233
+ this.accessory.hasHeatOperationMode = hasHeatOperationMode;
234
+ this.accessory.hasAutoOperationMode = hasAutoOperationMode;
235
+ this.accessory.hasRoomTemperature = hasRoomTemperature;
236
+ this.accessory.hasSupplyTemperature = hasSupplyTemperature;
237
+ this.accessory.hasCO2Sensor = hasCO2Sensor;
238
+ this.accessory.roomCO2Level = roomCO2Level;
239
+ this.accessory.roomCO2Detected = roomCO2Detected;
240
+ this.accessory.hasPM25Sensor = hasPM25Sensor;
241
+ this.accessory.pM25SensorStatus = pM25SensorStatus;
242
+ this.accessory.pM25Level = pM25Level;
243
+ this.accessory.pM25AirQuality = pM25AirQuality;
244
+ this.accessory.hasAutoVentilationMode = hasAutoVentilationMode;
245
+ this.accessory.hasBypassVentilationMode = hasBypassVentilationMode;
246
+ this.accessory.hasAutomaticFanSpeed = hasAutomaticFanSpeed;
247
+ this.accessory.coreMaintenanceRequired = coreMaintenanceRequired;
248
+ this.accessory.filterMaintenanceRequired = filterMaintenanceRequired;
249
+ this.accessory.actualVentilationMode = actualVentilationMode;
250
+ this.accessory.accessory.presets = presets;
251
+ this.accessory.operationModeSetPropsMinValue = 0;
252
+ this.accessory.operationModeSetPropsMaxValue = 3;
253
+ this.accessory.operationModeSetPropsValidValues = [0];
254
+ this.accessory.fanSpeedSetPropsMaxValue = 2;
255
+
246
256
  //operation mode - 0, HEAT, 2, COOL, 4, 5, 6, FAN, AUTO
247
257
  switch (displayMode) {
248
258
  case 0: //Heater Cooler
@@ -250,26 +260,26 @@ class DeviceErv extends EventEmitter {
250
260
  case true:
251
261
  switch (ventilationMode) {
252
262
  case 0: //LOSSNAY
253
- this.currentOperationMode = 2; //HEATING
254
- this.targetOperationMode = 1; //HEAT
263
+ this.accessory.currentOperationMode = 2; //HEATING
264
+ this.accessory.targetOperationMode = 1; //HEAT
255
265
  break;
256
266
  case 1: //BYPASS
257
- this.currentOperationMode = 3; //COOLING
258
- this.targetOperationMode = 2; //COOL
267
+ this.accessory.currentOperationMode = 3; //COOLING
268
+ this.accessory.targetOperationMode = 2; //COOL
259
269
  break;
260
270
  case 2: //AUTO
261
271
  switch (actualVentilationMode) {
262
272
  case 0: //LOSSNAY
263
- this.currentOperationMode = 2; //HEATING
273
+ this.accessory.currentOperationMode = 2; //HEATING
264
274
  break;
265
275
  case 1: //BYPASS
266
- this.currentOperationMode = 3; //COOLING
276
+ this.accessory.currentOperationMode = 3; //COOLING
267
277
  break;
268
278
  default:
269
279
  this.emit('warn', `Unknown actual ventilation mode: ${actualVentilationMode}`);
270
280
  break;
271
281
  };
272
- this.targetOperationMode = 0; //AUTO
282
+ this.accessory.targetOperationMode = 0; //AUTO
273
283
  break;
274
284
  default:
275
285
  this.emit('warn', `Unknown ventilation mode: ${ventilationMode}`);
@@ -277,27 +287,27 @@ class DeviceErv extends EventEmitter {
277
287
  };
278
288
  break;
279
289
  case false:
280
- this.currentOperationMode = 0; //OFF
290
+ this.accessory.currentOperationMode = 0; //OFF
281
291
  break;
282
292
  };
283
293
 
284
- this.operationModeSetPropsMinValue = hasAutoVentilationMode ? 0 : 1;
285
- this.operationModeSetPropsMaxValue = hasAutoVentilationMode ? 2 : 2;
286
- this.operationModeSetPropsValidValues = hasAutoVentilationMode ? (hasBypassVentilationMode ? [0, 1, 2] : [0, 2]) : (hasBypassVentilationMode ? [1, 2] : [2]);
294
+ this.accessory.operationModeSetPropsMinValue = hasAutoVentilationMode ? 0 : 1;
295
+ this.accessory.operationModeSetPropsMaxValue = hasAutoVentilationMode ? 2 : 2;
296
+ this.accessory.operationModeSetPropsValidValues = hasAutoVentilationMode ? (hasBypassVentilationMode ? [0, 1, 2] : [0, 2]) : (hasBypassVentilationMode ? [1, 2] : [2]);
287
297
 
288
298
  //fan speed mode
289
299
  switch (numberOfFanSpeeds) {
290
300
  case 2: //Fan speed mode 2
291
- this.fanSpeed = hasAutomaticFanSpeed ? [3, 1, 2][setFanSpeed] : [0, 1, 2][setFanSpeed];
292
- this.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 3 : 2;
301
+ this.accessory.fanSpeed = hasAutomaticFanSpeed ? [3, 1, 2][setFanSpeed] : [0, 1, 2][setFanSpeed];
302
+ this.accessory.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 3 : 2;
293
303
  break;
294
304
  case 3: //Fan speed mode 3
295
- this.this.fanSpeed = hasAutomaticFanSpeed ? [4, 1, 2, 3][setFanSpeed] : [0, 1, 2, 3][setFanSpeed];
296
- this.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 4 : 3;
305
+ this.this.accessory.fanSpeed = hasAutomaticFanSpeed ? [4, 1, 2, 3][setFanSpeed] : [0, 1, 2, 3][setFanSpeed];
306
+ this.accessory.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 4 : 3;
297
307
  break;
298
308
  case 4: //Fan speed mode 4
299
- this.fanSpeed = hasAutomaticFanSpeed ? [5, 1, 2, 3, 4][setFanSpeed] : [0, 1, 2, 3, 4][setFanSpeed];
300
- this.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 5 : 4;
309
+ this.accessory.fanSpeed = hasAutomaticFanSpeed ? [5, 1, 2, 3, 4][setFanSpeed] : [0, 1, 2, 3, 4][setFanSpeed];
310
+ this.accessory.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 5 : 4;
301
311
  break;
302
312
  };
303
313
 
@@ -305,12 +315,12 @@ class DeviceErv extends EventEmitter {
305
315
  if (this.melCloudService) {
306
316
  this.melCloudService
307
317
  .updateCharacteristic(Characteristic.Active, power)
308
- .updateCharacteristic(Characteristic.CurrentHeaterCoolerState, this.currentOperationMode)
309
- .updateCharacteristic(Characteristic.TargetHeaterCoolerState, this.targetOperationMode)
318
+ .updateCharacteristic(Characteristic.CurrentHeaterCoolerState, this.accessory.currentOperationMode)
319
+ .updateCharacteristic(Characteristic.TargetHeaterCoolerState, this.accessory.targetOperationMode)
310
320
  .updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature)
311
- .updateCharacteristic(Characteristic.RotationSpeed, this.fanSpeed)
312
- .updateCharacteristic(Characteristic.LockPhysicalControls, this.lockPhysicalControl)
313
- .updateCharacteristic(Characteristic.TemperatureDisplayUnits, this.useFahrenheit);
321
+ .updateCharacteristic(Characteristic.RotationSpeed, this.accessory.fanSpeed)
322
+ .updateCharacteristic(Characteristic.LockPhysicalControls, this.accessory.lockPhysicalControl)
323
+ .updateCharacteristic(Characteristic.TemperatureDisplayUnits, this.accessory.useFahrenheit);
314
324
  const updateHOM = hasHeatOperationMode ? this.melCloudService.updateCharacteristic(Characteristic.HeatingThresholdTemperature, targetTemperature) : false;
315
325
  const updateCOM = hasCoolOperationMode ? this.melCloudService.updateCharacteristic(Characteristic.CoolingThresholdTemperature, targetTemperature) : false;
316
326
  };
@@ -321,26 +331,26 @@ class DeviceErv extends EventEmitter {
321
331
  case true:
322
332
  switch (ventilationMode) {
323
333
  case 0: //LOSSNAY
324
- this.currentOperationMode = 1; //HEATING
325
- this.targetOperationMode = 1; //HEAT
334
+ this.accessory.currentOperationMode = 1; //HEATING
335
+ this.accessory.targetOperationMode = 1; //HEAT
326
336
  break;
327
337
  case 1: //BYPASS
328
- this.currentOperationMode = 2; //COOLING
329
- this.targetOperationMode = 2; //COOL
338
+ this.accessory.currentOperationMode = 2; //COOLING
339
+ this.accessory.targetOperationMode = 2; //COOL
330
340
  break;
331
341
  case 2: //AUTO
332
342
  switch (actualVentilationMode) {
333
343
  case 0: //LOSSNAY
334
- this.currentOperationMode = 1; //HEATING
344
+ this.accessory.currentOperationMode = 1; //HEATING
335
345
  break;
336
346
  case 1: //BYPASS
337
- this.currentOperationMode = 2; //COOLING
347
+ this.accessory.currentOperationMode = 2; //COOLING
338
348
  break;
339
349
  default:
340
350
  this.emit('warn', `Unknown actual ventilation mode: ${actualVentilationMode}`);
341
351
  break;
342
352
  };
343
- this.targetOperationMode = 3; //AUTO
353
+ this.accessory.targetOperationMode = 3; //AUTO
344
354
  break;
345
355
  default:
346
356
  this.emit('warn', `Unknown ventilation mode: ${ventilationMode}`);
@@ -348,34 +358,26 @@ class DeviceErv extends EventEmitter {
348
358
  };
349
359
  break;
350
360
  case false:
351
- this.currentOperationMode = 0; //OFF
352
- this.targetOperationMode = 0; //OFF
361
+ this.accessory.currentOperationMode = 0; //OFF
362
+ this.accessory.targetOperationMode = 0; //OFF
353
363
  break;
354
364
  };
355
- this.operationModeSetPropsMinValue = hasAutoVentilationMode ? 0 : 0;
356
- this.operationModeSetPropsMaxValue = hasAutoVentilationMode ? 3 : 2;
357
- this.operationModeSetPropsValidValues = hasAutoVentilationMode ? (hasBypassVentilationMode ? [0, 1, 2, 3] : [0, 2, 3]) : (hasBypassVentilationMode ? [0, 1, 2] : [0, 2]);
365
+ this.accessory.operationModeSetPropsMinValue = hasAutoVentilationMode ? 0 : 0;
366
+ this.accessory.operationModeSetPropsMaxValue = hasAutoVentilationMode ? 3 : 2;
367
+ this.accessory.operationModeSetPropsValidValues = hasAutoVentilationMode ? (hasBypassVentilationMode ? [0, 1, 2, 3] : [0, 2, 3]) : (hasBypassVentilationMode ? [0, 1, 2] : [0, 2]);
358
368
 
359
369
  //update characteristics
360
370
  if (this.melCloudService) {
361
371
  this.melCloudService
362
- .updateCharacteristic(Characteristic.CurrentHeatingCoolingState, this.currentOperationMode)
363
- .updateCharacteristic(Characteristic.TargetHeatingCoolingState, this.targetOperationMode)
372
+ .updateCharacteristic(Characteristic.CurrentHeatingCoolingState, this.accessory.currentOperationMode)
373
+ .updateCharacteristic(Characteristic.TargetHeatingCoolingState, this.accessory.targetOperationMode)
364
374
  .updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature)
365
375
  .updateCharacteristic(Characteristic.TargetTemperature, targetTemperature)
366
- .updateCharacteristic(Characteristic.TemperatureDisplayUnits, this.useFahrenheit);
376
+ .updateCharacteristic(Characteristic.TemperatureDisplayUnits, this.accessory.useFahrenheit);
367
377
  };
368
378
  break;
369
379
  };
370
380
 
371
- this.power = power;
372
- this.offline = offline;
373
- this.roomTemperature = roomTemperature;
374
- this.supplyTemperature = supplyTemperature;
375
- this.outdoorTemperature = outdoorTemperature;
376
- this.setTemperature = targetTemperature;
377
- this.setFanSpeed = setFanSpeed;
378
-
379
381
  //update temperature sensors
380
382
  if (this.roomTemperatureSensorService) {
381
383
  this.roomTemperatureSensorService
@@ -455,7 +457,7 @@ class DeviceErv extends EventEmitter {
455
457
  button.state = power ? (setFanSpeed === 4) : false;
456
458
  break;
457
459
  case 15: //PHYSICAL LOCK CONTROLS
458
- button.state = (this.lockPhysicalControl === 1);
460
+ button.state = (this.accessory.lockPhysicalControl === 1);
459
461
  break;
460
462
  case 16: //ROOM TEMP HIDE
461
463
  button.state = (hideRoomTemperature === true);
@@ -505,14 +507,14 @@ class DeviceErv extends EventEmitter {
505
507
  const operationModeText = !power ? CONSTANTS.Ventilation.System[0] : CONSTANTS.Ventilation.OperationMode[ventilationMode];
506
508
  this.emit('message', `Power: ${power ? 'ON' : 'OFF'}`);
507
509
  this.emit('message', `Operation mode: ${operationModeText}`);
508
- this.emit('message', `Room temperature: ${roomTemperature}${this.temperatureUnit}`);
509
- const info = hasCoolOperationMode || hasHeatOperationMode ? this.emit('message', `Target temperature: ${targetTemperature}${this.temperatureUnit}`) : false;
510
- const info1 = hasSupplyTemperature && this.supplyTemperature !== null ? this.emit('message', `Supply temperature: ${roomTemperature}${this.temperatureUnit}`) : false;
511
- const info2 = hasOutdoorTemperature && this.outdoorTemperature !== null ? this.emit('message', `Outdoor temperature: ${roomTemperature}${this.temperatureUnit}`) : false;
512
- const info3 = hasHeatOperationMode && displayMode === 0 ? this.emit('message', `Heating threshold temperature: ${targetTemperature}${this.temperatureUnit}`) : false;
513
- const info4 = hasCoolOperationMode && displayMode === 0 ? this.emit('message', `Cooling threshold temperature: ${targetTemperature}${this.temperatureUnit}`) : false;
510
+ this.emit('message', `Room temperature: ${roomTemperature}${temperatureUnit}`);
511
+ const info = hasCoolOperationMode || hasHeatOperationMode ? this.emit('message', `Target temperature: ${targetTemperature}${temperatureUnit}`) : false;
512
+ const info1 = hasSupplyTemperature && this.accessory.supplyTemperature !== null ? this.emit('message', `Supply temperature: ${roomTemperature}${temperatureUnit}`) : false;
513
+ const info2 = hasOutdoorTemperature && this.accessory.outdoorTemperature !== null ? this.emit('message', `Outdoor temperature: ${roomTemperature}${temperatureUnit}`) : false;
514
+ const info3 = hasHeatOperationMode && displayMode === 0 ? this.emit('message', `Heating threshold temperature: ${targetTemperature}${temperatureUnit}`) : false;
515
+ const info4 = hasCoolOperationMode && displayMode === 0 ? this.emit('message', `Cooling threshold temperature: ${targetTemperature}${temperatureUnit}`) : false;
514
516
  this.emit('message', `Fan speed mode: ${CONSTANTS.Ventilation.FanSpeed[setFanSpeed]}`);
515
- this.emit('message', `Temperature display unit: ${this.temperatureUnit}`);
517
+ this.emit('message', `Temperature display unit: ${temperatureUnit}`);
516
518
  this.emit('message', `Core maintenance: ${CONSTANTS.Ventilation.CoreMaintenance[coreMaintenanceRequired]}`);
517
519
  this.emit('message', `Filter maintenance: ${CONSTANTS.Ventilation.FilterMaintenance[filterMaintenanceRequired]}`);
518
520
  const info5 = hasCO2Sensor ? this.emit('message', `CO2 detected: ${CONSTANTS.Ventilation.Co2Detected[roomCO2Detected]}`) : false;
@@ -640,14 +642,14 @@ class DeviceErv extends EventEmitter {
640
642
  const temperatureSensorSupply = this.temperatureSensorSupply;
641
643
  const buttonsConfigured = this.buttonsConfigured;
642
644
  const buttonsConfiguredCount = this.buttonsConfiguredCount;
643
- const presets = this.presets;
645
+ const presets = this.accessory.presets;
644
646
  const presetsCount = this.presetsCount;
645
- const hasCoolOperationMode = this.hasCoolOperationMode;
646
- const hasHeatOperationMode = this.hasHeatOperationMode;
647
- const hasCO2Sensor = this.hasCO2Sensor;
648
- const hasPM25Sensor = this.hasPM25Sensor;
649
- const hasAutoVentilationMode = this.hasAutoVentilationMode;
650
- const hasBypassVentilationMode = this.hasBypassVentilationMode;
647
+ const hasCoolOperationMode = this.accessory.hasCoolOperationMode;
648
+ const hasHeatOperationMode = this.accessory.hasHeatOperationMode;
649
+ const hasCO2Sensor = this.accessory.hasCO2Sensor;
650
+ const hasPM25Sensor = this.accessory.hasPM25Sensor;
651
+ const hasAutoVentilationMode = this.accessory.hasAutoVentilationMode;
652
+ const hasBypassVentilationMode = this.accessory.hasBypassVentilationMode;
651
653
  const serviceName = `${deviceTypeText} ${accessoryName}`;
652
654
 
653
655
  switch (displayMode) {
@@ -656,7 +658,7 @@ class DeviceErv extends EventEmitter {
656
658
  this.melCloudService = accessory.addService(Service.HeaterCooler, serviceName, `HeaterCooler ${deviceId}`);
657
659
  this.melCloudService.getCharacteristic(Characteristic.Active)
658
660
  .onGet(async () => {
659
- const state = this.power;
661
+ const state = this.accessory.power;
660
662
  return state;
661
663
  })
662
664
  .onSet(async (state) => {
@@ -672,17 +674,17 @@ class DeviceErv extends EventEmitter {
672
674
  });
673
675
  this.melCloudService.getCharacteristic(Characteristic.CurrentHeaterCoolerState)
674
676
  .onGet(async () => {
675
- const value = this.currentOperationMode;
677
+ const value = this.accessory.currentOperationMode;
676
678
  return value;
677
679
  });
678
680
  this.melCloudService.getCharacteristic(Characteristic.TargetHeaterCoolerState)
679
681
  .setProps({
680
- minValue: this.operationModeSetPropsMinValue,
681
- maxValue: this.operationModeSetPropsMaxValue,
682
- validValues: this.operationModeSetPropsValidValues
682
+ minValue: this.accessory.operationModeSetPropsMinValue,
683
+ maxValue: this.accessory.operationModeSetPropsMaxValue,
684
+ validValues: this.accessory.operationModeSetPropsValidValues
683
685
  })
684
686
  .onGet(async () => {
685
- const value = this.targetOperationMode; //LOSSNAY, BYPASS, AUTO
687
+ const value = this.accessory.targetOperationMode; //LOSSNAY, BYPASS, AUTO
686
688
  return value;
687
689
  })
688
690
  .onSet(async (value) => {
@@ -715,11 +717,11 @@ class DeviceErv extends EventEmitter {
715
717
  this.melCloudService.getCharacteristic(Characteristic.RotationSpeed)
716
718
  .setProps({
717
719
  minValue: 0,
718
- maxValue: this.fanSpeedSetPropsMaxValue,
720
+ maxValue: this.accessory.fanSpeedSetPropsMaxValue,
719
721
  minStep: 1
720
722
  })
721
723
  .onGet(async () => {
722
- const value = this.fanSpeed; //STOP, 1, 2, 3, 4, OFF
724
+ const value = this.accessory.fanSpeed; //STOP, 1, 2, 3, 4, OFF
723
725
  return value;
724
726
  })
725
727
  .onSet(async (value) => {
@@ -756,7 +758,7 @@ class DeviceErv extends EventEmitter {
756
758
  minStep: 0.5
757
759
  })
758
760
  .onGet(async () => {
759
- const value = this.roomTemperature;
761
+ const value = this.accessory.roomTemperature;
760
762
  return value;
761
763
  });
762
764
  //device can heat
@@ -765,10 +767,10 @@ class DeviceErv extends EventEmitter {
765
767
  .setProps({
766
768
  minValue: 0,
767
769
  maxValue: 31,
768
- minStep: this.temperatureIncrement
770
+ minStep: this.accessory.temperatureIncrement
769
771
  })
770
772
  .onGet(async () => {
771
- const value = this.setTemperature;
773
+ const value = this.accessory.setTemperature;
772
774
  return value;
773
775
  })
774
776
  .onSet(async (value) => {
@@ -776,7 +778,7 @@ class DeviceErv extends EventEmitter {
776
778
  deviceState.SetTemperature = value;
777
779
  deviceState.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.SetTemperature;
778
780
  await this.melCloudErv.send(deviceState);
779
- const info = this.disableLogInfo ? false : this.emit('message', `Set heating threshold temperature: ${value}${this.temperatureUnit}`);
781
+ const info = this.disableLogInfo ? false : this.emit('message', `Set heating threshold temperature: ${value}${this.accessory.temperatureUnit}`);
780
782
  } catch (error) {
781
783
  this.emit('warn', `Set heating threshold temperature error: ${error}`);
782
784
  };
@@ -788,10 +790,10 @@ class DeviceErv extends EventEmitter {
788
790
  .setProps({
789
791
  minValue: 10,
790
792
  maxValue: 31,
791
- minStep: this.temperatureIncrement
793
+ minStep: this.accessory.temperatureIncrement
792
794
  })
793
795
  .onGet(async () => {
794
- const value = this.setTemperature;
796
+ const value = this.accessory.setTemperature;
795
797
  return value;
796
798
  })
797
799
  .onSet(async (value) => {
@@ -799,7 +801,7 @@ class DeviceErv extends EventEmitter {
799
801
  deviceState.SetTemperature = value;
800
802
  deviceState.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.SetTemperature;
801
803
  await this.melCloudErv.send(deviceState);
802
- const info = this.disableLogInfo ? false : this.emit('message', `Set cooling threshold temperature: ${value}${this.temperatureUnit}`);
804
+ const info = this.disableLogInfo ? false : this.emit('message', `Set cooling threshold temperature: ${value}${this.accessory.temperatureUnit}`);
803
805
  } catch (error) {
804
806
  this.emit('warn', `Set cooling threshold temperature error: ${error}`);
805
807
  };
@@ -807,7 +809,7 @@ class DeviceErv extends EventEmitter {
807
809
  };
808
810
  //this.melCloudService.getCharacteristic(Characteristic.LockPhysicalControls)
809
811
  // .onGet(async () => {
810
- // const value = this.lockPhysicalControl;
812
+ // const value = this.accessory.lockPhysicalControl;
811
813
  // const info = this.disableLogInfo ? false : this.emit('message', `Lock physical controls: ${value ? 'LOCKED' : 'UNLOCKED'}`);
812
814
  // return value;
813
815
  // })
@@ -824,13 +826,13 @@ class DeviceErv extends EventEmitter {
824
826
  // });
825
827
  this.melCloudService.getCharacteristic(Characteristic.TemperatureDisplayUnits)
826
828
  .onGet(async () => {
827
- const value = this.useFahrenheit;
829
+ const value = this.accessory.useFahrenheit;
828
830
  return value;
829
831
  })
830
832
  .onSet(async (value) => {
831
833
  try {
832
- this.useFahrenheit = value ? true : false;
833
- accountInfo.UseFahrenheit = this.useFahrenheit;
834
+ this.accessory.useFahrenheit = value ? true : false;
835
+ accountInfo.UseFahrenheit = this.accessory.useFahrenheit;
834
836
  await this.melCloud.send(accountInfo);
835
837
  const info = this.disableLogInfo ? false : this.emit('message', `Set temperature display unit: ${CONSTANTS.TemperatureDisplayUnits[value]}`);
836
838
  } catch (error) {
@@ -843,17 +845,17 @@ class DeviceErv extends EventEmitter {
843
845
  this.melCloudService = accessory.addService(Service.Thermostat, serviceName, `Thermostat ${deviceId}`);
844
846
  this.melCloudService.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
845
847
  .onGet(async () => {
846
- const value = this.currentOperationMode;
848
+ const value = this.accessory.currentOperationMode;
847
849
  return value;
848
850
  });
849
851
  this.melCloudService.getCharacteristic(Characteristic.TargetHeatingCoolingState)
850
852
  .setProps({
851
- minValue: this.operationModeSetPropsMinValue,
852
- maxValue: this.operationModeSetPropsMaxValue,
853
- validValues: this.operationModeSetPropsValidValues
853
+ minValue: this.accessory.operationModeSetPropsMinValue,
854
+ maxValue: this.accessory.operationModeSetPropsMaxValue,
855
+ validValues: this.accessory.operationModeSetPropsValidValues
854
856
  })
855
857
  .onGet(async () => {
856
- const value = this.targetOperationMode; //LOSSNAY, BYPASS, AUTO
858
+ const value = this.accessory.targetOperationMode; //LOSSNAY, BYPASS, AUTO
857
859
  return value;
858
860
  })
859
861
  .onSet(async (value) => {
@@ -894,17 +896,17 @@ class DeviceErv extends EventEmitter {
894
896
  minStep: 0.5
895
897
  })
896
898
  .onGet(async () => {
897
- const value = this.roomTemperature;
899
+ const value = this.accessory.roomTemperature;
898
900
  return value;
899
901
  });
900
902
  this.melCloudService.getCharacteristic(Characteristic.TargetTemperature)
901
903
  .setProps({
902
904
  minValue: 0,
903
905
  maxValue: 31,
904
- minStep: this.temperatureIncrement
906
+ minStep: this.accessory.temperatureIncrement
905
907
  })
906
908
  .onGet(async () => {
907
- const value = this.setTemperature;
909
+ const value = this.accessory.setTemperature;
908
910
  return value;
909
911
  })
910
912
  .onSet(async (value) => {
@@ -912,20 +914,20 @@ class DeviceErv extends EventEmitter {
912
914
  deviceState.SetTemperature = value;
913
915
  deviceState.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.SetTemperature;
914
916
  await this.melCloudErv.send(deviceState);
915
- const info = this.disableLogInfo ? false : this.emit('message', `Set temperature: ${value}${this.temperatureUnit}`);
917
+ const info = this.disableLogInfo ? false : this.emit('message', `Set temperature: ${value}${this.accessory.temperatureUnit}`);
916
918
  } catch (error) {
917
919
  this.emit('warn', `Set temperature error: ${error}`);
918
920
  };
919
921
  });
920
922
  this.melCloudService.getCharacteristic(Characteristic.TemperatureDisplayUnits)
921
923
  .onGet(async () => {
922
- const value = this.useFahrenheit;
924
+ const value = this.accessory.useFahrenheit;
923
925
  return value;
924
926
  })
925
927
  .onSet(async (value) => {
926
928
  try {
927
- this.useFahrenheit = value ? true : false;
928
- accountInfo.UseFahrenheit = this.useFahrenheit;
929
+ this.accessory.useFahrenheit = value ? true : false;
930
+ accountInfo.UseFahrenheit = this.accessory.useFahrenheit;
929
931
  await this.melCloud.send(accountInfo);
930
932
  const info = this.disableLogInfo ? false : this.emit('message', `Set temperature display unit: ${CONSTANTS.TemperatureDisplayUnits[value]}`);
931
933
  } catch (error) {
@@ -936,7 +938,7 @@ class DeviceErv extends EventEmitter {
936
938
  };
937
939
 
938
940
  //temperature sensor service room
939
- if (temperatureSensor && this.hasRoomTemperature && this.roomTemperature !== null) {
941
+ if (temperatureSensor && this.accessory.hasRoomTemperature && this.accessory.roomTemperature !== null) {
940
942
  const debug = this.enableDebugMode ? this.emit('debug', `Prepare room temperature sensor service`) : false;
941
943
  this.roomTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Room`, `Room Temperature Sensor ${deviceId}`);
942
944
  this.roomTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
@@ -948,14 +950,14 @@ class DeviceErv extends EventEmitter {
948
950
  minStep: 0.5
949
951
  })
950
952
  .onGet(async () => {
951
- const state = this.roomTemperature;
953
+ const state = this.accessory.roomTemperature;
952
954
  return state;
953
955
  })
954
956
  accessory.addService(this.roomTemperatureSensorService);
955
957
  };
956
958
 
957
959
  //temperature sensor service supply
958
- if (temperatureSensorSupply && this.hasSupplyTemperature && this.supplyTemperature !== null) {
960
+ if (temperatureSensorSupply && this.accessory.hasSupplyTemperature && this.accessory.supplyTemperature !== null) {
959
961
  const debug = this.enableDebugMode ? this.emit('debug', `Prepare supply temperature sensor service`) : false;
960
962
  this.supplyTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Supply`, `Supply Temperature Sensor ${deviceId}`);
961
963
  this.supplyTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
@@ -967,14 +969,14 @@ class DeviceErv extends EventEmitter {
967
969
  minStep: 0.5
968
970
  })
969
971
  .onGet(async () => {
970
- const state = this.supplyTemperature;
972
+ const state = this.accessory.supplyTemperature;
971
973
  return state;
972
974
  })
973
975
  accessory.addService(this.supplyTemperatureSensorService);
974
976
  };
975
977
 
976
978
  //temperature sensor service outdoor
977
- if (temperatureSensorOutdoor && this.hasOutdoorTemperature && this.outdoorTemperature !== null) {
979
+ if (temperatureSensorOutdoor && this.accessory.hasOutdoorTemperature && this.accessory.outdoorTemperature !== null) {
978
980
  const debug = this.enableDebugMode ? this.emit('debug', `Prepare outdoor temperature sensor service`) : false;
979
981
  this.outdoorTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Outdoor`, `Outdoor Temperature Sensor ${deviceId}`);
980
982
  this.outdoorTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
@@ -986,7 +988,7 @@ class DeviceErv extends EventEmitter {
986
988
  minStep: 0.5
987
989
  })
988
990
  .onGet(async () => {
989
- const state = this.outdoorTemperature;
991
+ const state = this.accessory.outdoorTemperature;
990
992
  return state;
991
993
  })
992
994
  accessory.addService(this.outdoorTemperatureSensorService);
@@ -998,7 +1000,7 @@ class DeviceErv extends EventEmitter {
998
1000
  this.coreMaintenanceService.setCharacteristic(Characteristic.ConfiguredName, `${serviceName} Core Maintenance`);
999
1001
  this.coreMaintenanceService.getCharacteristic(Characteristic.FilterChangeIndication)
1000
1002
  .onGet(async () => {
1001
- const value = this.coreMaintenanceRequired;
1003
+ const value = this.accessory.coreMaintenanceRequired;
1002
1004
  return value;
1003
1005
  });
1004
1006
  this.coreMaintenanceService.getCharacteristic(Characteristic.ResetFilterIndication)
@@ -1012,7 +1014,7 @@ class DeviceErv extends EventEmitter {
1012
1014
  this.filterMaintenanceService.setCharacteristic(Characteristic.ConfiguredName, `${serviceName} Filter Maintenance`);
1013
1015
  this.filterMaintenanceService.getCharacteristic(Characteristic.FilterChangeIndication)
1014
1016
  .onGet(async () => {
1015
- const value = this.filterMaintenanceRequired;
1017
+ const value = this.accessory.filterMaintenanceRequired;
1016
1018
  return value;
1017
1019
  });
1018
1020
  this.filterMaintenanceService.getCharacteristic(Characteristic.ResetFilterIndication)
@@ -1027,12 +1029,12 @@ class DeviceErv extends EventEmitter {
1027
1029
  this.carbonDioxideSensorService.setCharacteristic(Characteristic.ConfiguredName, `${serviceName} CO2 Sensor`);
1028
1030
  this.carbonDioxideSensorService.getCharacteristic(Characteristic.CarbonDioxideDetected)
1029
1031
  .onGet(async () => {
1030
- const value = this.roomCO2Detected;
1032
+ const value = this.accessory.roomCO2Detected;
1031
1033
  return value;
1032
1034
  });
1033
1035
  this.carbonDioxideSensorService.getCharacteristic(Characteristic.CarbonDioxideLevel)
1034
1036
  .onGet(async () => {
1035
- const value = this.roomCO2Level;
1037
+ const value = this.accessory.roomCO2Level;
1036
1038
  return value;
1037
1039
  });
1038
1040
  accessory.addService(this.carbonDioxideSensorService);
@@ -1045,12 +1047,12 @@ class DeviceErv extends EventEmitter {
1045
1047
  this.airQualitySensorService.setCharacteristic(Characteristic.ConfiguredName, `${serviceName} PM2.5 Sensor`);
1046
1048
  this.airQualitySensorService.getCharacteristic(Characteristic.AirQuality)
1047
1049
  .onGet(async () => {
1048
- const value = this.pM25AirQuality;
1050
+ const value = this.accessory.pM25AirQuality;
1049
1051
  return value;
1050
1052
  });
1051
1053
  this.airQualitySensorService.getCharacteristic(Characteristic.PM2_5Density)
1052
1054
  .onGet(async () => {
1053
- const value = this.pM25Level;
1055
+ const value = this.accessory.pM25Level;
1054
1056
  return value;
1055
1057
  });
1056
1058
  accessory.addService(this.airQualitySensorService);