homebridge-melcloud-control 3.8.3-beta.8 → 3.8.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/src/deviceerv.js CHANGED
@@ -42,10 +42,6 @@ class DeviceErv extends EventEmitter {
42
42
  this.mqtt = mqtt;
43
43
  this.mqttConnected = false;
44
44
 
45
- //variables
46
- this.useFahrenheit = useFahrenheit ? 1 : 0;
47
- this.temperatureUnit = TemperatureDisplayUnits[this.useFahrenheit];
48
-
49
45
  //function
50
46
  this.melCloud = melCloud; //function
51
47
 
@@ -91,7 +87,9 @@ class DeviceErv extends EventEmitter {
91
87
  this.deviceData = {};
92
88
 
93
89
  //accessory
94
- this.mielHvac = {};
90
+ this.accessory = {};
91
+ this.accessory.useFahrenheit = useFahrenheit ? 1 : 0;
92
+ this.accessory.temperatureUnit = TemperatureDisplayUnits[this.accessory.useFahrenheit];
95
93
  };
96
94
 
97
95
  async externalIntegrations() {
@@ -249,19 +247,18 @@ class DeviceErv extends EventEmitter {
249
247
  //prepare accessory
250
248
  async prepareAccessory(accountInfo, deviceData, deviceId, deviceTypeText, deviceName, accountName) {
251
249
  try {
252
- const mielHvac = this.mielHvac;
253
- const presetsOnServer = mielHvac.presets;
254
- const hasRoomTemperature = mielHvac.hasRoomTemperature;
255
- const hasSupplyTemperature = mielHvac.hasSupplyTemperature;
256
- const hasOutdoorTemperature = mielHvac.hasOutdoorTemperature;
257
- const hasCoolOperationMode = mielHvac.hasCoolOperationMode;
258
- const hasHeatOperationMode = mielHvac.hasHeatOperationMode;
259
- const hasAutoVentilationMode = mielHvac.hasAutoVentilationMode;
260
- const hasBypassVentilationMode = mielHvac.hasBypassVentilationMode;
261
- const hasAutomaticFanSpeed = mielHvac.hasAutomaticFanSpeed;
262
- const hasCO2Sensor = mielHvac.hasCO2Sensor;
263
- const hasPM25Sensor = mielHvac.hasPM25Sensor;
264
- const numberOfFanSpeeds = mielHvac.numberOfFanSpeeds;
250
+ const presetsOnServer = this.accessory.presets;
251
+ const hasRoomTemperature = this.accessory.hasRoomTemperature;
252
+ const hasSupplyTemperature = this.accessory.hasSupplyTemperature;
253
+ const hasOutdoorTemperature = this.accessory.hasOutdoorTemperature;
254
+ const hasCoolOperationMode = this.accessory.hasCoolOperationMode;
255
+ const hasHeatOperationMode = this.accessory.hasHeatOperationMode;
256
+ const hasAutoVentilationMode = this.accessory.hasAutoVentilationMode;
257
+ const hasBypassVentilationMode = this.accessory.hasBypassVentilationMode;
258
+ const hasAutomaticFanSpeed = this.accessory.hasAutomaticFanSpeed;
259
+ const hasCO2Sensor = this.accessory.hasCO2Sensor;
260
+ const hasPM25Sensor = this.accessory.hasPM25Sensor;
261
+ const numberOfFanSpeeds = this.accessory.numberOfFanSpeeds;
265
262
 
266
263
  //accessory
267
264
  const debug = this.enableDebugMode ? this.emit('debug', `Prepare accessory`) : false;
@@ -288,7 +285,7 @@ class DeviceErv extends EventEmitter {
288
285
  this.melCloudService.setPrimaryService(true);
289
286
  this.melCloudService.getCharacteristic(Characteristic.Active)
290
287
  .onGet(async () => {
291
- const state = mielHvac.power;
288
+ const state = this.accessory.power;
292
289
  return state;
293
290
  })
294
291
  .onSet(async (state) => {
@@ -296,24 +293,24 @@ class DeviceErv extends EventEmitter {
296
293
  deviceData.Device.Power = [false, true][state];
297
294
  deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.Power;
298
295
  await this.melCloudErv.send(deviceData, this.displayMode);
299
- const info = this.disableLogInfo ? false : this.emit('message', `Set power: ${state ? 'ON' : 'OFF'}`);
296
+ const info = this.disableLogInfo ? false : this.emit('info', `Set power: ${state ? 'ON' : 'OFF'}`);
300
297
  } catch (error) {
301
298
  this.emit('warn', `Set power error: ${error}`);
302
299
  };
303
300
  });
304
301
  this.melCloudService.getCharacteristic(Characteristic.CurrentHeaterCoolerState)
305
302
  .onGet(async () => {
306
- const value = mielHvac.currentOperationMode;
303
+ const value = this.accessory.currentOperationMode;
307
304
  return value;
308
305
  });
309
306
  this.melCloudService.getCharacteristic(Characteristic.TargetHeaterCoolerState)
310
307
  .setProps({
311
- minValue: mielHvac.operationModeSetPropsMinValue,
312
- maxValue: mielHvac.operationModeSetPropsMaxValue,
313
- validValues: mielHvac.operationModeSetPropsValidValues
308
+ minValue: this.accessory.operationModeSetPropsMinValue,
309
+ maxValue: this.accessory.operationModeSetPropsMaxValue,
310
+ validValues: this.accessory.operationModeSetPropsValidValues
314
311
  })
315
312
  .onGet(async () => {
316
- const value = mielHvac.targetOperationMode ?? 0; //LOSSNAY, BYPASS, AUTO
313
+ const value = this.accessory.targetOperationMode ?? 0; //LOSSNAY, BYPASS, AUTO
317
314
  return value;
318
315
  })
319
316
  .onSet(async (value) => {
@@ -333,24 +330,24 @@ class DeviceErv extends EventEmitter {
333
330
  deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.VentilationMode;
334
331
  await this.melCloudErv.send(deviceData, this.displayMode);
335
332
  const operationModeText = Ventilation.VentilationMode[deviceData.Device.VentilationMode];
336
- const info = this.disableLogInfo ? false : this.emit('message', `Set operation mode: ${operationModeText}`);
333
+ const info = this.disableLogInfo ? false : this.emit('info', `Set operation mode: ${operationModeText}`);
337
334
  } catch (error) {
338
335
  this.emit('warn', `Set operation mode error: ${error}`);
339
336
  };
340
337
  });
341
338
  this.melCloudService.getCharacteristic(Characteristic.CurrentTemperature)
342
339
  .onGet(async () => {
343
- const value = mielHvac.roomTemperature;
340
+ const value = this.accessory.roomTemperature;
344
341
  return value;
345
342
  });
346
343
  this.melCloudService.getCharacteristic(Characteristic.RotationSpeed)
347
344
  .setProps({
348
345
  minValue: 0,
349
- maxValue: mielHvac.fanSpeedSetPropsMaxValue,
346
+ maxValue: this.accessory.fanSpeedSetPropsMaxValue,
350
347
  minStep: 1
351
348
  })
352
349
  .onGet(async () => {
353
- const value = mielHvac.fanSpeed; //STOP, 1, 2, 3, 4, OFF
350
+ const value = this.accessory.fanSpeed; //STOP, 1, 2, 3, 4, OFF
354
351
  return value;
355
352
  })
356
353
  .onSet(async (value) => {
@@ -376,7 +373,7 @@ class DeviceErv extends EventEmitter {
376
373
  };
377
374
  deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.SetFanSpeed;
378
375
  await this.melCloudErv.send(deviceData, this.displayMode);
379
- const info = this.disableLogInfo ? false : this.emit('message', `Set fan speed mode: ${Ventilation.FanSpeed[fanSpeedModeText]}`);
376
+ const info = this.disableLogInfo ? false : this.emit('info', `Set fan speed mode: ${Ventilation.FanSpeed[fanSpeedModeText]}`);
380
377
  } catch (error) {
381
378
  this.emit('warn', `Set fan speed mode error: ${error}`);
382
379
  };
@@ -385,12 +382,12 @@ class DeviceErv extends EventEmitter {
385
382
  if (hasAutoVentilationMode && hasCoolOperationMode) {
386
383
  this.melCloudService.getCharacteristic(Characteristic.CoolingThresholdTemperature)
387
384
  .setProps({
388
- minValue: mielHvac.minTempCoolDry,
389
- maxValue: mielHvac.maxTempCoolDry,
390
- minStep: mielHvac.temperatureIncrement
385
+ minValue: this.accessory.minTempCoolDry,
386
+ maxValue: this.accessory.maxTempCoolDry,
387
+ minStep: this.accessory.temperatureIncrement
391
388
  })
392
389
  .onGet(async () => {
393
- const value = mielHvac.ventilationMode === 2 ? mielHvac.defaultHeatingSetTemperature : mielHvac.setTemperature;
390
+ const value = this.accessory.ventilationMode === 2 ? this.accessory.defaultHeatingSetTemperature : this.accessory.setTemperature;
394
391
  return value;
395
392
  })
396
393
  .onSet(async (value) => {
@@ -398,7 +395,7 @@ class DeviceErv extends EventEmitter {
398
395
  deviceData.Device.DefaultCoolingSetTemperature = value;
399
396
  deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.SetTemperature;
400
397
  await this.melCloudErv.send(deviceData, this.displayMode);
401
- const info = this.disableLogInfo ? false : this.emit('message', `Set cooling threshold temperature: ${value}${mielHvac.temperatureUnit}`);
398
+ const info = this.disableLogInfo ? false : this.emit('info', `Set cooling threshold temperature: ${value}${this.accessory.temperatureUnit}`);
402
399
  } catch (error) {
403
400
  this.emit('warn', `Set cooling threshold temperature error: ${error}`);
404
401
  };
@@ -408,12 +405,12 @@ class DeviceErv extends EventEmitter {
408
405
  if (hasAutoVentilationMode && hasHeatOperationMode) {
409
406
  this.melCloudService.getCharacteristic(Characteristic.HeatingThresholdTemperature)
410
407
  .setProps({
411
- minValue: mielHvac.minTempHeat,
412
- maxValue: mielHvac.maxTempHeat,
413
- minStep: mielHvac.temperatureIncrement
408
+ minValue: this.accessory.minTempHeat,
409
+ maxValue: this.accessory.maxTempHeat,
410
+ minStep: this.accessory.temperatureIncrement
414
411
  })
415
412
  .onGet(async () => {
416
- const value = mielHvac.ventilationMode === 2 ? mielHvac.defaultHeatingSetTemperature : mielHvac.setTemperature;
413
+ const value = this.accessory.ventilationMode === 2 ? this.accessory.defaultHeatingSetTemperature : this.accessory.setTemperature;
417
414
  return value;
418
415
  })
419
416
  .onSet(async (value) => {
@@ -421,7 +418,7 @@ class DeviceErv extends EventEmitter {
421
418
  deviceData.Device.DefaultHeatingSetTemperature = value;
422
419
  deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.SetTemperature;
423
420
  await this.melCloudErv.send(deviceData, this.displayMode);
424
- const info = this.disableLogInfo ? false : this.emit('message', `Set heating threshold temperature: ${value}${mielHvac.temperatureUnit}`);
421
+ const info = this.disableLogInfo ? false : this.emit('info', `Set heating threshold temperature: ${value}${this.accessory.temperatureUnit}`);
425
422
  } catch (error) {
426
423
  this.emit('warn', `Set heating threshold temperature error: ${error}`);
427
424
  };
@@ -429,8 +426,8 @@ class DeviceErv extends EventEmitter {
429
426
  };
430
427
  //this.melCloudService.getCharacteristic(Characteristic.LockPhysicalControls)
431
428
  // .onGet(async () => {
432
- // const value = mielHvac.lockPhysicalControl;
433
- // const info = this.disableLogInfo ? false : this.emit('message', `Lock physical controls: ${value ? 'LOCKED' : 'UNLOCKED'}`);
429
+ // const value = this.accessory.lockPhysicalControl;
430
+ // const info = this.disableLogInfo ? false : this.emit('info', `Lock physical controls: ${value ? 'LOCKED' : 'UNLOCKED'}`);
434
431
  // return value;
435
432
  // })
436
433
  // .onSet(async (value) => {
@@ -439,22 +436,22 @@ class DeviceErv extends EventEmitter {
439
436
  // deviceData.Device = deviceData.Device;
440
437
  // deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Prohibit;
441
438
  // await this.melCloudErv.send(deviceData, this.displayMode);
442
- // const info = this.disableLogInfo ? false : this.emit('message', `Set local physical controls: ${value ? 'LOCK' : 'UNLOCK'}`);
439
+ // const info = this.disableLogInfo ? false : this.emit('info', `Set local physical controls: ${value ? 'LOCK' : 'UNLOCK'}`);
443
440
  // } catch (error) {
444
441
  // this.emit('warn', `Set lock physical controls error: ${error}`);
445
442
  // };
446
443
  // });
447
444
  this.melCloudService.getCharacteristic(Characteristic.TemperatureDisplayUnits)
448
445
  .onGet(async () => {
449
- const value = mielHvac.useFahrenheit;
446
+ const value = this.accessory.useFahrenheit;
450
447
  return value;
451
448
  })
452
449
  .onSet(async (value) => {
453
450
  try {
454
451
  accountInfo.UseFahrenheit = [false, true][value];
455
452
  await this.melCloud.send(accountInfo);
456
- mielHvac.useFahrenheit = value;
457
- const info = this.disableLogInfo ? false : this.emit('message', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
453
+ this.accessory.useFahrenheit = value;
454
+ const info = this.disableLogInfo ? false : this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
458
455
  } catch (error) {
459
456
  this.emit('warn', `Set temperature display unit error: ${error}`);
460
457
  };
@@ -467,17 +464,17 @@ class DeviceErv extends EventEmitter {
467
464
  this.melCloudService.setPrimaryService(true);
468
465
  this.melCloudService.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
469
466
  .onGet(async () => {
470
- const value = mielHvac.currentOperationMode;
467
+ const value = this.accessory.currentOperationMode;
471
468
  return value;
472
469
  });
473
470
  this.melCloudService.getCharacteristic(Characteristic.TargetHeatingCoolingState)
474
471
  .setProps({
475
- minValue: mielHvac.operationModeSetPropsMinValue,
476
- maxValue: mielHvac.operationModeSetPropsMaxValue,
477
- validValues: mielHvac.operationModeSetPropsValidValues
472
+ minValue: this.accessory.operationModeSetPropsMinValue,
473
+ maxValue: this.accessory.operationModeSetPropsMaxValue,
474
+ validValues: this.accessory.operationModeSetPropsValidValues
478
475
  })
479
476
  .onGet(async () => {
480
- const value = mielHvac.targetOperationMode ?? 0; //LOSSNAY, BYPASS, AUTO
477
+ const value = this.accessory.targetOperationMode ?? 0; //LOSSNAY, BYPASS, AUTO
481
478
  return value;
482
479
  })
483
480
  .onSet(async (value) => {
@@ -506,24 +503,24 @@ class DeviceErv extends EventEmitter {
506
503
 
507
504
  await this.melCloudErv.send(deviceData, this.displayMode);
508
505
  const operationModeText = Ventilation.VentilationMode[deviceData.Device.VentilationMode];
509
- const info = this.disableLogInfo ? false : this.emit('message', `Set operation mode: ${operationModeText}`);
506
+ const info = this.disableLogInfo ? false : this.emit('info', `Set operation mode: ${operationModeText}`);
510
507
  } catch (error) {
511
508
  this.emit('warn', `Set operation mode error: ${error}`);
512
509
  };
513
510
  });
514
511
  this.melCloudService.getCharacteristic(Characteristic.CurrentTemperature)
515
512
  .onGet(async () => {
516
- const value = mielHvac.roomTemperature;
513
+ const value = this.accessory.roomTemperature;
517
514
  return value;
518
515
  });
519
516
  this.melCloudService.getCharacteristic(Characteristic.TargetTemperature)
520
517
  .setProps({
521
- minValue: mielHvac.minTempHeat,
522
- maxValue: mielHvac.maxTempHeat,
523
- minStep: mielHvac.temperatureIncrement
518
+ minValue: this.accessory.minTempHeat,
519
+ maxValue: this.accessory.maxTempHeat,
520
+ minStep: this.accessory.temperatureIncrement
524
521
  })
525
522
  .onGet(async () => {
526
- const value = mielHvac.setTemperature;
523
+ const value = this.accessory.setTemperature;
527
524
  return value;
528
525
  })
529
526
  .onSet(async (value) => {
@@ -531,22 +528,22 @@ class DeviceErv extends EventEmitter {
531
528
  deviceData.Device.SetTemperature = value;
532
529
  deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.SetTemperature;
533
530
  await this.melCloudErv.send(deviceData, this.displayMode);
534
- const info = this.disableLogInfo ? false : this.emit('message', `Set temperature: ${value}${mielHvac.temperatureUnit}`);
531
+ const info = this.disableLogInfo ? false : this.emit('info', `Set temperature: ${value}${this.accessory.temperatureUnit}`);
535
532
  } catch (error) {
536
533
  this.emit('warn', `Set temperature error: ${error}`);
537
534
  };
538
535
  });
539
536
  this.melCloudService.getCharacteristic(Characteristic.TemperatureDisplayUnits)
540
537
  .onGet(async () => {
541
- const value = mielHvac.useFahrenheit;
538
+ const value = this.accessory.useFahrenheit;
542
539
  return value;
543
540
  })
544
541
  .onSet(async (value) => {
545
542
  try {
546
543
  accountInfo.UseFahrenheit = [false, true][value];
547
544
  await this.melCloud.send(accountInfo);
548
- mielHvac.useFahrenheit = value;
549
- const info = this.disableLogInfo ? false : this.emit('message', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
545
+ this.accessory.useFahrenheit = value;
546
+ const info = this.disableLogInfo ? false : this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
550
547
  } catch (error) {
551
548
  this.emit('warn', `Set temperature display unit error: ${error}`);
552
549
  };
@@ -556,7 +553,7 @@ class DeviceErv extends EventEmitter {
556
553
  };
557
554
 
558
555
  //temperature sensor service room
559
- if (this.temperatureSensor && hasRoomTemperature && mielHvac.roomTemperature !== null) {
556
+ if (this.temperatureSensor && hasRoomTemperature && this.accessory.roomTemperature !== null) {
560
557
  const debug = this.enableDebugMode ? this.emit('debug', `Prepare room temperature sensor service`) : false;
561
558
  this.roomTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Room`, `Room Temperature Sensor ${deviceId}`);
562
559
  this.roomTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
@@ -568,14 +565,14 @@ class DeviceErv extends EventEmitter {
568
565
  minStep: 0.5
569
566
  })
570
567
  .onGet(async () => {
571
- const state = mielHvac.roomTemperature;
568
+ const state = this.accessory.roomTemperature;
572
569
  return state;
573
570
  })
574
571
  accessory.addService(this.roomTemperatureSensorService);
575
572
  };
576
573
 
577
574
  //temperature sensor service supply
578
- if (this.temperatureSensorSupply && hasSupplyTemperature && mielHvac.supplyTemperature !== null) {
575
+ if (this.temperatureSensorSupply && hasSupplyTemperature && this.accessory.supplyTemperature !== null) {
579
576
  const debug = this.enableDebugMode ? this.emit('debug', `Prepare supply temperature sensor service`) : false;
580
577
  this.supplyTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Supply`, `Supply Temperature Sensor ${deviceId}`);
581
578
  this.supplyTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
@@ -587,14 +584,14 @@ class DeviceErv extends EventEmitter {
587
584
  minStep: 0.5
588
585
  })
589
586
  .onGet(async () => {
590
- const state = mielHvac.supplyTemperature;
587
+ const state = this.accessory.supplyTemperature;
591
588
  return state;
592
589
  })
593
590
  accessory.addService(this.supplyTemperatureSensorService);
594
591
  };
595
592
 
596
593
  //temperature sensor service outdoor
597
- if (this.temperatureSensorOutdoor && hasOutdoorTemperature && mielHvac.outdoorTemperature !== null) {
594
+ if (this.temperatureSensorOutdoor && hasOutdoorTemperature && this.accessory.outdoorTemperature !== null) {
598
595
  const debug = this.enableDebugMode ? this.emit('debug', `Prepare outdoor temperature sensor service`) : false;
599
596
  this.outdoorTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Outdoor`, `Outdoor Temperature Sensor ${deviceId}`);
600
597
  this.outdoorTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
@@ -606,7 +603,7 @@ class DeviceErv extends EventEmitter {
606
603
  minStep: 0.5
607
604
  })
608
605
  .onGet(async () => {
609
- const state = mielHvac.outdoorTemperature;
606
+ const state = this.accessory.outdoorTemperature;
610
607
  return state;
611
608
  })
612
609
  accessory.addService(this.outdoorTemperatureSensorService);
@@ -618,7 +615,7 @@ class DeviceErv extends EventEmitter {
618
615
  this.coreMaintenanceService.setCharacteristic(Characteristic.ConfiguredName, `${serviceName} Core Maintenance`);
619
616
  this.coreMaintenanceService.getCharacteristic(Characteristic.FilterChangeIndication)
620
617
  .onGet(async () => {
621
- const value = mielHvac.coreMaintenanceRequired;
618
+ const value = this.accessory.coreMaintenanceRequired;
622
619
  return value;
623
620
  });
624
621
  this.coreMaintenanceService.getCharacteristic(Characteristic.ResetFilterIndication)
@@ -632,7 +629,7 @@ class DeviceErv extends EventEmitter {
632
629
  this.filterMaintenanceService.setCharacteristic(Characteristic.ConfiguredName, `${serviceName} Filter Maintenance`);
633
630
  this.filterMaintenanceService.getCharacteristic(Characteristic.FilterChangeIndication)
634
631
  .onGet(async () => {
635
- const value = mielHvac.filterMaintenanceRequired;
632
+ const value = this.accessory.filterMaintenanceRequired;
636
633
  return value;
637
634
  });
638
635
  this.filterMaintenanceService.getCharacteristic(Characteristic.ResetFilterIndication)
@@ -647,12 +644,12 @@ class DeviceErv extends EventEmitter {
647
644
  this.carbonDioxideSensorService.setCharacteristic(Characteristic.ConfiguredName, `${serviceName} CO2 Sensor`);
648
645
  this.carbonDioxideSensorService.getCharacteristic(Characteristic.CarbonDioxideDetected)
649
646
  .onGet(async () => {
650
- const value = mielHvac.roomCO2Detected;
647
+ const value = this.accessory.roomCO2Detected;
651
648
  return value;
652
649
  });
653
650
  this.carbonDioxideSensorService.getCharacteristic(Characteristic.CarbonDioxideLevel)
654
651
  .onGet(async () => {
655
- const value = mielHvac.roomCO2Level;
652
+ const value = this.accessory.roomCO2Level;
656
653
  return value;
657
654
  });
658
655
  accessory.addService(this.carbonDioxideSensorService);
@@ -665,12 +662,12 @@ class DeviceErv extends EventEmitter {
665
662
  this.airQualitySensorService.setCharacteristic(Characteristic.ConfiguredName, `${serviceName} PM2.5 Sensor`);
666
663
  this.airQualitySensorService.getCharacteristic(Characteristic.AirQuality)
667
664
  .onGet(async () => {
668
- const value = mielHvac.pM25AirQuality;
665
+ const value = this.accessory.pM25AirQuality;
669
666
  return value;
670
667
  });
671
668
  this.airQualitySensorService.getCharacteristic(Characteristic.PM2_5Density)
672
669
  .onGet(async () => {
673
- const value = mielHvac.pM25Level;
670
+ const value = this.accessory.pM25Level;
674
671
  return value;
675
672
  });
676
673
  accessory.addService(this.airQualitySensorService);
@@ -723,7 +720,7 @@ class DeviceErv extends EventEmitter {
723
720
  };
724
721
 
725
722
  await this.melCloudErv.send(deviceData, this.displayMode);
726
- const info = this.disableLogInfo ? false : this.emit('message', `${state ? 'Set:' : 'Unset:'} ${name}`);
723
+ const info = this.disableLogInfo ? false : this.emit('info', `${state ? 'Set:' : 'Unset:'} ${name}`);
727
724
  } catch (error) {
728
725
  this.emit('warn', `Set preset error: ${error}`);
729
726
  };
@@ -832,12 +829,12 @@ class DeviceErv extends EventEmitter {
832
829
  deviceData.hideOutdoorTemperature = state;
833
830
  break;
834
831
  default:
835
- this.emit('message', `Unknown button mode: ${mode}`);
832
+ this.emit('warn', `Unknown button mode: ${mode}`);
836
833
  break;
837
834
  };
838
835
 
839
836
  await this.melCloudErv.send(deviceData, this.displayMode);
840
- const info = this.disableLogInfo ? false : this.emit('message', `${state ? `Set: ${buttonName}` : `Unset: ${buttonName}, Set: ${button.previousValue}`}`);
837
+ const info = this.disableLogInfo ? false : this.emit('info', `${state ? `Set: ${buttonName}` : `Unset: ${buttonName}, Set: ${button.previousValue}`}`);
841
838
  } catch (error) {
842
839
  this.emit('warn', `Set button error: ${error}`);
843
840
  };
@@ -939,98 +936,92 @@ class DeviceErv extends EventEmitter {
939
936
  const ventilationMode = deviceData.Device.VentilationMode;
940
937
 
941
938
  //accessory
942
- const obj = {
943
- presets: presetsOnServer,
944
- hasRoomTemperature: hasRoomTemperature,
945
- hasSupplyTemperature: hasSupplyTemperature,
946
- hasOutdoorTemperature: hasOutdoorTemperature,
947
- hasCoolOperationMode: hasCoolOperationMode,
948
- hasHeatOperationMode: hasHeatOperationMode,
949
- hasCO2Sensor: hasCO2Sensor,
950
- roomCO2Level: roomCO2Level,
951
- roomCO2Detected: roomCO2Detected,
952
- hasPM25Sensor: hasPM25Sensor,
953
- pM25SensorStatus: pM25SensorStatus,
954
- pM25Level: pM25Level,
955
- pM25AirQuality: pM25AirQuality,
956
- hasAutoVentilationMode: hasAutoVentilationMode,
957
- hasBypassVentilationMode: hasBypassVentilationMode,
958
- hasAutomaticFanSpeed: hasAutomaticFanSpeed,
959
- coreMaintenanceRequired: coreMaintenanceRequired,
960
- filterMaintenanceRequired: filterMaintenanceRequired,
961
- actualVentilationMode: actualVentilationMode,
962
- numberOfFanSpeeds: numberOfFanSpeeds,
963
- power: power ? 1 : 0,
964
- operationMode: operationMode,
965
- currentOperationMode: 0,
966
- targetOperationMode: 0,
967
- ventilationMode: ventilationMode,
968
- roomTemperature: roomTemperature,
969
- supplyTemperature: supplyTemperature,
970
- outdoorTemperature: outdoorTemperature,
971
- setTemperature: setTemperature,
972
- defaultHeatingSetTemperature: defaultHeatingSetTemperature,
973
- defaultCoolingSetTemperature: defaultCoolingSetTemperature,
974
- lockPhysicalControl: 0,
975
- temperatureIncrement: temperatureIncrement,
976
- minTempHeat: minTempHeat,
977
- temperatureIncrement: maxTempHeat,
978
- minTempCoolDry: minTempCoolDry,
979
- maxTempCoolDry: maxTempCoolDry,
980
- useFahrenheit: this.useFahrenheit,
981
- temperatureUnit: this.useFahrenheit,
982
- };
939
+ this.accessory.presets = presetsOnServer;
940
+ this.accessory.hasRoomTemperature = hasRoomTemperature;
941
+ this.accessory.hasSupplyTemperature = hasSupplyTemperature;
942
+ this.accessory.hasOutdoorTemperature = hasOutdoorTemperature;
943
+ this.accessory.hasCoolOperationMode = hasCoolOperationMode;
944
+ this.accessory.hasHeatOperationMode = hasHeatOperationMode;
945
+ this.accessory.hasCO2Sensor = hasCO2Sensor;
946
+ this.accessory.roomCO2Level = roomCO2Level;
947
+ this.accessory.roomCO2Detected = roomCO2Detected;
948
+ this.accessory.hasPM25Sensor = hasPM25Sensor;
949
+ this.accessory.pM25SensorStatus = pM25SensorStatus;
950
+ this.accessory.pM25Level = pM25Level;
951
+ this.accessory.pM25AirQuality = pM25AirQuality;
952
+ this.accessory.hasAutoVentilationMode = hasAutoVentilationMode;
953
+ this.accessory.hasBypassVentilationMode = hasBypassVentilationMode;
954
+ this.accessory.hasAutomaticFanSpeed = hasAutomaticFanSpeed;
955
+ this.accessory.coreMaintenanceRequired = coreMaintenanceRequired;
956
+ this.accessory.filterMaintenanceRequired = filterMaintenanceRequired;
957
+ this.accessory.actualVentilationMode = actualVentilationMode;
958
+ this.accessory.numberOfFanSpeeds = numberOfFanSpeeds;
959
+ this.accessory.power = power ? 1 : 0;
960
+ this.accessory.operationMode = operationMode;
961
+ this.accessory.ventilationMode = ventilationMode;
962
+ this.accessory.roomTemperature = roomTemperature;
963
+ this.accessory.supplyTemperature = supplyTemperature;
964
+ this.accessory.outdoorTemperature = outdoorTemperature;
965
+ this.accessory.setTemperature = setTemperature;
966
+ this.accessory.defaultHeatingSetTemperature = defaultHeatingSetTemperature;
967
+ this.accessory.defaultCoolingSetTemperature = defaultCoolingSetTemperature;
968
+ this.accessory.lockPhysicalControl = 0;
969
+ this.accessory.temperatureIncrement = temperatureIncrement;
970
+ this.accessory.minTempHeat = minTempHeat;
971
+ this.accessory.temperatureIncrement = maxTempHeat;
972
+ this.accessory.minTempCoolDry = minTempCoolDry;
973
+ this.accessory.maxTempCoolDry = maxTempCoolDry;
983
974
 
984
975
  //ventilation mode - 0, HEAT, 2, COOL, 4, 5, 6, FAN, AUTO
985
976
  switch (this.displayMode) {
986
977
  case 1: //Heater Cooler
987
978
  switch (ventilationMode) {
988
979
  case 0: //LOSSNAY
989
- obj.currentOperationMode = 2; //INACTIVE, IDLE, HEATING, COOLIN
990
- obj.targetOperationMode = 1; //AUTO, HEAT, COOL
980
+ this.accessory.currentOperationMode = 2; //INACTIVE, IDLE, HEATING, COOLIN
981
+ this.accessory.targetOperationMode = 1; //AUTO, HEAT, COOL
991
982
  break;
992
983
  case 1: //BYPASS
993
- obj.currentOperationMode = 3;
994
- obj.targetOperationMode = 2;
984
+ this.accessory.currentOperationMode = 3;
985
+ this.accessory.targetOperationMode = 2;
995
986
  break;
996
987
  case 2: //AUTO
997
988
  switch (actualVentilationMode) {
998
989
  case 0: //LOSSNAY
999
- obj.currentOperationMode = 2;
990
+ this.accessory.currentOperationMode = 2;
1000
991
  break;
1001
992
  case 1: //BYPASS
1002
- obj.currentOperationMode = 3;
993
+ this.accessory.currentOperationMode = 3;
1003
994
  break;
1004
995
  default:
1005
996
  this.emit('warn', `Unknown actual ventilation mode: ${actualVentilationMode}`);
1006
997
  break;
1007
998
  };
1008
- obj.targetOperationMode = 0;
999
+ this.accessory.targetOperationMode = 0;
1009
1000
  break;
1010
1001
  default:
1011
1002
  this.emit('warn', `Unknown ventilation mode: ${ventilationMode}`);
1012
1003
  break;
1013
1004
  };
1014
1005
 
1015
- obj.currentOperationMode = !power ? 0 : obj.currentOperationMode;
1016
- obj.operationModeSetPropsMinValue = hasAutoVentilationMode ? 0 : 1;
1017
- obj.operationModeSetPropsMaxValue = hasAutoVentilationMode ? 2 : 2;
1018
- obj.operationModeSetPropsValidValues = hasAutoVentilationMode ? (hasBypassVentilationMode ? [0, 1, 2] : [0, 2]) : (hasBypassVentilationMode ? [1, 2] : [2]);
1006
+ this.accessory.currentOperationMode = !power ? 0 : this.accessory.currentOperationMode;
1007
+ this.accessory.operationModeSetPropsMinValue = hasAutoVentilationMode ? 0 : 1;
1008
+ this.accessory.operationModeSetPropsMaxValue = hasAutoVentilationMode ? 2 : 2;
1009
+ this.accessory.operationModeSetPropsValidValues = hasAutoVentilationMode ? (hasBypassVentilationMode ? [0, 1, 2] : [0, 2]) : (hasBypassVentilationMode ? [1, 2] : [2]);
1019
1010
 
1020
1011
  //fan speed mode
1021
- obj.fanSpeedSetPropsMaxValue = 2;
1012
+ this.accessory.fanSpeedSetPropsMaxValue = 2;
1022
1013
  switch (numberOfFanSpeeds) {
1023
1014
  case 2: //Fan speed mode 2
1024
- obj.fanSpeed = hasAutomaticFanSpeed ? [3, 1, 2][setFanSpeed] : [0, 1, 2][setFanSpeed];
1025
- obj.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 3 : 2;
1015
+ this.accessory.fanSpeed = hasAutomaticFanSpeed ? [3, 1, 2][setFanSpeed] : [0, 1, 2][setFanSpeed];
1016
+ this.accessory.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 3 : 2;
1026
1017
  break;
1027
1018
  case 3: //Fan speed mode 3
1028
- this.obj.fanSpeed = hasAutomaticFanSpeed ? [4, 1, 2, 3][setFanSpeed] : [0, 1, 2, 3][setFanSpeed];
1029
- obj.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 4 : 3;
1019
+ this.this.accessory.fanSpeed = hasAutomaticFanSpeed ? [4, 1, 2, 3][setFanSpeed] : [0, 1, 2, 3][setFanSpeed];
1020
+ this.accessory.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 4 : 3;
1030
1021
  break;
1031
1022
  case 4: //Fan speed mode 4
1032
- obj.fanSpeed = hasAutomaticFanSpeed ? [5, 1, 2, 3, 4][setFanSpeed] : [0, 1, 2, 3, 4][setFanSpeed];
1033
- obj.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 5 : 4;
1023
+ this.accessory.fanSpeed = hasAutomaticFanSpeed ? [5, 1, 2, 3, 4][setFanSpeed] : [0, 1, 2, 3, 4][setFanSpeed];
1024
+ this.accessory.fanSpeedSetPropsMaxValue = hasAutomaticFanSpeed ? 5 : 4;
1034
1025
  break;
1035
1026
  };
1036
1027
 
@@ -1038,12 +1029,12 @@ class DeviceErv extends EventEmitter {
1038
1029
  if (this.melCloudService) {
1039
1030
  this.melCloudService
1040
1031
  .updateCharacteristic(Characteristic.Active, power)
1041
- .updateCharacteristic(Characteristic.CurrentHeaterCoolerState, obj.currentOperationMode)
1042
- .updateCharacteristic(Characteristic.TargetHeaterCoolerState, obj.targetOperationMode)
1032
+ .updateCharacteristic(Characteristic.CurrentHeaterCoolerState, this.accessory.currentOperationMode)
1033
+ .updateCharacteristic(Characteristic.TargetHeaterCoolerState, this.accessory.targetOperationMode)
1043
1034
  .updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature)
1044
- .updateCharacteristic(Characteristic.RotationSpeed, obj.fanSpeed)
1045
- .updateCharacteristic(Characteristic.LockPhysicalControls, obj.lockPhysicalControl)
1046
- .updateCharacteristic(Characteristic.TemperatureDisplayUnits, obj.useFahrenheit);
1035
+ .updateCharacteristic(Characteristic.RotationSpeed, this.accessory.fanSpeed)
1036
+ .updateCharacteristic(Characteristic.LockPhysicalControls, this.accessory.lockPhysicalControl)
1037
+ .updateCharacteristic(Characteristic.TemperatureDisplayUnits, this.accessory.useFahrenheit);
1047
1038
  const updateDefCool = hasCoolOperationMode ? this.melCloudService.updateCharacteristic(Characteristic.CoolingThresholdTemperature, defaultCoolingSetTemperature) : false;
1048
1039
  const updateDefHeat = hasHeatOperationMode ? this.melCloudService.updateCharacteristic(Characteristic.HeatingThresholdTemperature, defaultHeatingSetTemperature) : false;
1049
1040
  };
@@ -1052,53 +1043,50 @@ class DeviceErv extends EventEmitter {
1052
1043
  //operation mode - 0, HEAT, 2, COOL, 4, 5, 6, FAN, AUTO
1053
1044
  switch (ventilationMode) {
1054
1045
  case 0: //LOSSNAY
1055
- obj.currentOperationMode = 1; //OFF, HEAT, COOL
1056
- obj.targetOperationMode = 1; //OFF, HEAT, COOL, AUTO
1046
+ this.accessory.currentOperationMode = 1; //OFF, HEAT, COOL
1047
+ this.accessory.targetOperationMode = 1; //OFF, HEAT, COOL, AUTO
1057
1048
  break;
1058
1049
  case 1: //BYPASS
1059
- obj.currentOperationMode = 2;
1060
- obj.targetOperationMode = 2;
1050
+ this.accessory.currentOperationMode = 2;
1051
+ this.accessory.targetOperationMode = 2;
1061
1052
  break;
1062
1053
  case 2: //AUTO
1063
1054
  switch (actualVentilationMode) {
1064
1055
  case 0: //LOSSNAY
1065
- obj.currentOperationMode = 1;
1056
+ this.accessory.currentOperationMode = 1;
1066
1057
  break;
1067
1058
  case 1: //BYPASS
1068
- obj.currentOperationMode = 2;
1059
+ this.accessory.currentOperationMode = 2;
1069
1060
  break;
1070
1061
  default:
1071
1062
  this.emit('warn', `Unknown actual ventilation mode: ${actualVentilationMode}`);
1072
1063
  break;
1073
1064
  };
1074
- obj.targetOperationMode = 3;
1065
+ this.accessory.targetOperationMode = 3;
1075
1066
  break;
1076
1067
  default:
1077
1068
  this.emit('warn', `Unknown ventilation mode: ${ventilationMode}`);
1078
1069
  break;
1079
1070
  };
1080
1071
 
1081
- obj.currentOperationMode = !power ? 0 : obj.currentOperationMode;
1082
- obj.targetOperationMode = !power ? 0 : obj.targetOperationMode;
1083
- obj.operationModeSetPropsMinValue = hasAutoVentilationMode ? 0 : 0;
1084
- obj.operationModeSetPropsMaxValue = hasAutoVentilationMode ? 3 : 2;
1085
- obj.operationModeSetPropsValidValues = hasAutoVentilationMode ? (hasBypassVentilationMode ? [0, 1, 2, 3] : [0, 2, 3]) : (hasBypassVentilationMode ? [0, 1, 2] : [0, 2]);
1072
+ this.accessory.currentOperationMode = !power ? 0 : this.accessory.currentOperationMode;
1073
+ this.accessory.targetOperationMode = !power ? 0 : this.accessory.targetOperationMode;
1074
+ this.accessory.operationModeSetPropsMinValue = hasAutoVentilationMode ? 0 : 0;
1075
+ this.accessory.operationModeSetPropsMaxValue = hasAutoVentilationMode ? 3 : 2;
1076
+ this.accessory.operationModeSetPropsValidValues = hasAutoVentilationMode ? (hasBypassVentilationMode ? [0, 1, 2, 3] : [0, 2, 3]) : (hasBypassVentilationMode ? [0, 1, 2] : [0, 2]);
1086
1077
 
1087
1078
  //update characteristics
1088
1079
  if (this.melCloudService) {
1089
1080
  this.melCloudService
1090
- .updateCharacteristic(Characteristic.CurrentHeatingCoolingState, obj.currentOperationMode)
1091
- .updateCharacteristic(Characteristic.TargetHeatingCoolingState, obj.targetOperationMode)
1081
+ .updateCharacteristic(Characteristic.CurrentHeatingCoolingState, this.accessory.currentOperationMode)
1082
+ .updateCharacteristic(Characteristic.TargetHeatingCoolingState, this.accessory.targetOperationMode)
1092
1083
  .updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature)
1093
1084
  .updateCharacteristic(Characteristic.TargetTemperature, setTemperature)
1094
- .updateCharacteristic(Characteristic.TemperatureDisplayUnits, obj.useFahrenheit);
1085
+ .updateCharacteristic(Characteristic.TemperatureDisplayUnits, this.accessory.useFahrenheit);
1095
1086
  };
1096
1087
  break;
1097
1088
  };
1098
1089
 
1099
- //add obj to mielHvac
1100
- this.mielHvac = obj;
1101
-
1102
1090
  //update temperature sensors
1103
1091
  if (this.roomTemperatureSensorService) {
1104
1092
  this.roomTemperatureSensorService
@@ -1196,7 +1184,7 @@ class DeviceErv extends EventEmitter {
1196
1184
  button.state = power ? (setFanSpeed === 4) : false;
1197
1185
  break;
1198
1186
  case 15: //PHYSICAL LOCK CONTROLS
1199
- button.state = (obj.lockPhysicalControl === 1);
1187
+ button.state = (this.accessory.lockPhysicalControl === 1);
1200
1188
  break;
1201
1189
  case 16: //ROOM TEMP HIDE
1202
1190
  button.state = (hideRoomTemperature === true);
@@ -1223,21 +1211,21 @@ class DeviceErv extends EventEmitter {
1223
1211
 
1224
1212
  //log current state
1225
1213
  if (!this.disableLogInfo) {
1226
- this.emit('message', `Power: ${power ? 'ON' : 'OFF'}`);
1227
- this.emit('message', `Target ventilation mode: ${Ventilation.OperationMode[ventilationMode]}`);
1228
- this.emit('message', `Current ventilation mode: ${Ventilation.OperationMode[actualVentilationMode]}`);
1229
- this.emit('message', `Target temperature: ${setTemperature}${obj.temperatureUnit}`);
1230
- this.emit('message', `Room temperature: ${roomTemperature}${obj.temperatureUnit}`);
1231
- const info1 = hasSupplyTemperature && deviceData.Device.SupplyTemperature !== null ? this.emit('message', `Supply temperature: ${roomTemperature}${obj.temperatureUnit}`) : false;
1232
- const info2 = hasOutdoorTemperature && deviceData.Device.OutdoorTemperature !== null ? this.emit('message', `Outdoor temperature: ${roomTemperature}${obj.temperatureUnit}`) : false;
1233
- this.emit('message', `Fan speed mode: ${Ventilation.FanSpeed[setFanSpeed]}`);
1234
- this.emit('message', `Temperature display unit: ${obj.temperatureUnit}`);
1235
- this.emit('message', `Core maintenance: ${Ventilation.CoreMaintenance[coreMaintenanceRequired]}`);
1236
- this.emit('message', `Filter maintenance: ${Ventilation.FilterMaintenance[filterMaintenanceRequired]}`);
1237
- const info5 = hasCO2Sensor ? this.emit('message', `CO2 detected: ${Ventilation.Co2Detected[roomCO2Detected]}`) : false;
1238
- const info6 = hasCO2Sensor ? this.emit('message', `CO2 level: ${roomCO2Level} ppm`) : false;
1239
- const info7 = hasPM25Sensor ? this.emit('message', `PM2.5 air quality: ${Ventilation.PM25AirQuality[pM25AirQuality]}`) : false;
1240
- const info8 = hasPM25Sensor ? this.emit('message', `PM2.5 level: ${pM25Level} µg/m`) : false;
1214
+ this.emit('info', `Power: ${power ? 'ON' : 'OFF'}`);
1215
+ this.emit('info', `Target ventilation mode: ${Ventilation.OperationMode[ventilationMode]}`);
1216
+ this.emit('info', `Current ventilation mode: ${Ventilation.OperationMode[actualVentilationMode]}`);
1217
+ this.emit('info', `Target temperature: ${setTemperature}${this.accessory.temperatureUnit}`);
1218
+ this.emit('info', `Room temperature: ${roomTemperature}${this.accessory.temperatureUnit}`);
1219
+ const info1 = hasSupplyTemperature && deviceData.Device.SupplyTemperature !== null ? this.emit('info', `Supply temperature: ${roomTemperature}${this.accessory.temperatureUnit}`) : false;
1220
+ const info2 = hasOutdoorTemperature && deviceData.Device.OutdoorTemperature !== null ? this.emit('info', `Outdoor temperature: ${roomTemperature}${this.accessory.temperatureUnit}`) : false;
1221
+ this.emit('info', `Fan speed mode: ${Ventilation.FanSpeed[setFanSpeed]}`);
1222
+ this.emit('info', `Temperature display unit: ${this.accessory.temperatureUnit}`);
1223
+ this.emit('info', `Core maintenance: ${Ventilation.CoreMaintenance[coreMaintenanceRequired]}`);
1224
+ this.emit('info', `Filter maintenance: ${Ventilation.FilterMaintenance[filterMaintenanceRequired]}`);
1225
+ const info5 = hasCO2Sensor ? this.emit('info', `CO2 detected: ${Ventilation.Co2Detected[roomCO2Detected]}`) : false;
1226
+ const info6 = hasCO2Sensor ? this.emit('info', `CO2 level: ${roomCO2Level} ppm`) : false;
1227
+ const info7 = hasPM25Sensor ? this.emit('info', `PM2.5 air quality: ${Ventilation.PM25AirQuality[pM25AirQuality]}`) : false;
1228
+ const info8 = hasPM25Sensor ? this.emit('info', `PM2.5 level: ${pM25Level} µg/m`) : false;
1241
1229
  };
1242
1230
 
1243
1231
  //prepare accessory