homebridge-melcloud-control 2.3.1-beta.1 → 2.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -21,6 +21,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
21
21
 
22
22
  - After update to v2 from v1 only RESTFull and MQTT config settings need to be updated in config.
23
23
 
24
+ ## [2.4.0] - (28.08.2024)
25
+
26
+ ## Changes
27
+
28
+ - required upcomming homebridge 2.x.x required
29
+ - bump dependencies
30
+ - config schema updated
31
+
32
+ ## [2.3.3] - (28.08.2024)
33
+
34
+ ## Changes
35
+
36
+ - cleanup and refactor accessory code
37
+ - bump dependencies
38
+
24
39
  ## [2.3.0] - (25.08.2024)
25
40
 
26
41
  ## Changes
@@ -629,7 +629,7 @@
629
629
  ]
630
630
  }
631
631
  ],
632
- "description": "Select the characterristic type to be displayed in HomeKit app.",
632
+ "description": "Select the characteristic type to be displayed in HomeKit app.",
633
633
  "required": true
634
634
  },
635
635
  "namePrefix": {
@@ -956,7 +956,7 @@
956
956
  ]
957
957
  }
958
958
  ],
959
- "description": "Select the characterristic type to be displayed in HomeKit app.",
959
+ "description": "Select the characteristic type to be displayed in HomeKit app.",
960
960
  "required": true
961
961
  },
962
962
  "namePrefix": {
@@ -1193,7 +1193,7 @@
1193
1193
  ]
1194
1194
  }
1195
1195
  ],
1196
- "description": "Select the characterristic type to be displayed in HomeKit app.",
1196
+ "description": "Select the characteristic type to be displayed in HomeKit app.",
1197
1197
  "required": false
1198
1198
  },
1199
1199
  "namePrefix": {
package/index.js CHANGED
@@ -98,13 +98,13 @@ class MelCloudPlatform {
98
98
 
99
99
  //publish device
100
100
  api.publishExternalAccessories(CONSTANTS.PluginName, [accessory]);
101
- log.success(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`);
101
+ log.info(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`);
102
102
  })
103
103
  .on('devInfo', (devInfo) => {
104
104
  log.info(devInfo);
105
105
  })
106
106
  .on('success', (message) => {
107
- log.success(`${deviceTypeText}, ${deviceName}, ${message}`);
107
+ log.info(`${deviceTypeText}, ${deviceName}, ${message}`);
108
108
  })
109
109
  .on('message', (message) => {
110
110
  log.info(`${deviceTypeText}, ${deviceName}, ${message}`);
@@ -130,13 +130,13 @@ class MelCloudPlatform {
130
130
 
131
131
  //publish device
132
132
  api.publishExternalAccessories(CONSTANTS.PluginName, [accessory]);
133
- log.success(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`);
133
+ log.info(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`);
134
134
  })
135
135
  .on('devInfo', (devInfo) => {
136
136
  log.info(devInfo);
137
137
  })
138
138
  .on('success', (message) => {
139
- log.success(`${deviceTypeText}, ${deviceName}, ${message}`);
139
+ log.info(`${deviceTypeText}, ${deviceName}, ${message}`);
140
140
  })
141
141
  .on('message', (message) => {
142
142
  log.info(`${deviceTypeText}, ${deviceName}, ${message}`);
@@ -162,13 +162,13 @@ class MelCloudPlatform {
162
162
 
163
163
  //publish device
164
164
  api.publishExternalAccessories(CONSTANTS.PluginName, [accessory]);
165
- log.success(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`);
165
+ log.info(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`);
166
166
  })
167
167
  .on('devInfo', (devInfo) => {
168
168
  log.info(devInfo);
169
169
  })
170
170
  .on('success', (message) => {
171
- log.success(`${deviceTypeText}, ${deviceName}, ${message}`);
171
+ log.info(`${deviceTypeText}, ${deviceName}, ${message}`);
172
172
  })
173
173
  .on('message', (message) => {
174
174
  log.info(`${deviceTypeText}, ${deviceName}, ${message}`);
@@ -189,7 +189,7 @@ class MelCloudPlatform {
189
189
  }
190
190
  })
191
191
  .on('success', (message) => {
192
- log.success(`Account ${accountName}, ${message}`);
192
+ log.info(`Account ${accountName}, ${message}`);
193
193
  })
194
194
  .on('message', (message) => {
195
195
  log.info(`Account ${accountName}, ${message}`);
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.1",
4
+ "version": "2.3.3",
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
@@ -197,8 +197,7 @@ class DeviceAta extends EventEmitter {
197
197
  const offline = deviceState.Offline;
198
198
 
199
199
  //presets
200
- const presets = deviceData.Presets ?? [];
201
- this.presetsCount = this.presetsEnabled ? presets.length : 0;
200
+ const presets = this.presetsEnabled ? deviceData.Presets : [];
202
201
 
203
202
  //accessory
204
203
  this.accessory.power = power;
@@ -212,6 +211,8 @@ class DeviceAta extends EventEmitter {
212
211
  this.accessory.targetOperationMode = 0;
213
212
  this.accessory.vaneHorizontal = vaneHorizontal;
214
213
  this.accessory.vaneVertical = vaneVertical;
214
+ this.accessory.swingMode = swingFunction && vaneHorizontal === 12 && vaneVertical === 7 ? 1 : 0;
215
+ this.accessory.lockPhysicalControl = prohibitSetTemperature && prohibitOperationMode && prohibitPower ? 1 : 0;
215
216
  this.accessory.temperatureIncrement = temperatureIncrement;
216
217
  this.accessory.useFahrenheit = useFahrenheit;
217
218
  this.accessory.hasAutomaticFanSpeed = hasAutomaticFanSpeed;
@@ -222,6 +223,10 @@ class DeviceAta extends EventEmitter {
222
223
  this.accessory.modelSupportsFanSpeed = modelSupportsFanSpeed;
223
224
  this.accessory.modelSupportsDry = modelSupportsDry;
224
225
  this.accessory.presets = presets;
226
+ this.accessory.operationModeSetPropsMinValue = 0;
227
+ this.accessory.operationModeSetPropsMaxValue = 3;
228
+ this.accessory.operationModeSetPropsValidValues = [0];
229
+ this.accessory.fanSpeedSetPropsMaxValue = 2;
225
230
 
226
231
  //operating mode
227
232
  switch (displayMode) {
@@ -308,12 +313,6 @@ class DeviceAta extends EventEmitter {
308
313
  };
309
314
  };
310
315
 
311
- //swing and vane mode
312
- this.accessory.swingMode = swingFunction && vaneHorizontal === 12 && vaneVertical === 7 ? 1 : 0;
313
-
314
- //lock physical controls
315
- this.accessory.lockPhysicalControl = prohibitSetTemperature && prohibitOperationMode && prohibitPower ? 1 : 0;
316
-
317
316
  //update characteristics
318
317
  if (this.melCloudService) {
319
318
  this.melCloudService
@@ -534,10 +533,10 @@ class DeviceAta extends EventEmitter {
534
533
  };
535
534
 
536
535
  //update presets state
537
- if (this.presetsCount > 0) {
536
+ if (presets.length > 0) {
538
537
  this.presetsStates = [];
539
538
 
540
- for (let i = 0; i < this.presetsCount; i++) {
539
+ for (let i = 0; i < presets.length; i++) {
541
540
  const preset = presets[i];
542
541
  const state = preset.Power === power
543
542
  && preset.SetTemperature === setTemperature
@@ -699,7 +698,6 @@ class DeviceAta extends EventEmitter {
699
698
  const buttonsConfigured = this.buttonsConfigured;
700
699
  const buttonsConfiguredCount = this.buttonsConfiguredCount;
701
700
  const presets = this.accessory.presets;
702
- const presetsCount = this.presetsCount;
703
701
  const hasAutomaticFanSpeed = this.accessory.hasAutomaticFanSpeed;
704
702
  const modelSupportsFanSpeed = this.accessory.modelSupportsFanSpeed;
705
703
  const modelSupportsDry = this.accessory.modelSupportsDry;
@@ -1281,12 +1279,12 @@ class DeviceAta extends EventEmitter {
1281
1279
  };
1282
1280
 
1283
1281
  //presets services
1284
- if (presetsCount > 0) {
1282
+ if (presets.length > 0) {
1285
1283
  const debug = this.enableDebugMode ? this.emit('debug', `Prepare presets service`) : false;
1286
1284
  this.presetsServices = [];
1287
1285
  const previousPresets = [];
1288
1286
 
1289
- for (let i = 0; i < presetsCount; i++) {
1287
+ for (let i = 0; i < presets.length; i++) {
1290
1288
  const preset = presets[i];
1291
1289
  const presetName = preset.NumberDescription;
1292
1290
 
package/src/deviceatw.js CHANGED
@@ -65,18 +65,7 @@ class DeviceAtw extends EventEmitter {
65
65
 
66
66
  //accessory
67
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
- };
68
+ this.accessory = { zones: [{}, {}, {}, {}] };
80
69
 
81
70
  //melcloud device
82
71
  this.melCloudAtw = new MelCloudAtw({
@@ -196,26 +185,15 @@ class DeviceAtw extends EventEmitter {
196
185
  const minSetTemperature = deviceData.Device.MinSetTemperature ?? 10;
197
186
  const maxSetTemperature = deviceData.Device.MaxSetTemperature ?? 30;
198
187
  const maxTankTemperature = deviceData.Device.MaxTankTemperature ?? 70;
199
- const flowTemperature = deviceData.Device.FlowTemperature;
188
+ const flowTemperatureHeatPump = deviceData.Device.FlowTemperature;
200
189
  const flowTemperatureZone1 = deviceData.Device.FlowTemperatureZone1;
201
190
  const flowTemperatureZone2 = deviceData.Device.FlowTemperatureZone2;
202
191
  const flowTemperatureWaterTank = deviceData.Device.FlowTemperatureBoiler;
203
- const returnTemperature = deviceData.Device.ReturnTemperature;
192
+ const returnTemperatureHeatPump = deviceData.Device.ReturnTemperature;
204
193
  const returnTemperatureZone1 = deviceData.Device.ReturnTemperatureZone1;
205
194
  const returnTemperatureZone2 = deviceData.Device.ReturnTemperatureZone2;
206
195
  const returnTemperatureWaterTank = deviceData.Device.ReturnTemperatureBoiler;
207
196
 
208
- this.hasHotWaterTank = hasHotWaterTank;
209
- this.hasZone2 = hasZone2;
210
- this.flowTemperature = flowTemperature;
211
- this.flowTemperatureZone1 = flowTemperatureZone1;
212
- this.flowTemperatureZone2 = flowTemperatureZone2;
213
- this.flowTemperatureWaterTank = flowTemperatureWaterTank;
214
- this.returnTemperature = returnTemperature;
215
- this.returnTemperatureZone1 = returnTemperatureZone1;
216
- this.returnTemperatureZone2 = returnTemperatureZone2;
217
- this.returnTemperatureWaterTank = returnTemperatureWaterTank;
218
-
219
197
  //zones
220
198
  const hotWater = hasHotWaterTank ? 1 : 0;
221
199
  const zone2 = hasZone2 ? 1 : 0;
@@ -256,8 +234,7 @@ class DeviceAtw extends EventEmitter {
256
234
  const offline = deviceState.Offline;
257
235
 
258
236
  //presets
259
- const presets = deviceData.Presets ?? [];
260
- this.presetsCount = this.presetsEnabled ? presets.length : 0;
237
+ const presets = this.presetsEnabled ? deviceData.Presets : [];
261
238
 
262
239
  //accessory
263
240
  this.accessory.power = power;
@@ -268,15 +245,19 @@ class DeviceAtw extends EventEmitter {
268
245
  this.accessory.useFahrenheit = useFahrenheit;
269
246
  this.accessory.temperatureUnit = temperatureUnit;
270
247
  this.accessory.temperatureIncrement = temperatureIncrement;
248
+ this.accessory.hasHotWaterTank = hasHotWaterTank;
249
+ this.accessory.hasZone2 = hasZone2;
271
250
  this.accessory.presets = presets;
272
251
 
273
252
  //default values
253
+ let name = 'Heat Pump'
274
254
  let currentOperationMode = 0;
275
255
  let targetOperationMode = 0;
276
256
  let roomTemperature = 20;
277
257
  let setTemperature = 20;
278
258
  let lockPhysicalControl = 0;
279
-
259
+ let flowTemperature = 0;
260
+ let returnTemperature = 0;
280
261
  let operationModeSetPropsMinValue = 0;
281
262
  let operationModeSetPropsMaxValue = 3;
282
263
  let operationModeSetPropsValidValues = [0];
@@ -288,60 +269,68 @@ class DeviceAtw extends EventEmitter {
288
269
  case 0: //Heater Cooler
289
270
  switch (i) {
290
271
  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
272
+ name = heatPumpName;
291
273
  currentOperationMode = !power ? 0 : [1, 2, 2, 3, 2, 1, 1, 2, 1, 1, 1, 2][operationMode]; //INACTIVE, IDLE, HEATING, COOLING
292
274
  targetOperationMode = [1, 2][unitStatus]; //AUTO, HEAT, COOL
293
275
  roomTemperature = outdoorTemperature;
294
276
  setTemperature = outdoorTemperature;
295
277
  lockPhysicalControl = hasHotWaterTank && hasZone2 ? (prohibitZone1 && prohibitHotWater && prohibitZone2 ? 1 : 0) : hasHotWaterTank ? (prohibitZone1 && prohibitHotWater ? 1 : 0) : hasZone2 ? (prohibitZone1 && prohibitZone2 ? 1 : 0) : 0;
278
+ flowTemperature = flowTemperatureHeatPump;
279
+ returnTemperature = returnTemperatureHeatPump;
296
280
 
297
281
  operationModeSetPropsMinValue = [1, 1, 2, 0][heatCoolModes];
298
282
  operationModeSetPropsMaxValue = [2, 1, 2, 0][heatCoolModes];
299
283
  operationModeSetPropsValidValues = [[1, 2], [1], [2], [0]][heatCoolModes];
300
284
  temperatureSetPropsMinValue = -35;
301
285
  temperatureSetPropsMaxValue = 100;
302
- this.accessory.zones[i].name = heatPumpName;
303
286
  break;
304
287
  case 1: //Zone 1 - HEAT THERMOSTAT, HEAT FLOW, HEAT CURVE, COOL THERMOSTAT, COOL FLOW, FLOOR DRY UP
288
+ name = zone1Name;
305
289
  currentOperationMode = !power ? 0 : idleZone1 ? 1 : [2, 2, 2, 3, 3, 2][operationModeZone1]; //INACTIVE, IDLE, HEATING, COOLING
306
290
  targetOperationMode = [1, 2, 0, 1, 2, 1][operationModeZone1]; //AUTO, HEAT, COOL
307
291
  roomTemperature = roomTemperatureZone1;
308
292
  setTemperature = setTemperatureZone1;
309
293
  lockPhysicalControl = prohibitZone1 ? 1 : 0;
294
+ flowTemperature = flowTemperatureZone1;
295
+ returnTemperature = returnTemperatureZone1;
310
296
 
311
297
  operationModeSetPropsMinValue = [0, 0, 1, 0][heatCoolModes];
312
298
  operationModeSetPropsMaxValue = [2, 2, 2, 0][heatCoolModes];
313
299
  operationModeSetPropsValidValues = [[0, 1, 2], [0, 1, 2], [1, 2], [0]][heatCoolModes];
314
300
  temperatureSetPropsMinValue = 0;
315
301
  temperatureSetPropsMaxValue = 31;
316
- this.accessory.zones[i].name = zone1Name;
317
302
  break;
318
303
  case caseHotWater: //Hot Water - NORMAL, HEAT NOW
304
+ name = hotWaterName;
319
305
  currentOperationMode = !power ? 0 : operationMode === 1 ? 2 : [1, 2][forcedHotWaterMode]; //INACTIVE, IDLE, HEATING, COOLING
320
306
  targetOperationMode = [0, 1][forcedHotWaterMode] //AUTO, HEAT, COOL
321
307
  roomTemperature = tankWaterTemperature;
322
308
  setTemperature = setTankWaterTemperature;
323
309
  lockPhysicalControl = prohibitHotWater ? 1 : 0;
310
+ flowTemperature = flowTemperatureWaterTank;
311
+ returnTemperature = returnTemperatureWaterTank;
324
312
 
325
313
  operationModeSetPropsMinValue = 0;
326
314
  operationModeSetPropsMaxValue = 1;
327
315
  operationModeSetPropsValidValues = [0, 1];
328
316
  temperatureSetPropsMinValue = 0;
329
317
  temperatureSetPropsMaxValue = maxTankTemperature;
330
- this.accessory.zones[i].name = hotWaterName;
331
318
  break;
332
319
  case caseZone2: //Zone 2 - HEAT THERMOSTAT, HEAT FLOW, HEAT CURVE, COOL THERMOSTAT, COOL FLOW, FLOOR DRY UP
320
+ name = zone2Name;
333
321
  currentOperationMode = !power ? 0 : idleZone2 ? 1 : [2, 2, 2, 3, 3, 2][operationModeZone2]; //INACTIVE, IDLE, HEATING, COOLING
334
322
  targetOperationMode = [1, 2, 0, 1, 2, 1][operationModeZone2]; //AUTO, HEAT, COOL
335
323
  roomTemperature = roomTemperatureZone2;
336
324
  setTemperature = setTemperatureZone2;
337
325
  lockPhysicalControl = prohibitZone2 ? 1 : 0;
326
+ flowTemperature = flowTemperatureZone2;
327
+ returnTemperature = returnTemperatureZone2;
338
328
 
339
329
  operationModeSetPropsMinValue = [0, 0, 1, 0][heatCoolModes];
340
330
  operationModeSetPropsMaxValue = [2, 2, 2, 0][heatCoolModes];
341
331
  operationModeSetPropsValidValues = [[0, 1, 2], [0, 1, 2], [1, 2], [0]][heatCoolModes];
342
332
  temperatureSetPropsMinValue = 0;
343
333
  temperatureSetPropsMaxValue = 31;
344
- this.accessory.zones[i].name = zone2Name;
345
334
  break;
346
335
  default: //unknown zone detected
347
336
  this.emit('message', `Unknown zone: ${i} detected.`);
@@ -374,6 +363,7 @@ class DeviceAtw extends EventEmitter {
374
363
  operationModeSetPropsValidValues = [[0, 1, 2], [0, 1], [0, 2], [0]][heatCoolModes];
375
364
  temperatureSetPropsMinValue = -35;
376
365
  temperatureSetPropsMaxValue = 100;
366
+ this.accessory.zones[i].name = heatPumpName;
377
367
  break;
378
368
  case 1: //Zone 1 - HEAT THERMOSTAT, HEAT FLOW, HEAT CURVE, COOL THERMOSTAT, COOL FLOW, FLOOR DRY UP
379
369
  currentOperationMode = !power ? 0 : idleZone1 ? 0 : [1, 1, 1, 2, 2, 1][operationModeZone1]; //OFF, HEAT, COOL
@@ -386,6 +376,7 @@ class DeviceAtw extends EventEmitter {
386
376
  operationModeSetPropsValidValues = [[1, 2, 3], [1, 2, 3], [1, 2], [0]][heatCoolModes];
387
377
  temperatureSetPropsMinValue = 0;
388
378
  temperatureSetPropsMaxValue = 31;
379
+ this.accessory.zones[i].name = heatPumpName;
389
380
  break;
390
381
  case caseHotWater: //Hot Water - NORMAL, HEAT NOW
391
382
  currentOperationMode = !power ? 0 : operationMode === 1 ? 1 : [0, 1][forcedHotWaterMode]; //OFF, HEAT, COOL
@@ -398,6 +389,7 @@ class DeviceAtw extends EventEmitter {
398
389
  operationModeSetPropsValidValues = [1, 3];
399
390
  temperatureSetPropsMinValue = 0;
400
391
  temperatureSetPropsMaxValue = 60;
392
+ this.accessory.zones[i].name = heatPumpName;
401
393
  break;
402
394
  case caseZone2: //Zone 2 - HEAT THERMOSTAT, HEAT FLOW, HEAT CURVE, COOL THERMOSTAT, COOL FLOW, FLOOR DRY UP
403
395
  currentOperationMode = !power ? 0 : idleZone2 ? 0 : [1, 1, 1, 2, 2, 1][operationModeZone2]; //OFF, HEAT, COOL
@@ -410,6 +402,7 @@ class DeviceAtw extends EventEmitter {
410
402
  operationModeSetPropsValidValues = [[1, 2, 3], [1, 2, 3], [1, 2], [0]][heatCoolModes];
411
403
  temperatureSetPropsMinValue = 0;
412
404
  temperatureSetPropsMaxValue = 31;
405
+ this.accessory.zones[i].name = heatPumpName;
413
406
  break;
414
407
  default: //unknown zone detected
415
408
  this.emit('message', `Unknown zone: ${i} detected.`);
@@ -432,11 +425,14 @@ class DeviceAtw extends EventEmitter {
432
425
  };
433
426
 
434
427
  //push value to arrays
428
+ this.accessory.zones[i].name = name;
435
429
  this.accessory.zones[i].currentOperationMode = currentOperationMode;
436
430
  this.accessory.zones[i].targetOperationMode = targetOperationMode;
437
431
  this.accessory.zones[i].roomTemperature = roomTemperature;
438
432
  this.accessory.zones[i].setTemperature = setTemperature;
439
433
  this.accessory.zones[i].lockPhysicalControl = lockPhysicalControl;
434
+ this.accessory.zones[i].flowTemperature = flowTemperature;
435
+ this.accessory.zones[i].returnTemperature = returnTemperature;
440
436
  this.accessory.zones[i].operationModesSetPropsMinValue = operationModeSetPropsMinValue;
441
437
  this.accessory.zones[i].operationModesSetPropsMaxValue = operationModeSetPropsMaxValue;
442
438
  this.accessory.zones[i].operationModesSetPropsValidValues = operationModeSetPropsValidValues;
@@ -648,10 +644,10 @@ class DeviceAtw extends EventEmitter {
648
644
  };
649
645
 
650
646
  //update presets state
651
- if (this.presetsCount > 0) {
647
+ if (presets.length > 0) {
652
648
  this.presetsStates = [];
653
649
 
654
- for (let i = 0; i < this.presetsCount; i++) {
650
+ for (let i = 0; i < presets.length; i++) {
655
651
  const preset = presets[i];
656
652
  const state = preset.Power === power
657
653
  && preset.EcoHotWater === ecoHotWater
@@ -829,7 +825,6 @@ class DeviceAtw extends EventEmitter {
829
825
  const buttonsConfigured = this.buttonsConfigured;
830
826
  const buttonsConfiguredCount = this.buttonsConfiguredCount;
831
827
  const presets = this.accessory.presets;
832
- const presetsCount = this.presetsCount;
833
828
  const displayMode = this.displayMode;
834
829
  const caseHotWater = this.caseHotWater;
835
830
  const caseZone2 = this.caseZone2;
@@ -1307,7 +1302,7 @@ class DeviceAtw extends EventEmitter {
1307
1302
  accessory.addService(this.roomTemperatureSensorService);
1308
1303
  };
1309
1304
 
1310
- if (temperatureSensorFlow && this.flowTemperature !== null) {
1305
+ if (temperatureSensorFlow && this.accessory.zones[i].flowTemperature !== null) {
1311
1306
  const debug = this.enableDebugMode ? this.emit('debug', `Prepare flow temperature sensor service`) : false;
1312
1307
  this.flowTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Flow`, `${zoneName} Temperature Sensor Flow ${deviceId} ${i}`);
1313
1308
  this.flowTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
@@ -1319,13 +1314,13 @@ class DeviceAtw extends EventEmitter {
1319
1314
  minStep: 0.5
1320
1315
  })
1321
1316
  .onGet(async () => {
1322
- const state = this.flowTemperature;
1317
+ const state = this.accessory.zones[i].flowTemperature;
1323
1318
  return state;
1324
1319
  })
1325
1320
  accessory.addService(this.flowTemperatureSensorService);
1326
1321
 
1327
1322
  };
1328
- if (temperatureSensorReturn && this.returnTemperature !== null) {
1323
+ if (temperatureSensorReturn && this.accessory.zones[i].returnTemperature !== null) {
1329
1324
  const debug1 = this.enableDebugMode ? this.emit('debug', `Prepare return temperature sensor service`) : false;
1330
1325
  this.returnTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Return`, `${zoneName} Temperature Sensor Return ${deviceId} ${i}`);
1331
1326
  this.returnTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
@@ -1337,7 +1332,7 @@ class DeviceAtw extends EventEmitter {
1337
1332
  minStep: 0.5
1338
1333
  })
1339
1334
  .onGet(async () => {
1340
- const state = this.returnTemperature;
1335
+ const state = this.accessory.zones[i].returnTemperature;
1341
1336
  return state;
1342
1337
  })
1343
1338
  accessory.addService(this.returnTemperatureSensorService);
@@ -1362,7 +1357,7 @@ class DeviceAtw extends EventEmitter {
1362
1357
  accessory.addService(this.roomTemperatureZone1SensorService);
1363
1358
  };
1364
1359
 
1365
- if (temperatureSensorFlowZone1 && this.flowTemperatureZone1 !== null) {
1360
+ if (temperatureSensorFlowZone1 && this.accessory.zones[i].flowTemperature !== null) {
1366
1361
  const debug2 = this.enableDebugMode ? this.emit('debug', `Prepare flow temperature zone 1 sensor service`) : false;
1367
1362
  this.flowTemperatureZone1SensorService = new Service.TemperatureSensor(`${serviceName} Flow`, `${zoneName} Temperature Sensor Flow ${deviceId} ${i}`);
1368
1363
  this.flowTemperatureZone1SensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
@@ -1374,13 +1369,13 @@ class DeviceAtw extends EventEmitter {
1374
1369
  minStep: 0.5
1375
1370
  })
1376
1371
  .onGet(async () => {
1377
- const state = this.flowTemperatureZone1;
1372
+ const state = this.accessory.zones[i].flowTemperature;
1378
1373
  return state;
1379
1374
  })
1380
1375
  accessory.addService(this.flowTemperatureZone1SensorService);
1381
1376
  };
1382
1377
 
1383
- if (temperatureSensorReturnZone1 && this.returnTemperatureZone1 !== null) {
1378
+ if (temperatureSensorReturnZone1 && this.accessory.zones[i].returnTemperature !== null) {
1384
1379
  const debug3 = this.enableDebugMode ? this.emit('debug', `Prepare return temperature zone 1 sensor service`) : false;
1385
1380
  this.returnTemperatureZone1SensorService = new Service.TemperatureSensor(`${serviceName} Return`, `${zoneName} Temperature Sensor Return ${deviceId} ${i}`);
1386
1381
  this.returnTemperatureZone1SensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
@@ -1392,7 +1387,7 @@ class DeviceAtw extends EventEmitter {
1392
1387
  minStep: 0.5
1393
1388
  })
1394
1389
  .onGet(async () => {
1395
- const state = this.returnTemperatureZone1;
1390
+ const state = this.accessory.zones[i].returnTemperature;
1396
1391
  return state;
1397
1392
  })
1398
1393
  accessory.addService(this.returnTemperatureZone1SensorService);
@@ -1417,7 +1412,7 @@ class DeviceAtw extends EventEmitter {
1417
1412
  accessory.addService(this.roomTemperatureWaterTankSensorService);
1418
1413
  };
1419
1414
 
1420
- if (temperatureSensorFlowWaterTank && this.flowTemperatureWaterTank !== null) {
1415
+ if (temperatureSensorFlowWaterTank && this.accessory.zones[i].flowTemperature !== null) {
1421
1416
  const debug = this.enableDebugMode ? this.emit('debug', `Prepare flow temperature water tank sensor service`) : false;
1422
1417
  this.flowTemperatureWaterTankSensorService = new Service.TemperatureSensor(`${serviceName} Flow`, `${zoneName} Temperature Sensor Flow ${deviceId} ${i}`);
1423
1418
  this.flowTemperatureWaterTankSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
@@ -1429,13 +1424,13 @@ class DeviceAtw extends EventEmitter {
1429
1424
  minStep: 0.5
1430
1425
  })
1431
1426
  .onGet(async () => {
1432
- const state = this.flowTemperatureWaterTank;
1427
+ const state = this.accessory.zones[i].flowTemperature;
1433
1428
  return state;
1434
1429
  })
1435
1430
  accessory.addService(this.flowTemperatureWaterTankSensorService);
1436
1431
  };
1437
1432
 
1438
- if (temperatureSensorReturnWaterTank && this.returnTemperatureWaterTank !== null) {
1433
+ if (temperatureSensorReturnWaterTank && this.accessory.zones[i].returnTemperature !== null) {
1439
1434
  const debug1 = this.enableDebugMode ? this.emit('debug', `Prepare return temperature water tank sensor service`) : false;
1440
1435
  this.returnTemperatureWaterTankSensorService = new Service.TemperatureSensor(`${serviceName} Return`, `${zoneName} Temperature Sensor Return ${deviceId} ${i}`);
1441
1436
  this.returnTemperatureWaterTankSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
@@ -1447,7 +1442,7 @@ class DeviceAtw extends EventEmitter {
1447
1442
  minStep: 0.5
1448
1443
  })
1449
1444
  .onGet(async () => {
1450
- const state = this.returnTemperatureWaterTank;
1445
+ const state = this.accessory.zones[i].returnTemperature;
1451
1446
  return state;
1452
1447
  })
1453
1448
  accessory.addService(this.returnTemperatureWaterTankSensorService);
@@ -1472,7 +1467,7 @@ class DeviceAtw extends EventEmitter {
1472
1467
  accessory.addService(this.roomTemperatureZone2SensorService);
1473
1468
  };
1474
1469
 
1475
- if (temperatureSensorFlowZone2 && this.flowTemperatureZone2 !== null) {
1470
+ if (temperatureSensorFlowZone2 && this.accessory.zones[i].flowTemperature !== null) {
1476
1471
  const debug = this.enableDebugMode ? this.emit('debug', `Prepare flow temperature zone 2 sensor service`) : false;
1477
1472
  this.flowTemperatureZone2SensorService = new Service.TemperatureSensor(`${serviceName} Flow`, `${zoneName} Temperature Sensor Flow${deviceId} ${i}`);
1478
1473
  this.flowTemperatureZone2SensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
@@ -1484,13 +1479,13 @@ class DeviceAtw extends EventEmitter {
1484
1479
  minStep: 0.5
1485
1480
  })
1486
1481
  .onGet(async () => {
1487
- const state = this.flowTemperatureZone2;
1482
+ const state = this.accessory.zones[i].flowTemperature;
1488
1483
  return state;
1489
1484
  })
1490
1485
  accessory.addService(this.flowTemperatureZone2SensorService);
1491
1486
  };
1492
1487
 
1493
- if (temperatureSensorReturnZone2 && this.returnTemperatureZone2 !== null) {
1488
+ if (temperatureSensorReturnZone2 && this.accessory.zones[i].returnTemperature !== null) {
1494
1489
  const debug1 = this.enableDebugMode ? this.emit('debug', `Prepare return temperature zone 2 sensor service`) : false;
1495
1490
  this.returnTemperatureZone2SensorService = new Service.TemperatureSensor(`${serviceName} Return`, `${zoneName} Temperature Sensor Return${deviceId} ${i}`);
1496
1491
  this.returnTemperatureZone2SensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
@@ -1502,7 +1497,7 @@ class DeviceAtw extends EventEmitter {
1502
1497
  minStep: 0.5
1503
1498
  })
1504
1499
  .onGet(async () => {
1505
- const state = this.returnTemperatureZone2;
1500
+ const state = this.accessory.zones[i].returnTemperature;
1506
1501
  return state;
1507
1502
  })
1508
1503
  accessory.addService(this.returnTemperatureZone2SensorService);
@@ -1674,12 +1669,12 @@ class DeviceAtw extends EventEmitter {
1674
1669
  };
1675
1670
 
1676
1671
  //presets services
1677
- if (presetsCount > 0) {
1672
+ if (presets.length > 0) {
1678
1673
  const debug = this.enableDebugMode ? this.emit('debug', `Prepare presets service`) : false;
1679
1674
  this.presetsServices = [];
1680
1675
  const previousPresets = [];
1681
1676
 
1682
- for (let i = 0; i < presetsCount; i++) {
1677
+ for (let i = 0; i < presets.length; i++) {
1683
1678
  const preset = presets[i];
1684
1679
  const presetName = preset.NumberDescription;
1685
1680
 
package/src/deviceerv.js CHANGED
@@ -59,16 +59,7 @@ class DeviceErv extends EventEmitter {
59
59
 
60
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,56 @@ 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
- const presets = deviceData.Presets ?? [];
240
- this.presets = presets;
241
- this.presetsCount = this.presetsEnabled ? presets.length : 0;
207
+ const presets = this.presetsEnabled ? deviceData.Presets : [];
242
208
 
243
209
  //set temperature
244
210
  const targetTemperature = hasCoolOperationMode || hasHeatOperationMode ? setTemperature : 20;
245
211
 
212
+ //accessory
213
+ this.accessory.power = power;
214
+ this.accessory.offline = offline;
215
+ this.accessory.roomTemperature = roomTemperature;
216
+ this.accessory.outdoorTemperature = outdoorTemperature;
217
+ this.accessory.supplyTemperature = supplyTemperature;
218
+ this.accessory.setTemperature = targetTemperature;
219
+ this.accessory.fanSpeed = 0;
220
+ this.accessory.setFanSpeed = setFanSpeed;
221
+ this.accessory.currentOperationMode = 0;
222
+ this.accessory.targetOperationMode = 0;
223
+ this.accessory.temperatureIncrement = temperatureIncrement;
224
+ this.accessory.useFahrenheit = useFahrenheit;
225
+ this.accessory.temperatureUnit = temperatureUnit;
226
+ this.accessory.lockPhysicalControl = 0;
227
+ this.accessory.hasAutomaticFanSpeed = hasAutomaticFanSpeed;
228
+ this.accessory.hasOutdoorTemperature = hasOutdoorTemperature;
229
+ this.accessory.numberOfFanSpeeds = numberOfFanSpeeds;
230
+ this.accessory.hasCoolOperationMode = hasCoolOperationMode;
231
+ this.accessory.hasHeatOperationMode = hasHeatOperationMode;
232
+ this.accessory.hasAutoOperationMode = hasAutoOperationMode;
233
+ this.accessory.hasRoomTemperature = hasRoomTemperature;
234
+ this.accessory.hasSupplyTemperature = hasSupplyTemperature;
235
+ this.accessory.hasCO2Sensor = hasCO2Sensor;
236
+ this.accessory.roomCO2Level = roomCO2Level;
237
+ this.accessory.roomCO2Detected = roomCO2Detected;
238
+ this.accessory.hasPM25Sensor = hasPM25Sensor;
239
+ this.accessory.pM25SensorStatus = pM25SensorStatus;
240
+ this.accessory.pM25Level = pM25Level;
241
+ this.accessory.pM25AirQuality = pM25AirQuality;
242
+ this.accessory.hasAutoVentilationMode = hasAutoVentilationMode;
243
+ this.accessory.hasBypassVentilationMode = hasBypassVentilationMode;
244
+ this.accessory.hasAutomaticFanSpeed = hasAutomaticFanSpeed;
245
+ this.accessory.coreMaintenanceRequired = coreMaintenanceRequired;
246
+ this.accessory.filterMaintenanceRequired = filterMaintenanceRequired;
247
+ this.accessory.actualVentilationMode = actualVentilationMode;
248
+ this.accessory.accessory.presets = presets;
249
+ this.accessory.operationModeSetPropsMinValue = 0;
250
+ this.accessory.operationModeSetPropsMaxValue = 3;
251
+ this.accessory.operationModeSetPropsValidValues = [0];
252
+ this.accessory.fanSpeedSetPropsMaxValue = 2;
253
+
246
254
  //operation mode - 0, HEAT, 2, COOL, 4, 5, 6, FAN, AUTO
247
255
  switch (displayMode) {
248
256
  case 0: //Heater Cooler
@@ -250,26 +258,26 @@ class DeviceErv extends EventEmitter {
250
258
  case true:
251
259
  switch (ventilationMode) {
252
260
  case 0: //LOSSNAY
253
- this.currentOperationMode = 2; //HEATING
254
- this.targetOperationMode = 1; //HEAT
261
+ this.accessory.currentOperationMode = 2; //HEATING
262
+ this.accessory.targetOperationMode = 1; //HEAT
255
263
  break;
256
264
  case 1: //BYPASS
257
- this.currentOperationMode = 3; //COOLING
258
- this.targetOperationMode = 2; //COOL
265
+ this.accessory.currentOperationMode = 3; //COOLING
266
+ this.accessory.targetOperationMode = 2; //COOL
259
267
  break;
260
268
  case 2: //AUTO
261
269
  switch (actualVentilationMode) {
262
270
  case 0: //LOSSNAY
263
- this.currentOperationMode = 2; //HEATING
271
+ this.accessory.currentOperationMode = 2; //HEATING
264
272
  break;
265
273
  case 1: //BYPASS
266
- this.currentOperationMode = 3; //COOLING
274
+ this.accessory.currentOperationMode = 3; //COOLING
267
275
  break;
268
276
  default:
269
277
  this.emit('warn', `Unknown actual ventilation mode: ${actualVentilationMode}`);
270
278
  break;
271
279
  };
272
- this.targetOperationMode = 0; //AUTO
280
+ this.accessory.targetOperationMode = 0; //AUTO
273
281
  break;
274
282
  default:
275
283
  this.emit('warn', `Unknown ventilation mode: ${ventilationMode}`);
@@ -277,27 +285,27 @@ class DeviceErv extends EventEmitter {
277
285
  };
278
286
  break;
279
287
  case false:
280
- this.currentOperationMode = 0; //OFF
288
+ this.accessory.currentOperationMode = 0; //OFF
281
289
  break;
282
290
  };
283
291
 
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]);
292
+ this.accessory.operationModeSetPropsMinValue = hasAutoVentilationMode ? 0 : 1;
293
+ this.accessory.operationModeSetPropsMaxValue = hasAutoVentilationMode ? 2 : 2;
294
+ this.accessory.operationModeSetPropsValidValues = hasAutoVentilationMode ? (hasBypassVentilationMode ? [0, 1, 2] : [0, 2]) : (hasBypassVentilationMode ? [1, 2] : [2]);
287
295
 
288
296
  //fan speed mode
289
297
  switch (numberOfFanSpeeds) {
290
298
  case 2: //Fan speed mode 2
291
- this.fanSpeed = hasAutomaticFanSpeed ? [3, 1, 2][setFanSpeed] : [0, 1, 2][setFanSpeed];
292
- this.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 3 : 2;
299
+ this.accessory.fanSpeed = hasAutomaticFanSpeed ? [3, 1, 2][setFanSpeed] : [0, 1, 2][setFanSpeed];
300
+ this.accessory.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 3 : 2;
293
301
  break;
294
302
  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;
303
+ this.this.accessory.fanSpeed = hasAutomaticFanSpeed ? [4, 1, 2, 3][setFanSpeed] : [0, 1, 2, 3][setFanSpeed];
304
+ this.accessory.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 4 : 3;
297
305
  break;
298
306
  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;
307
+ this.accessory.fanSpeed = hasAutomaticFanSpeed ? [5, 1, 2, 3, 4][setFanSpeed] : [0, 1, 2, 3, 4][setFanSpeed];
308
+ this.accessory.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 5 : 4;
301
309
  break;
302
310
  };
303
311
 
@@ -305,12 +313,12 @@ class DeviceErv extends EventEmitter {
305
313
  if (this.melCloudService) {
306
314
  this.melCloudService
307
315
  .updateCharacteristic(Characteristic.Active, power)
308
- .updateCharacteristic(Characteristic.CurrentHeaterCoolerState, this.currentOperationMode)
309
- .updateCharacteristic(Characteristic.TargetHeaterCoolerState, this.targetOperationMode)
316
+ .updateCharacteristic(Characteristic.CurrentHeaterCoolerState, this.accessory.currentOperationMode)
317
+ .updateCharacteristic(Characteristic.TargetHeaterCoolerState, this.accessory.targetOperationMode)
310
318
  .updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature)
311
- .updateCharacteristic(Characteristic.RotationSpeed, this.fanSpeed)
312
- .updateCharacteristic(Characteristic.LockPhysicalControls, this.lockPhysicalControl)
313
- .updateCharacteristic(Characteristic.TemperatureDisplayUnits, this.useFahrenheit);
319
+ .updateCharacteristic(Characteristic.RotationSpeed, this.accessory.fanSpeed)
320
+ .updateCharacteristic(Characteristic.LockPhysicalControls, this.accessory.lockPhysicalControl)
321
+ .updateCharacteristic(Characteristic.TemperatureDisplayUnits, this.accessory.useFahrenheit);
314
322
  const updateHOM = hasHeatOperationMode ? this.melCloudService.updateCharacteristic(Characteristic.HeatingThresholdTemperature, targetTemperature) : false;
315
323
  const updateCOM = hasCoolOperationMode ? this.melCloudService.updateCharacteristic(Characteristic.CoolingThresholdTemperature, targetTemperature) : false;
316
324
  };
@@ -321,26 +329,26 @@ class DeviceErv extends EventEmitter {
321
329
  case true:
322
330
  switch (ventilationMode) {
323
331
  case 0: //LOSSNAY
324
- this.currentOperationMode = 1; //HEATING
325
- this.targetOperationMode = 1; //HEAT
332
+ this.accessory.currentOperationMode = 1; //HEATING
333
+ this.accessory.targetOperationMode = 1; //HEAT
326
334
  break;
327
335
  case 1: //BYPASS
328
- this.currentOperationMode = 2; //COOLING
329
- this.targetOperationMode = 2; //COOL
336
+ this.accessory.currentOperationMode = 2; //COOLING
337
+ this.accessory.targetOperationMode = 2; //COOL
330
338
  break;
331
339
  case 2: //AUTO
332
340
  switch (actualVentilationMode) {
333
341
  case 0: //LOSSNAY
334
- this.currentOperationMode = 1; //HEATING
342
+ this.accessory.currentOperationMode = 1; //HEATING
335
343
  break;
336
344
  case 1: //BYPASS
337
- this.currentOperationMode = 2; //COOLING
345
+ this.accessory.currentOperationMode = 2; //COOLING
338
346
  break;
339
347
  default:
340
348
  this.emit('warn', `Unknown actual ventilation mode: ${actualVentilationMode}`);
341
349
  break;
342
350
  };
343
- this.targetOperationMode = 3; //AUTO
351
+ this.accessory.targetOperationMode = 3; //AUTO
344
352
  break;
345
353
  default:
346
354
  this.emit('warn', `Unknown ventilation mode: ${ventilationMode}`);
@@ -348,34 +356,26 @@ class DeviceErv extends EventEmitter {
348
356
  };
349
357
  break;
350
358
  case false:
351
- this.currentOperationMode = 0; //OFF
352
- this.targetOperationMode = 0; //OFF
359
+ this.accessory.currentOperationMode = 0; //OFF
360
+ this.accessory.targetOperationMode = 0; //OFF
353
361
  break;
354
362
  };
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]);
363
+ this.accessory.operationModeSetPropsMinValue = hasAutoVentilationMode ? 0 : 0;
364
+ this.accessory.operationModeSetPropsMaxValue = hasAutoVentilationMode ? 3 : 2;
365
+ this.accessory.operationModeSetPropsValidValues = hasAutoVentilationMode ? (hasBypassVentilationMode ? [0, 1, 2, 3] : [0, 2, 3]) : (hasBypassVentilationMode ? [0, 1, 2] : [0, 2]);
358
366
 
359
367
  //update characteristics
360
368
  if (this.melCloudService) {
361
369
  this.melCloudService
362
- .updateCharacteristic(Characteristic.CurrentHeatingCoolingState, this.currentOperationMode)
363
- .updateCharacteristic(Characteristic.TargetHeatingCoolingState, this.targetOperationMode)
370
+ .updateCharacteristic(Characteristic.CurrentHeatingCoolingState, this.accessory.currentOperationMode)
371
+ .updateCharacteristic(Characteristic.TargetHeatingCoolingState, this.accessory.targetOperationMode)
364
372
  .updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature)
365
373
  .updateCharacteristic(Characteristic.TargetTemperature, targetTemperature)
366
- .updateCharacteristic(Characteristic.TemperatureDisplayUnits, this.useFahrenheit);
374
+ .updateCharacteristic(Characteristic.TemperatureDisplayUnits, this.accessory.useFahrenheit);
367
375
  };
368
376
  break;
369
377
  };
370
378
 
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
379
  //update temperature sensors
380
380
  if (this.roomTemperatureSensorService) {
381
381
  this.roomTemperatureSensorService
@@ -455,7 +455,7 @@ class DeviceErv extends EventEmitter {
455
455
  button.state = power ? (setFanSpeed === 4) : false;
456
456
  break;
457
457
  case 15: //PHYSICAL LOCK CONTROLS
458
- button.state = (this.lockPhysicalControl === 1);
458
+ button.state = (this.accessory.lockPhysicalControl === 1);
459
459
  break;
460
460
  case 16: //ROOM TEMP HIDE
461
461
  button.state = (hideRoomTemperature === true);
@@ -481,10 +481,10 @@ class DeviceErv extends EventEmitter {
481
481
  };
482
482
 
483
483
  //update presets state
484
- if (this.presetsCount > 0) {
484
+ if (presets.length > 0) {
485
485
  this.presetsStates = [];
486
486
 
487
- for (let i = 0; i < this.presetsCount; i++) {
487
+ for (let i = 0; i < presets.length; i++) {
488
488
  const preset = presets[i];
489
489
  const state = preset.Power === power
490
490
  && preset.SetTemperature === targetTemperature
@@ -505,14 +505,14 @@ class DeviceErv extends EventEmitter {
505
505
  const operationModeText = !power ? CONSTANTS.Ventilation.System[0] : CONSTANTS.Ventilation.OperationMode[ventilationMode];
506
506
  this.emit('message', `Power: ${power ? 'ON' : 'OFF'}`);
507
507
  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;
508
+ this.emit('message', `Room temperature: ${roomTemperature}${temperatureUnit}`);
509
+ const info = hasCoolOperationMode || hasHeatOperationMode ? this.emit('message', `Target temperature: ${targetTemperature}${temperatureUnit}`) : false;
510
+ const info1 = hasSupplyTemperature && this.accessory.supplyTemperature !== null ? this.emit('message', `Supply temperature: ${roomTemperature}${temperatureUnit}`) : false;
511
+ const info2 = hasOutdoorTemperature && this.accessory.outdoorTemperature !== null ? this.emit('message', `Outdoor temperature: ${roomTemperature}${temperatureUnit}`) : false;
512
+ const info3 = hasHeatOperationMode && displayMode === 0 ? this.emit('message', `Heating threshold temperature: ${targetTemperature}${temperatureUnit}`) : false;
513
+ const info4 = hasCoolOperationMode && displayMode === 0 ? this.emit('message', `Cooling threshold temperature: ${targetTemperature}${temperatureUnit}`) : false;
514
514
  this.emit('message', `Fan speed mode: ${CONSTANTS.Ventilation.FanSpeed[setFanSpeed]}`);
515
- this.emit('message', `Temperature display unit: ${this.temperatureUnit}`);
515
+ this.emit('message', `Temperature display unit: ${temperatureUnit}`);
516
516
  this.emit('message', `Core maintenance: ${CONSTANTS.Ventilation.CoreMaintenance[coreMaintenanceRequired]}`);
517
517
  this.emit('message', `Filter maintenance: ${CONSTANTS.Ventilation.FilterMaintenance[filterMaintenanceRequired]}`);
518
518
  const info5 = hasCO2Sensor ? this.emit('message', `CO2 detected: ${CONSTANTS.Ventilation.Co2Detected[roomCO2Detected]}`) : false;
@@ -640,14 +640,13 @@ class DeviceErv extends EventEmitter {
640
640
  const temperatureSensorSupply = this.temperatureSensorSupply;
641
641
  const buttonsConfigured = this.buttonsConfigured;
642
642
  const buttonsConfiguredCount = this.buttonsConfiguredCount;
643
- const presets = this.presets;
644
- 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;
643
+ const presets = this.accessory.presets;
644
+ const hasCoolOperationMode = this.accessory.hasCoolOperationMode;
645
+ const hasHeatOperationMode = this.accessory.hasHeatOperationMode;
646
+ const hasCO2Sensor = this.accessory.hasCO2Sensor;
647
+ const hasPM25Sensor = this.accessory.hasPM25Sensor;
648
+ const hasAutoVentilationMode = this.accessory.hasAutoVentilationMode;
649
+ const hasBypassVentilationMode = this.accessory.hasBypassVentilationMode;
651
650
  const serviceName = `${deviceTypeText} ${accessoryName}`;
652
651
 
653
652
  switch (displayMode) {
@@ -656,7 +655,7 @@ class DeviceErv extends EventEmitter {
656
655
  this.melCloudService = accessory.addService(Service.HeaterCooler, serviceName, `HeaterCooler ${deviceId}`);
657
656
  this.melCloudService.getCharacteristic(Characteristic.Active)
658
657
  .onGet(async () => {
659
- const state = this.power;
658
+ const state = this.accessory.power;
660
659
  return state;
661
660
  })
662
661
  .onSet(async (state) => {
@@ -672,17 +671,17 @@ class DeviceErv extends EventEmitter {
672
671
  });
673
672
  this.melCloudService.getCharacteristic(Characteristic.CurrentHeaterCoolerState)
674
673
  .onGet(async () => {
675
- const value = this.currentOperationMode;
674
+ const value = this.accessory.currentOperationMode;
676
675
  return value;
677
676
  });
678
677
  this.melCloudService.getCharacteristic(Characteristic.TargetHeaterCoolerState)
679
678
  .setProps({
680
- minValue: this.operationModeSetPropsMinValue,
681
- maxValue: this.operationModeSetPropsMaxValue,
682
- validValues: this.operationModeSetPropsValidValues
679
+ minValue: this.accessory.operationModeSetPropsMinValue,
680
+ maxValue: this.accessory.operationModeSetPropsMaxValue,
681
+ validValues: this.accessory.operationModeSetPropsValidValues
683
682
  })
684
683
  .onGet(async () => {
685
- const value = this.targetOperationMode; //LOSSNAY, BYPASS, AUTO
684
+ const value = this.accessory.targetOperationMode; //LOSSNAY, BYPASS, AUTO
686
685
  return value;
687
686
  })
688
687
  .onSet(async (value) => {
@@ -715,11 +714,11 @@ class DeviceErv extends EventEmitter {
715
714
  this.melCloudService.getCharacteristic(Characteristic.RotationSpeed)
716
715
  .setProps({
717
716
  minValue: 0,
718
- maxValue: this.fanSpeedSetPropsMaxValue,
717
+ maxValue: this.accessory.fanSpeedSetPropsMaxValue,
719
718
  minStep: 1
720
719
  })
721
720
  .onGet(async () => {
722
- const value = this.fanSpeed; //STOP, 1, 2, 3, 4, OFF
721
+ const value = this.accessory.fanSpeed; //STOP, 1, 2, 3, 4, OFF
723
722
  return value;
724
723
  })
725
724
  .onSet(async (value) => {
@@ -756,7 +755,7 @@ class DeviceErv extends EventEmitter {
756
755
  minStep: 0.5
757
756
  })
758
757
  .onGet(async () => {
759
- const value = this.roomTemperature;
758
+ const value = this.accessory.roomTemperature;
760
759
  return value;
761
760
  });
762
761
  //device can heat
@@ -765,10 +764,10 @@ class DeviceErv extends EventEmitter {
765
764
  .setProps({
766
765
  minValue: 0,
767
766
  maxValue: 31,
768
- minStep: this.temperatureIncrement
767
+ minStep: this.accessory.temperatureIncrement
769
768
  })
770
769
  .onGet(async () => {
771
- const value = this.setTemperature;
770
+ const value = this.accessory.setTemperature;
772
771
  return value;
773
772
  })
774
773
  .onSet(async (value) => {
@@ -776,7 +775,7 @@ class DeviceErv extends EventEmitter {
776
775
  deviceState.SetTemperature = value;
777
776
  deviceState.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.SetTemperature;
778
777
  await this.melCloudErv.send(deviceState);
779
- const info = this.disableLogInfo ? false : this.emit('message', `Set heating threshold temperature: ${value}${this.temperatureUnit}`);
778
+ const info = this.disableLogInfo ? false : this.emit('message', `Set heating threshold temperature: ${value}${this.accessory.temperatureUnit}`);
780
779
  } catch (error) {
781
780
  this.emit('warn', `Set heating threshold temperature error: ${error}`);
782
781
  };
@@ -788,10 +787,10 @@ class DeviceErv extends EventEmitter {
788
787
  .setProps({
789
788
  minValue: 10,
790
789
  maxValue: 31,
791
- minStep: this.temperatureIncrement
790
+ minStep: this.accessory.temperatureIncrement
792
791
  })
793
792
  .onGet(async () => {
794
- const value = this.setTemperature;
793
+ const value = this.accessory.setTemperature;
795
794
  return value;
796
795
  })
797
796
  .onSet(async (value) => {
@@ -799,7 +798,7 @@ class DeviceErv extends EventEmitter {
799
798
  deviceState.SetTemperature = value;
800
799
  deviceState.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.SetTemperature;
801
800
  await this.melCloudErv.send(deviceState);
802
- const info = this.disableLogInfo ? false : this.emit('message', `Set cooling threshold temperature: ${value}${this.temperatureUnit}`);
801
+ const info = this.disableLogInfo ? false : this.emit('message', `Set cooling threshold temperature: ${value}${this.accessory.temperatureUnit}`);
803
802
  } catch (error) {
804
803
  this.emit('warn', `Set cooling threshold temperature error: ${error}`);
805
804
  };
@@ -807,7 +806,7 @@ class DeviceErv extends EventEmitter {
807
806
  };
808
807
  //this.melCloudService.getCharacteristic(Characteristic.LockPhysicalControls)
809
808
  // .onGet(async () => {
810
- // const value = this.lockPhysicalControl;
809
+ // const value = this.accessory.lockPhysicalControl;
811
810
  // const info = this.disableLogInfo ? false : this.emit('message', `Lock physical controls: ${value ? 'LOCKED' : 'UNLOCKED'}`);
812
811
  // return value;
813
812
  // })
@@ -824,13 +823,13 @@ class DeviceErv extends EventEmitter {
824
823
  // });
825
824
  this.melCloudService.getCharacteristic(Characteristic.TemperatureDisplayUnits)
826
825
  .onGet(async () => {
827
- const value = this.useFahrenheit;
826
+ const value = this.accessory.useFahrenheit;
828
827
  return value;
829
828
  })
830
829
  .onSet(async (value) => {
831
830
  try {
832
- this.useFahrenheit = value ? true : false;
833
- accountInfo.UseFahrenheit = this.useFahrenheit;
831
+ this.accessory.useFahrenheit = value ? true : false;
832
+ accountInfo.UseFahrenheit = this.accessory.useFahrenheit;
834
833
  await this.melCloud.send(accountInfo);
835
834
  const info = this.disableLogInfo ? false : this.emit('message', `Set temperature display unit: ${CONSTANTS.TemperatureDisplayUnits[value]}`);
836
835
  } catch (error) {
@@ -843,17 +842,17 @@ class DeviceErv extends EventEmitter {
843
842
  this.melCloudService = accessory.addService(Service.Thermostat, serviceName, `Thermostat ${deviceId}`);
844
843
  this.melCloudService.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
845
844
  .onGet(async () => {
846
- const value = this.currentOperationMode;
845
+ const value = this.accessory.currentOperationMode;
847
846
  return value;
848
847
  });
849
848
  this.melCloudService.getCharacteristic(Characteristic.TargetHeatingCoolingState)
850
849
  .setProps({
851
- minValue: this.operationModeSetPropsMinValue,
852
- maxValue: this.operationModeSetPropsMaxValue,
853
- validValues: this.operationModeSetPropsValidValues
850
+ minValue: this.accessory.operationModeSetPropsMinValue,
851
+ maxValue: this.accessory.operationModeSetPropsMaxValue,
852
+ validValues: this.accessory.operationModeSetPropsValidValues
854
853
  })
855
854
  .onGet(async () => {
856
- const value = this.targetOperationMode; //LOSSNAY, BYPASS, AUTO
855
+ const value = this.accessory.targetOperationMode; //LOSSNAY, BYPASS, AUTO
857
856
  return value;
858
857
  })
859
858
  .onSet(async (value) => {
@@ -894,17 +893,17 @@ class DeviceErv extends EventEmitter {
894
893
  minStep: 0.5
895
894
  })
896
895
  .onGet(async () => {
897
- const value = this.roomTemperature;
896
+ const value = this.accessory.roomTemperature;
898
897
  return value;
899
898
  });
900
899
  this.melCloudService.getCharacteristic(Characteristic.TargetTemperature)
901
900
  .setProps({
902
901
  minValue: 0,
903
902
  maxValue: 31,
904
- minStep: this.temperatureIncrement
903
+ minStep: this.accessory.temperatureIncrement
905
904
  })
906
905
  .onGet(async () => {
907
- const value = this.setTemperature;
906
+ const value = this.accessory.setTemperature;
908
907
  return value;
909
908
  })
910
909
  .onSet(async (value) => {
@@ -912,20 +911,20 @@ class DeviceErv extends EventEmitter {
912
911
  deviceState.SetTemperature = value;
913
912
  deviceState.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.SetTemperature;
914
913
  await this.melCloudErv.send(deviceState);
915
- const info = this.disableLogInfo ? false : this.emit('message', `Set temperature: ${value}${this.temperatureUnit}`);
914
+ const info = this.disableLogInfo ? false : this.emit('message', `Set temperature: ${value}${this.accessory.temperatureUnit}`);
916
915
  } catch (error) {
917
916
  this.emit('warn', `Set temperature error: ${error}`);
918
917
  };
919
918
  });
920
919
  this.melCloudService.getCharacteristic(Characteristic.TemperatureDisplayUnits)
921
920
  .onGet(async () => {
922
- const value = this.useFahrenheit;
921
+ const value = this.accessory.useFahrenheit;
923
922
  return value;
924
923
  })
925
924
  .onSet(async (value) => {
926
925
  try {
927
- this.useFahrenheit = value ? true : false;
928
- accountInfo.UseFahrenheit = this.useFahrenheit;
926
+ this.accessory.useFahrenheit = value ? true : false;
927
+ accountInfo.UseFahrenheit = this.accessory.useFahrenheit;
929
928
  await this.melCloud.send(accountInfo);
930
929
  const info = this.disableLogInfo ? false : this.emit('message', `Set temperature display unit: ${CONSTANTS.TemperatureDisplayUnits[value]}`);
931
930
  } catch (error) {
@@ -936,7 +935,7 @@ class DeviceErv extends EventEmitter {
936
935
  };
937
936
 
938
937
  //temperature sensor service room
939
- if (temperatureSensor && this.hasRoomTemperature && this.roomTemperature !== null) {
938
+ if (temperatureSensor && this.accessory.hasRoomTemperature && this.accessory.roomTemperature !== null) {
940
939
  const debug = this.enableDebugMode ? this.emit('debug', `Prepare room temperature sensor service`) : false;
941
940
  this.roomTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Room`, `Room Temperature Sensor ${deviceId}`);
942
941
  this.roomTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
@@ -948,14 +947,14 @@ class DeviceErv extends EventEmitter {
948
947
  minStep: 0.5
949
948
  })
950
949
  .onGet(async () => {
951
- const state = this.roomTemperature;
950
+ const state = this.accessory.roomTemperature;
952
951
  return state;
953
952
  })
954
953
  accessory.addService(this.roomTemperatureSensorService);
955
954
  };
956
955
 
957
956
  //temperature sensor service supply
958
- if (temperatureSensorSupply && this.hasSupplyTemperature && this.supplyTemperature !== null) {
957
+ if (temperatureSensorSupply && this.accessory.hasSupplyTemperature && this.accessory.supplyTemperature !== null) {
959
958
  const debug = this.enableDebugMode ? this.emit('debug', `Prepare supply temperature sensor service`) : false;
960
959
  this.supplyTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Supply`, `Supply Temperature Sensor ${deviceId}`);
961
960
  this.supplyTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
@@ -967,14 +966,14 @@ class DeviceErv extends EventEmitter {
967
966
  minStep: 0.5
968
967
  })
969
968
  .onGet(async () => {
970
- const state = this.supplyTemperature;
969
+ const state = this.accessory.supplyTemperature;
971
970
  return state;
972
971
  })
973
972
  accessory.addService(this.supplyTemperatureSensorService);
974
973
  };
975
974
 
976
975
  //temperature sensor service outdoor
977
- if (temperatureSensorOutdoor && this.hasOutdoorTemperature && this.outdoorTemperature !== null) {
976
+ if (temperatureSensorOutdoor && this.accessory.hasOutdoorTemperature && this.accessory.outdoorTemperature !== null) {
978
977
  const debug = this.enableDebugMode ? this.emit('debug', `Prepare outdoor temperature sensor service`) : false;
979
978
  this.outdoorTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Outdoor`, `Outdoor Temperature Sensor ${deviceId}`);
980
979
  this.outdoorTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
@@ -986,7 +985,7 @@ class DeviceErv extends EventEmitter {
986
985
  minStep: 0.5
987
986
  })
988
987
  .onGet(async () => {
989
- const state = this.outdoorTemperature;
988
+ const state = this.accessory.outdoorTemperature;
990
989
  return state;
991
990
  })
992
991
  accessory.addService(this.outdoorTemperatureSensorService);
@@ -998,7 +997,7 @@ class DeviceErv extends EventEmitter {
998
997
  this.coreMaintenanceService.setCharacteristic(Characteristic.ConfiguredName, `${serviceName} Core Maintenance`);
999
998
  this.coreMaintenanceService.getCharacteristic(Characteristic.FilterChangeIndication)
1000
999
  .onGet(async () => {
1001
- const value = this.coreMaintenanceRequired;
1000
+ const value = this.accessory.coreMaintenanceRequired;
1002
1001
  return value;
1003
1002
  });
1004
1003
  this.coreMaintenanceService.getCharacteristic(Characteristic.ResetFilterIndication)
@@ -1012,7 +1011,7 @@ class DeviceErv extends EventEmitter {
1012
1011
  this.filterMaintenanceService.setCharacteristic(Characteristic.ConfiguredName, `${serviceName} Filter Maintenance`);
1013
1012
  this.filterMaintenanceService.getCharacteristic(Characteristic.FilterChangeIndication)
1014
1013
  .onGet(async () => {
1015
- const value = this.filterMaintenanceRequired;
1014
+ const value = this.accessory.filterMaintenanceRequired;
1016
1015
  return value;
1017
1016
  });
1018
1017
  this.filterMaintenanceService.getCharacteristic(Characteristic.ResetFilterIndication)
@@ -1027,12 +1026,12 @@ class DeviceErv extends EventEmitter {
1027
1026
  this.carbonDioxideSensorService.setCharacteristic(Characteristic.ConfiguredName, `${serviceName} CO2 Sensor`);
1028
1027
  this.carbonDioxideSensorService.getCharacteristic(Characteristic.CarbonDioxideDetected)
1029
1028
  .onGet(async () => {
1030
- const value = this.roomCO2Detected;
1029
+ const value = this.accessory.roomCO2Detected;
1031
1030
  return value;
1032
1031
  });
1033
1032
  this.carbonDioxideSensorService.getCharacteristic(Characteristic.CarbonDioxideLevel)
1034
1033
  .onGet(async () => {
1035
- const value = this.roomCO2Level;
1034
+ const value = this.accessory.roomCO2Level;
1036
1035
  return value;
1037
1036
  });
1038
1037
  accessory.addService(this.carbonDioxideSensorService);
@@ -1045,12 +1044,12 @@ class DeviceErv extends EventEmitter {
1045
1044
  this.airQualitySensorService.setCharacteristic(Characteristic.ConfiguredName, `${serviceName} PM2.5 Sensor`);
1046
1045
  this.airQualitySensorService.getCharacteristic(Characteristic.AirQuality)
1047
1046
  .onGet(async () => {
1048
- const value = this.pM25AirQuality;
1047
+ const value = this.accessory.pM25AirQuality;
1049
1048
  return value;
1050
1049
  });
1051
1050
  this.airQualitySensorService.getCharacteristic(Characteristic.PM2_5Density)
1052
1051
  .onGet(async () => {
1053
- const value = this.pM25Level;
1052
+ const value = this.accessory.pM25Level;
1054
1053
  return value;
1055
1054
  });
1056
1055
  accessory.addService(this.airQualitySensorService);
@@ -1173,12 +1172,12 @@ class DeviceErv extends EventEmitter {
1173
1172
  };
1174
1173
 
1175
1174
  //presets services
1176
- if (presetsCount > 0) {
1175
+ if (presets.length > 0) {
1177
1176
  const debug = this.enableDebugMode ? this.emit('debug', `Prepare presets service`) : false;
1178
1177
  this.presetsServices = [];
1179
1178
  const previousPresets = [];
1180
1179
 
1181
- for (let i = 0; i < presetsCount; i++) {
1180
+ for (let i = 0; i < presets.length; i++) {
1182
1181
  const preset = presets[i];
1183
1182
  const presetName = preset.NumberDescription;
1184
1183