homebridge-melcloud-control 4.2.6-beta.10 → 4.2.6-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.2.6-beta.10",
4
+ "version": "4.2.6-beta.11",
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
@@ -355,7 +355,6 @@ class DeviceAta extends EventEmitter {
355
355
  .onSet(async (state) => {
356
356
  try {
357
357
  deviceData.Device.Power = state ? true : false;
358
-
359
358
  if (this.logInfo) this.emit('info', `Set power: ${state ? 'On' : 'Off'}`);
360
359
  await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.Power);
361
360
  } catch (error) {
@@ -382,18 +381,16 @@ class DeviceAta extends EventEmitter {
382
381
  switch (value) {
383
382
  case 0: //AUTO - AUTO
384
383
  value = autoDryFanMode;
385
- deviceData.Device.OperationMode = value;
386
384
  break;
387
385
  case 1: //HEAT - HEAT
388
386
  value = heatDryFanMode;
389
- deviceData.Device.OperationMode = value;
390
387
  break;
391
388
  case 2: //COOL - COOL
392
389
  value = coolDryFanMode;
393
- deviceData.Device.OperationMode = value;
394
390
  break;
395
391
  };
396
392
 
393
+ deviceData.Device.OperationMode = value;
397
394
  if (this.logInfo) this.emit('info', `Set operation mode: ${AirConditioner.OperationModeMapEnumToString[value]}`);
398
395
  await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.OperationMode);
399
396
  } catch (error) {
@@ -456,7 +453,7 @@ class DeviceAta extends EventEmitter {
456
453
  if (this.logInfo) this.emit('info', `Set air direction mode: ${AirConditioner.AirDirectionMapEnumToString[value]}`);
457
454
  await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.VaneVerticalVaneHorizontal);
458
455
  } catch (error) {
459
- if (this.logWarn) this.emit('warn', `Set vane swing mode error: ${error}`);
456
+ if (this.logWarn) this.emit('warn', `Set air direction mode error: ${error}`);
460
457
  };
461
458
  });
462
459
  };
@@ -539,10 +536,11 @@ class DeviceAta extends EventEmitter {
539
536
  };
540
537
  });
541
538
  this.melCloudService = melCloudService;
539
+ accessory.addService(melCloudService);
542
540
  break;
543
541
  case 2: //Thermostat
544
542
  if (this.logDebug) this.emit('debug', `Prepare thermostat service`);
545
- const melCloudServiceT = new Service.Thermostat(serviceName, `HeaterCooler ${deviceId}`);
543
+ const melCloudServiceT = new Service.Thermostat(serviceName, `Thermostat ${deviceId}`);
546
544
  melCloudServiceT.setPrimaryService(true);
547
545
  melCloudServiceT.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
548
546
  .onGet(async () => {
@@ -565,26 +563,23 @@ class DeviceAta extends EventEmitter {
565
563
  switch (value) {
566
564
  case 0: //OFF - POWER OFF
567
565
  value = deviceData.Device.OperationMode;
568
- deviceData.Device.Power = false;
569
566
  flag = AirConditioner.EffectiveFlags.Power;
570
567
  break;
571
568
  case 1: //HEAT - HEAT
572
- deviceData.Device.Power = true;
573
569
  value = heatDryFanMode;
574
570
  flag = AirConditioner.EffectiveFlags.PowerOperationModeSetTemperature;
575
571
  break;
576
572
  case 2: //COOL - COOL
577
573
  value = coolDryFanMode;
578
- deviceData.Device.Power = true;
579
574
  flag = AirConditioner.EffectiveFlags.PowerOperationModeSetTemperature
580
575
  break;
581
576
  case 3: //AUTO - AUTO
582
577
  value = autoDryFanMode;
583
- deviceData.Device.Power = true;
584
578
  flag = AirConditioner.EffectiveFlags.PowerOperationModeSetTemperature;
585
579
  break;
586
580
  };
587
581
 
582
+ deviceData.Device.Power = value > 0 ? true : false;
588
583
  deviceData.Device.OperationMode = value;
589
584
  if (this.logInfo) this.emit('info', `Set operation mode: ${AirConditioner.OperationModeMapEnumToString[value]}`);
590
585
  await this.melCloudAta.send(this.accountType, this.displayType, deviceData, flag);
@@ -634,6 +629,7 @@ class DeviceAta extends EventEmitter {
634
629
  };
635
630
  });
636
631
  this.melCloudService = melCloudServiceT;
632
+ accessory.addService(melCloudServiceT);
637
633
  break;
638
634
  };
639
635
 
@@ -1609,7 +1605,7 @@ class DeviceAta extends EventEmitter {
1609
1605
  obj.operationModeSetPropsValidValues = supportsAuto && supportsHeat ? [0, 1, 2, 3] : !supportsAuto && supportsHeat ? [0, 1, 2] : supportsAuto && !supportsHeat ? [0, 2, 3] : [0, 2];
1610
1606
 
1611
1607
  //update characteristics
1612
- this.melCloudServiceT
1608
+ this.melCloudService
1613
1609
  ?.updateCharacteristic(Characteristic.CurrentHeatingCoolingState, obj.currentOperationMode)
1614
1610
  .updateCharacteristic(Characteristic.TargetHeatingCoolingState, obj.targetOperationMode)
1615
1611
  .updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature)
package/src/deviceerv.js CHANGED
@@ -316,9 +316,9 @@ class DeviceErv extends EventEmitter {
316
316
  switch (this.displayType) {
317
317
  case 1: //Heater Cooler
318
318
  if (this.logDebug) this.emit('debug', `Prepare heather/cooler service`);
319
- this.melCloudService = new Service.HeaterCooler(serviceName, `HeaterCooler ${deviceId}`);
320
- this.melCloudService.setPrimaryService(true);
321
- this.melCloudService.getCharacteristic(Characteristic.Active)
319
+ const melCloudService = new Service.HeaterCooler(serviceName, `HeaterCooler ${deviceId}`);
320
+ melCloudService.setPrimaryService(true);
321
+ melCloudService.getCharacteristic(Characteristic.Active)
322
322
  .onGet(async () => {
323
323
  const state = this.accessory.power;
324
324
  return state;
@@ -332,12 +332,12 @@ class DeviceErv extends EventEmitter {
332
332
  if (this.logWarn) this.emit('warn', `Set power error: ${error}`);
333
333
  };
334
334
  });
335
- this.melCloudService.getCharacteristic(Characteristic.CurrentHeaterCoolerState)
335
+ melCloudService.getCharacteristic(Characteristic.CurrentHeaterCoolerState)
336
336
  .onGet(async () => {
337
337
  const value = this.accessory.currentOperationMode;
338
338
  return value;
339
339
  });
340
- this.melCloudService.getCharacteristic(Characteristic.TargetHeaterCoolerState)
340
+ melCloudService.getCharacteristic(Characteristic.TargetHeaterCoolerState)
341
341
  .setProps({
342
342
  minValue: this.accessory.operationModeSetPropsMinValue,
343
343
  maxValue: this.accessory.operationModeSetPropsMaxValue,
@@ -367,13 +367,13 @@ class DeviceErv extends EventEmitter {
367
367
  if (this.logWarn) this.emit('warn', `Set operation mode error: ${error}`);
368
368
  };
369
369
  });
370
- this.melCloudService.getCharacteristic(Characteristic.CurrentTemperature)
370
+ melCloudService.getCharacteristic(Characteristic.CurrentTemperature)
371
371
  .onGet(async () => {
372
372
  const value = this.accessory.roomTemperature;
373
373
  return value;
374
374
  });
375
375
  if (supportsFanSpeed) {
376
- this.melCloudService.getCharacteristic(Characteristic.RotationSpeed)
376
+ melCloudService.getCharacteristic(Characteristic.RotationSpeed)
377
377
  .setProps({
378
378
  minValue: 0,
379
379
  maxValue: this.accessory.fanSpeedSetPropsMaxValue,
@@ -410,7 +410,7 @@ class DeviceErv extends EventEmitter {
410
410
  }
411
411
  //device can cool
412
412
  if (supportsAutoVentilationMode && supportsCoolOperationMode) {
413
- this.melCloudService.getCharacteristic(Characteristic.CoolingThresholdTemperature)
413
+ melCloudService.getCharacteristic(Characteristic.CoolingThresholdTemperature)
414
414
  .setProps({
415
415
  minValue: this.accessory.minTempCoolDry,
416
416
  maxValue: this.accessory.maxTempCoolDry,
@@ -432,7 +432,7 @@ class DeviceErv extends EventEmitter {
432
432
  };
433
433
  //device can heat
434
434
  if (supportsAutoVentilationMode && supportsHeatOperationMode) {
435
- this.melCloudService.getCharacteristic(Characteristic.HeatingThresholdTemperature)
435
+ melCloudService.getCharacteristic(Characteristic.HeatingThresholdTemperature)
436
436
  .setProps({
437
437
  minValue: this.accessory.minTempHeat,
438
438
  maxValue: this.accessory.maxTempHeat,
@@ -452,7 +452,7 @@ class DeviceErv extends EventEmitter {
452
452
  };
453
453
  });
454
454
  };
455
- this.melCloudService.getCharacteristic(Characteristic.TemperatureDisplayUnits)
455
+ melCloudService.getCharacteristic(Characteristic.TemperatureDisplayUnits)
456
456
  .onGet(async () => {
457
457
  const value = this.accessory.useFahrenheit;
458
458
  return value;
@@ -469,18 +469,18 @@ class DeviceErv extends EventEmitter {
469
469
  if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
470
470
  };
471
471
  });
472
- accessory.addService(this.melCloudService);
472
+ this.melCloudService = melCloudService;
473
473
  break;
474
474
  case 2: //Thermostat
475
475
  if (this.logDebug) this.emit('debug', `Prepare thermostat service`);
476
- this.melCloudService = new Service.Thermostat(serviceName, `Thermostat ${deviceId}`);
477
- this.melCloudService.setPrimaryService(true);
478
- this.melCloudService.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
476
+ const melCloudServiceT = new Service.Thermostat(serviceName, `Thermostat ${deviceId}`);
477
+ melCloudServiceT.setPrimaryService(true);
478
+ melCloudServiceT.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
479
479
  .onGet(async () => {
480
480
  const value = this.accessory.currentOperationMode;
481
481
  return value;
482
482
  });
483
- this.melCloudService.getCharacteristic(Characteristic.TargetHeatingCoolingState)
483
+ melCloudServiceT.getCharacteristic(Characteristic.TargetHeatingCoolingState)
484
484
  .setProps({
485
485
  minValue: this.accessory.operationModeSetPropsMinValue,
486
486
  maxValue: this.accessory.operationModeSetPropsMaxValue,
@@ -500,33 +500,33 @@ class DeviceErv extends EventEmitter {
500
500
  break;
501
501
  case 1: //HEAT - LOSSNAY
502
502
  deviceData.Device.Power = true;
503
- deviceData.Device.VentilationMode = 0;
504
503
  flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
505
504
  break;
506
505
  case 2: //COOL - BYPASS
507
506
  deviceData.Device.Power = true;
508
- deviceData.Device.VentilationMode = supportsBypassVentilationMode ? 1 : 0;
507
+ value = supportsBypassVentilationMode ? 1 : 0;
509
508
  flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
510
509
  break;
511
510
  case 3: //AUTO - AUTO
512
511
  deviceData.Device.Power = true;
513
- deviceData.Device.VentilationMode = supportsAutoVentilationMode ? 2 : 0;
512
+ value = supportsAutoVentilationMode ? 2 : 0;
514
513
  flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
515
514
  break;
516
515
  };
517
516
 
517
+ deviceData.Device.VentilationMode = value;
518
518
  if (this.logInfo) this.emit('info', `Set operation mode: ${Ventilation.VentilationModeMapEnumToString[deviceData.Device.VentilationMode]}`);
519
519
  await this.melCloudErv.send(this.accountType, this.displayType, deviceData, flag);
520
520
  } catch (error) {
521
521
  if (this.logWarn) this.emit('warn', `Set operation mode error: ${error}`);
522
522
  };
523
523
  });
524
- this.melCloudService.getCharacteristic(Characteristic.CurrentTemperature)
524
+ melCloudServiceT.getCharacteristic(Characteristic.CurrentTemperature)
525
525
  .onGet(async () => {
526
526
  const value = this.accessory.roomTemperature;
527
527
  return value;
528
528
  });
529
- this.melCloudService.getCharacteristic(Characteristic.TargetTemperature)
529
+ melCloudServiceT.getCharacteristic(Characteristic.TargetTemperature)
530
530
  .setProps({
531
531
  minValue: this.accessory.minTempHeat,
532
532
  maxValue: this.accessory.maxTempHeat,
@@ -545,7 +545,7 @@ class DeviceErv extends EventEmitter {
545
545
  if (this.logWarn) this.emit('warn', `Set temperature error: ${error}`);
546
546
  };
547
547
  });
548
- this.melCloudService.getCharacteristic(Characteristic.TemperatureDisplayUnits)
548
+ melCloudServiceT.getCharacteristic(Characteristic.TemperatureDisplayUnits)
549
549
  .onGet(async () => {
550
550
  const value = this.accessory.useFahrenheit;
551
551
  return value;
@@ -562,7 +562,7 @@ class DeviceErv extends EventEmitter {
562
562
  if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
563
563
  };
564
564
  });
565
- accessory.addService(this.melCloudService);
565
+ this.melCloudService = melCloudServiceT;
566
566
  break;
567
567
  };
568
568
 
@@ -1319,8 +1319,8 @@ class DeviceErv extends EventEmitter {
1319
1319
  .updateCharacteristic(Characteristic.RotationSpeed, obj.fanSpeed)
1320
1320
  .updateCharacteristic(Characteristic.LockPhysicalControls, obj.lockPhysicalControl)
1321
1321
  .updateCharacteristic(Characteristic.TemperatureDisplayUnits, obj.useFahrenheit);
1322
- const updateDefCool = supportsCoolOperationMode ? this.melCloudService?.updateCharacteristic(Characteristic.CoolingThresholdTemperature, defaultCoolingSetTemperature) : false;
1323
- const updateDefHeat = supportsHeatOperationMode ? this.melCloudService?.updateCharacteristic(Characteristic.HeatingThresholdTemperature, defaultHeatingSetTemperature) : false;
1322
+ if (supportsCoolOperationMode) this.melCloudService?.updateCharacteristic(Characteristic.CoolingThresholdTemperature, defaultCoolingSetTemperature);
1323
+ if (supportsHeatOperationMode) this.melCloudService?.updateCharacteristic(Characteristic.HeatingThresholdTemperature, defaultHeatingSetTemperature);
1324
1324
  break;
1325
1325
  case 2: //Thermostat
1326
1326
  //operation mode - 0, HEAT, 2, COOL, 4, 5, 6, FAN, AUTO