homebridge-melcloud-control 4.0.0-beta.176 → 4.0.0-beta.178

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/deviceata.js +23 -18
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.0.0-beta.176",
4
+ "version": "4.0.0-beta.178",
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
@@ -319,19 +319,20 @@ class DeviceAta extends EventEmitter {
319
319
  try {
320
320
  switch (value) {
321
321
  case 0: //AUTO - AUTO
322
- deviceData.Device.OperationMode = autoDryFanMode;
322
+ value = autoDryFanMode;
323
323
  break;
324
324
  case 1: //HEAT - HEAT
325
- deviceData.Device.OperationMode = heatDryFanMode;
325
+ value = heatDryFanMode;
326
326
  break;
327
327
  case 2: //COOL - COOL
328
- deviceData.Device.OperationMode = coolDryFanMode;
328
+ value = coolDryFanMode;
329
329
  break;
330
330
  };
331
331
 
332
+ deviceData.Device.OperationMode = value;
332
333
  deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.OperationMode;
333
334
  await this.melCloudAta.send(this.accountType, this.displayMode, deviceData);
334
- if (this.logInfo) this.emit('info', `Set operation mode: ${AirConditioner.OperationModeMapEnumToString[deviceData.Device.OperationMode]}`);
335
+ if (this.logInfo) this.emit('info', `Set operation mode: ${AirConditioner.OperationModeMapEnumToString[value]}`);
335
336
  } catch (error) {
336
337
  if (this.logWarn) this.emit('warn', `Set operation mode error: ${error}`);
337
338
  };
@@ -357,21 +358,23 @@ class DeviceAta extends EventEmitter {
357
358
  const fanKey = this.accountType === 'melcloud' ? 'FanSpeed' : 'SetFanSpeed';
358
359
  switch (numberOfFanSpeeds) {
359
360
  case 2: //Fan speed mode 2
360
- deviceData.Device[fanKey] = supportsAutomaticFanSpeed ? [0, 1, 2, 0][value] : [1, 1, 2][value];
361
+ value = supportsAutomaticFanSpeed ? [0, 1, 2, 0][value] : [1, 1, 2][value];
361
362
  break;
362
363
  case 3: //Fan speed mode 3
363
- deviceData.Device[fanKey] = supportsAutomaticFanSpeed ? [0, 1, 2, 3, 0][value] : [1, 1, 2, 3][value];
364
+ value = supportsAutomaticFanSpeed ? [0, 1, 2, 3, 0][value] : [1, 1, 2, 3][value];
364
365
  break;
365
366
  case 4: //Fan speed mode 4
366
- deviceData.Device[fanKey] = supportsAutomaticFanSpeed ? [0, 1, 2, 3, 4, 0][value] : [1, 1, 2, 3, 4][value];
367
+ value = supportsAutomaticFanSpeed ? [0, 1, 2, 3, 4, 0][value] : [1, 1, 2, 3, 4][value];
367
368
  break;
368
369
  case 5: //Fan speed mode 5
369
- deviceData.Device[fanKey] = supportsAutomaticFanSpeed ? [0, 1, 2, 3, 4, 5, 0][value] : [1, 1, 2, 3, 4, 5][value];
370
+ value = supportsAutomaticFanSpeed ? [0, 1, 2, 3, 4, 5, 0][value] : [1, 1, 2, 3, 4, 5][value];
370
371
  break;
371
372
  };
373
+
374
+ deviceData.Device[fanKey] = value
372
375
  deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.SetFanSpeed;
373
376
  await this.melCloudAta.send(this.accountType, this.displayMode, deviceData);
374
- if (this.logInfo) this.emit('info', `Set fan speed mode: ${AirConditioner.FanSpeedMapEnumToString[deviceData.Device[fanKey]]}`);
377
+ if (this.logInfo) this.emit('info', `Set fan speed mode: ${AirConditioner.FanSpeedMapEnumToString[value]}`);
375
378
  } catch (error) {
376
379
  if (this.logWarn) this.emit('warn', `Set fan speed mode error: ${error}`);
377
380
  };
@@ -498,28 +501,30 @@ class DeviceAta extends EventEmitter {
498
501
  try {
499
502
  switch (value) {
500
503
  case 0: //OFF - POWER OFF
504
+ value = deviceData.Device.OperationMode;
501
505
  deviceData.Device.Power = false;
502
506
  deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.Power;
503
507
  break;
504
508
  case 1: //HEAT - HEAT
505
509
  deviceData.Device.Power = true;
506
- deviceData.Device.OperationMode = heatDryFanMode;
510
+ value = heatDryFanMode;
507
511
  deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.PowerOperationModeSetTemperature;
508
512
  break;
509
513
  case 2: //COOL - COOL
514
+ value = coolDryFanMode;
510
515
  deviceData.Device.Power = true;
511
- deviceData.Device.OperationMode = coolDryFanMode;
512
516
  deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.PowerOperationModeSetTemperature
513
517
  break;
514
518
  case 3: //AUTO - AUTO
519
+ value = autoDryFanMode;
515
520
  deviceData.Device.Power = true;
516
- deviceData.Device.OperationMode = autoDryFanMode;
517
521
  deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.PowerOperationModeSetTemperature;
518
522
  break;
519
523
  };
520
524
 
525
+ deviceData.Device.OperationMode = value;
521
526
  await this.melCloudAta.send(this.accountType, this.displayMode, deviceData);
522
- const operationModeText = AirConditioner.OperationModeMapEnumToString[deviceData.Device.OperationMode];
527
+ const operationModeText = AirConditioner.OperationModeMapEnumToString[value];
523
528
  if (this.logInfo) this.emit('info', `Set operation mode: ${operationModeText}`);
524
529
  } catch (error) {
525
530
  if (this.logWarn) this.emit('warn', `Set operation mode error: ${error}`);
@@ -976,9 +981,9 @@ class DeviceAta extends EventEmitter {
976
981
  const power = deviceData.Device.Power ?? false;
977
982
  const inStandbyMode = deviceData.Device.InStandbyMode ?? false;
978
983
  const roomTemperature = deviceData.Device.RoomTemperature;
979
- const setTemperature = deviceData.Device.SetTemperature ?? 20;
980
- const defaultHeatingSetTemperature = deviceData.Device.DefaultHeatingSetTemperature ?? 20;
981
- const defaultCoolingSetTemperature = deviceData.Device.DefaultCoolingSetTemperature ?? 23;
984
+ const setTemperature = deviceData.Device.SetTemperature;
985
+ const defaultHeatingSetTemperature = deviceData.Device.DefaultHeatingSetTemperature;
986
+ const defaultCoolingSetTemperature = deviceData.Device.DefaultCoolingSetTemperature;
982
987
  const actualFanSpeed = deviceData.Device.ActualFanSpeed;
983
988
  const automaticFanSpeed = deviceData.Device.AutomaticFanSpeed;
984
989
  const setFanSpeed = deviceData.Device[fanKey];
@@ -1108,8 +1113,8 @@ class DeviceAta extends EventEmitter {
1108
1113
  .updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature)
1109
1114
  .updateCharacteristic(Characteristic.LockPhysicalControls, obj.lockPhysicalControl)
1110
1115
  .updateCharacteristic(Characteristic.TemperatureDisplayUnits, obj.useFahrenheit)
1111
- .updateCharacteristic(Characteristic.CoolingThresholdTemperature, defaultCoolingSetTemperature);
1112
- if (supportsHeat) this.melCloudService?.updateCharacteristic(Characteristic.HeatingThresholdTemperature, defaultHeatingSetTemperature);
1116
+ .updateCharacteristic(Characteristic.CoolingThresholdTemperature, operationMode === 8 ? defaultCoolingSetTemperature : setTemperature);
1117
+ if (supportsHeat) this.melCloudService?.updateCharacteristic(Characteristic.HeatingThresholdTemperature, operationMode === 8 ? defaultHeatingSetTemperature : setTemperature);
1113
1118
  if (supportsFanSpeed) this.melCloudService?.updateCharacteristic(Characteristic.RotationSpeed, obj.currentFanSpeed);
1114
1119
  if (supportsSwingFunction) this.melCloudService?.updateCharacteristic(Characteristic.SwingMode, obj.currentSwingMode);
1115
1120
  break;