homebridge-melcloud-control 4.2.5-beta.0 → 4.2.5-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/README.md +3 -3
- package/config.schema.json +36 -18
- package/package.json +1 -1
- package/src/deviceata.js +272 -247
- package/src/deviceatw.js +200 -179
- package/src/deviceerv.js +143 -137
- package/src/melcloud.js +9 -15
- package/src/melcloudata.js +18 -27
- package/src/melcloudatw.js +10 -20
- package/src/melclouderv.js +10 -20
- package/src/melcloudhome.js +14 -22
package/src/deviceata.js
CHANGED
|
@@ -56,7 +56,7 @@ class DeviceAta extends EventEmitter {
|
|
|
56
56
|
this.restFulConnected = false;
|
|
57
57
|
this.mqtt = account.mqtt ?? {};
|
|
58
58
|
this.mqttConnected = false;
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
const serviceType = [null, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor];
|
|
61
61
|
const characteristicType = [null, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState];
|
|
62
62
|
|
|
@@ -88,8 +88,8 @@ class DeviceAta extends EventEmitter {
|
|
|
88
88
|
//buttons configured
|
|
89
89
|
for (const button of this.buttons) {
|
|
90
90
|
button.name = button.name || 'Button'
|
|
91
|
-
button.serviceType = [
|
|
92
|
-
button.characteristicType = [
|
|
91
|
+
button.serviceType = serviceType[button.displayType];
|
|
92
|
+
button.characteristicType = characteristicType[button.displayType];
|
|
93
93
|
button.state = false;
|
|
94
94
|
button.previousValue = null;
|
|
95
95
|
}
|
|
@@ -349,8 +349,9 @@ class DeviceAta extends EventEmitter {
|
|
|
349
349
|
.onSet(async (state) => {
|
|
350
350
|
try {
|
|
351
351
|
deviceData.Device.Power = state ? true : false;
|
|
352
|
-
|
|
352
|
+
|
|
353
353
|
if (this.logInfo) this.emit('info', `Set power: ${state ? 'On' : 'Off'}`);
|
|
354
|
+
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.Power);
|
|
354
355
|
} catch (error) {
|
|
355
356
|
if (this.logWarn) this.emit('warn', `Set power error: ${error}`);
|
|
356
357
|
};
|
|
@@ -387,8 +388,8 @@ class DeviceAta extends EventEmitter {
|
|
|
387
388
|
break;
|
|
388
389
|
};
|
|
389
390
|
|
|
390
|
-
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.OperationMode);
|
|
391
391
|
if (this.logInfo) this.emit('info', `Set operation mode: ${AirConditioner.OperationModeMapEnumToString[value]}`);
|
|
392
|
+
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.OperationMode);
|
|
392
393
|
} catch (error) {
|
|
393
394
|
if (this.logWarn) this.emit('warn', `Set operation mode error: ${error}`);
|
|
394
395
|
};
|
|
@@ -427,9 +428,9 @@ class DeviceAta extends EventEmitter {
|
|
|
427
428
|
break;
|
|
428
429
|
};
|
|
429
430
|
|
|
430
|
-
deviceData.Device[fanKey] = value
|
|
431
|
-
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.SetFanSpeed);
|
|
431
|
+
deviceData.Device[fanKey] = value;
|
|
432
432
|
if (this.logInfo) this.emit('info', `Set fan speed mode: ${AirConditioner.FanSpeedMapEnumToString[value]}`);
|
|
433
|
+
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.SetFanSpeed);
|
|
433
434
|
} catch (error) {
|
|
434
435
|
if (this.logWarn) this.emit('warn', `Set fan speed mode error: ${error}`);
|
|
435
436
|
};
|
|
@@ -446,8 +447,8 @@ class DeviceAta extends EventEmitter {
|
|
|
446
447
|
try {
|
|
447
448
|
deviceData.Device.VaneHorizontalDirection = value ? 12 : 0;
|
|
448
449
|
deviceData.Device.VaneVerticalDirection = value ? 7 : 0;
|
|
449
|
-
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.VaneVerticalVaneHorizontal);
|
|
450
450
|
if (this.logInfo) this.emit('info', `Set air direction mode: ${AirConditioner.AirDirectionMapEnumToString[value]}`);
|
|
451
|
+
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.VaneVerticalVaneHorizontal);
|
|
451
452
|
} catch (error) {
|
|
452
453
|
if (this.logWarn) this.emit('warn', `Set vane swing mode error: ${error}`);
|
|
453
454
|
};
|
|
@@ -467,8 +468,8 @@ class DeviceAta extends EventEmitter {
|
|
|
467
468
|
try {
|
|
468
469
|
const tempKey = this.accessory.operationMode === 8 ? 'DefaultCoolingSetTemperature' : 'SetTemperature';
|
|
469
470
|
deviceData.Device[tempKey] = value;
|
|
470
|
-
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.SetTemperature);
|
|
471
471
|
if (this.logInfo) this.emit('info', `Set cooling threshold temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
472
|
+
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.SetTemperature);
|
|
472
473
|
} catch (error) {
|
|
473
474
|
if (this.logWarn) this.emit('warn', `Set cooling threshold temperature error: ${error}`);
|
|
474
475
|
};
|
|
@@ -488,8 +489,8 @@ class DeviceAta extends EventEmitter {
|
|
|
488
489
|
try {
|
|
489
490
|
const tempKey = this.accessory.operationMode === 8 ? 'DefaultHeatingSetTemperature' : 'SetTemperature';
|
|
490
491
|
deviceData.Device[tempKey] = value;
|
|
491
|
-
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.SetTemperature);
|
|
492
492
|
if (this.logInfo) this.emit('info', `Set heating threshold temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
493
|
+
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.SetTemperature);
|
|
493
494
|
} catch (error) {
|
|
494
495
|
if (this.logWarn) this.emit('warn', `Set heating threshold temperature error: ${error}`);
|
|
495
496
|
};
|
|
@@ -508,8 +509,8 @@ class DeviceAta extends EventEmitter {
|
|
|
508
509
|
deviceData.Device.ProhibitSetTemperature = value;
|
|
509
510
|
deviceData.Device.ProhibitOperationMode = value;
|
|
510
511
|
deviceData.Device.ProhibitPower = value;
|
|
512
|
+
if (this.logInfo) this.emit('info', `Set local physical controls: ${value ? 'Lock' : 'Unlock'}`);
|
|
511
513
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.Prohibit);
|
|
512
|
-
if (this.logInfo) this.emit('info', `Set local physical controls: ${value ? 'LOCK' : 'UNLOCK'}`);
|
|
513
514
|
} catch (error) {
|
|
514
515
|
if (this.logWarn) this.emit('warn', `Set lock physical controls error: ${error}`);
|
|
515
516
|
};
|
|
@@ -525,8 +526,8 @@ class DeviceAta extends EventEmitter {
|
|
|
525
526
|
try {
|
|
526
527
|
value = [false, true][value];
|
|
527
528
|
this.accessory.useFahrenheit = value;
|
|
528
|
-
this.emit('melCloud', 'UseFahrenheit', value);
|
|
529
529
|
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
530
|
+
this.emit('melCloud', 'UseFahrenheit', value);
|
|
530
531
|
} catch (error) {
|
|
531
532
|
if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
532
533
|
};
|
|
@@ -579,9 +580,8 @@ class DeviceAta extends EventEmitter {
|
|
|
579
580
|
};
|
|
580
581
|
|
|
581
582
|
deviceData.Device.OperationMode = value;
|
|
583
|
+
if (this.logInfo) this.emit('info', `Set operation mode: ${AirConditioner.OperationModeMapEnumToString[value]}`);
|
|
582
584
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, flag);
|
|
583
|
-
const operationModeText = AirConditioner.OperationModeMapEnumToString[value];
|
|
584
|
-
if (this.logInfo) this.emit('info', `Set operation mode: ${operationModeText}`);
|
|
585
585
|
} catch (error) {
|
|
586
586
|
if (this.logWarn) this.emit('warn', `Set operation mode error: ${error}`);
|
|
587
587
|
};
|
|
@@ -604,8 +604,8 @@ class DeviceAta extends EventEmitter {
|
|
|
604
604
|
.onSet(async (value) => {
|
|
605
605
|
try {
|
|
606
606
|
deviceData.Device.SetTemperature = value;
|
|
607
|
-
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.SetTemperature);
|
|
608
607
|
if (this.logInfo) this.emit('info', `Set temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
608
|
+
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.SetTemperature);
|
|
609
609
|
} catch (error) {
|
|
610
610
|
if (this.logWarn) this.emit('warn', `Set temperature error: ${error}`);
|
|
611
611
|
};
|
|
@@ -619,10 +619,10 @@ class DeviceAta extends EventEmitter {
|
|
|
619
619
|
if (this.account.type === 'melcloudhome') return;
|
|
620
620
|
|
|
621
621
|
try {
|
|
622
|
-
value =
|
|
622
|
+
value = value ? true : false;
|
|
623
623
|
this.accessory.useFahrenheit = value;
|
|
624
|
-
this.emit('melCloud', 'UseFahrenheit', value);
|
|
625
624
|
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
625
|
+
this.emit('melCloud', 'UseFahrenheit', value);
|
|
626
626
|
} catch (error) {
|
|
627
627
|
if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
628
628
|
};
|
|
@@ -725,8 +725,8 @@ class DeviceAta extends EventEmitter {
|
|
|
725
725
|
.onSet(async (state) => {
|
|
726
726
|
try {
|
|
727
727
|
deviceData.FrostProtection.Enabled = state;
|
|
728
|
+
if (this.logInfo) this.emit('info', `Frost protection: ${state ? 'Enable' : 'Disable'}`);
|
|
728
729
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'frostprotection');
|
|
729
|
-
if (this.logInfo) this.emit('info', `Frost protection: ${state ? 'Enabled' : 'Disabled'}`);
|
|
730
730
|
} catch (error) {
|
|
731
731
|
if (this.logWarn) this.emit('warn', `Set frost protection error: ${error}`);
|
|
732
732
|
};
|
|
@@ -772,8 +772,8 @@ class DeviceAta extends EventEmitter {
|
|
|
772
772
|
.onSet(async (state) => {
|
|
773
773
|
try {
|
|
774
774
|
deviceData.OverheatProtection.Enabled = state;
|
|
775
|
+
if (this.logInfo) this.emit('info', `Overheat protection: ${state ? 'Enable' : 'Disable'}`);
|
|
775
776
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'overheatprotection');
|
|
776
|
-
if (this.logInfo) this.emit('info', `Overheat protection: ${state ? 'Enabled' : 'Disabled'}`);
|
|
777
777
|
} catch (error) {
|
|
778
778
|
if (this.logWarn) this.emit('warn', `Set overheat protection error: ${error}`);
|
|
779
779
|
};
|
|
@@ -818,8 +818,8 @@ class DeviceAta extends EventEmitter {
|
|
|
818
818
|
.onSet(async (state) => {
|
|
819
819
|
try {
|
|
820
820
|
deviceData.HolidayMode.Enabled = state;
|
|
821
|
+
if (this.logInfo) this.emit('info', `Holiday mode: ${state ? 'Enable' : 'Disable'}`);
|
|
821
822
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'holidaymode');
|
|
822
|
-
if (this.logInfo) this.emit('info', `Holiday mode: ${state ? 'Enabled' : 'Disabled'}`);
|
|
823
823
|
} catch (error) {
|
|
824
824
|
if (this.logWarn) this.emit('warn', `Set holiday mode error: ${error}`);
|
|
825
825
|
};
|
|
@@ -900,8 +900,8 @@ class DeviceAta extends EventEmitter {
|
|
|
900
900
|
break;
|
|
901
901
|
};
|
|
902
902
|
|
|
903
|
+
if (this.logInfo) this.emit('info', `Preset ${name}: ${state ? 'Set:' : 'Unset:'}`);
|
|
903
904
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.Presets);
|
|
904
|
-
if (this.logInfo) this.emit('info', `Preset ${name}: ${state ? 'Set:' : 'Unset:'} ${name}`);
|
|
905
905
|
} catch (error) {
|
|
906
906
|
if (this.logWarn) this.emit('warn', `Set preset error: ${error}`);
|
|
907
907
|
};
|
|
@@ -957,10 +957,10 @@ class DeviceAta extends EventEmitter {
|
|
|
957
957
|
.onSet(async (state) => {
|
|
958
958
|
try {
|
|
959
959
|
deviceData.ScheduleEnabled = state;
|
|
960
|
+
if (this.logInfo) this.emit('info', `Schedules: ${state ? 'Enable' : 'Disable'}`);
|
|
960
961
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'schedule');
|
|
961
|
-
if (this.logInfo) this.emit('info', `Schedule ${name}: ${state ? 'Enabled' : 'Disabled'}`);
|
|
962
962
|
} catch (error) {
|
|
963
|
-
if (this.logWarn) this.emit('warn', `Set
|
|
963
|
+
if (this.logWarn) this.emit('warn', `Set schedules error: ${error}`);
|
|
964
964
|
};
|
|
965
965
|
});
|
|
966
966
|
accessory.addService(this.scheduleControlService);
|
|
@@ -1026,8 +1026,8 @@ class DeviceAta extends EventEmitter {
|
|
|
1026
1026
|
.onSet(async (state) => {
|
|
1027
1027
|
try {
|
|
1028
1028
|
sceneData.Enabled = state;
|
|
1029
|
+
if (this.logInfo) this.emit('info', `Scene ${name}: ${state ? 'Enable' : 'Disable'}`);
|
|
1029
1030
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'scene', sceneData);
|
|
1030
|
-
if (this.logInfo) this.emit('info', `Scene ${name}: ${state ? 'Enabled' : 'Disabled'}`);
|
|
1031
1031
|
} catch (error) {
|
|
1032
1032
|
if (this.logWarn) this.emit('warn', `Set scene error: ${error}`);
|
|
1033
1033
|
};
|
|
@@ -1036,6 +1036,7 @@ class DeviceAta extends EventEmitter {
|
|
|
1036
1036
|
accessory.addService(sceneControlService);
|
|
1037
1037
|
}
|
|
1038
1038
|
|
|
1039
|
+
//sensor
|
|
1039
1040
|
if (this.logDebug) this.emit('debug', `Prepare scene control sensor ${name} service`);
|
|
1040
1041
|
const sceneControlSensorService = new serviceType(`${serviceName1} Control`, `sceneControlSensorService${deviceId} ${i}`);
|
|
1041
1042
|
sceneControlSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
@@ -1052,8 +1053,9 @@ class DeviceAta extends EventEmitter {
|
|
|
1052
1053
|
|
|
1053
1054
|
//buttons services
|
|
1054
1055
|
if (this.buttons.length > 0) {
|
|
1055
|
-
if (this.logDebug) this.emit('debug', `Prepare buttons/sensors services`);
|
|
1056
|
-
this.
|
|
1056
|
+
if (this.logDebug) this.emit('debug', `Prepare buttons / sensors services`);
|
|
1057
|
+
this.buttonControlServices = [];
|
|
1058
|
+
this.buttonControlSensorServices = [];
|
|
1057
1059
|
this.buttons.forEach((button, i) => {
|
|
1058
1060
|
//get button mode
|
|
1059
1061
|
const mode = button.mode;
|
|
@@ -1067,228 +1069,246 @@ class DeviceAta extends EventEmitter {
|
|
|
1067
1069
|
const serviceName = namePrefix ? `${accessoryName} ${name}` : name;
|
|
1068
1070
|
const serviceType = button.serviceType;
|
|
1069
1071
|
const characteristicType = button.characteristicType;
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1072
|
+
|
|
1073
|
+
//control
|
|
1074
|
+
if (button.displayType > 3) {
|
|
1075
|
+
if (this.logDebug) this.emit('debug', `Prepare button control ${name} service`);
|
|
1076
|
+
const buttonControlService = new serviceType(serviceName, `buttonControlService${deviceId} ${i}`);
|
|
1077
|
+
buttonControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
1078
|
+
buttonControlService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
1079
|
+
buttonControlService.getCharacteristic(Characteristic, On)
|
|
1080
|
+
.onGet(async () => {
|
|
1081
|
+
const state = button.state;
|
|
1082
|
+
return state;
|
|
1083
|
+
})
|
|
1084
|
+
.onSet(async (state) => {
|
|
1085
|
+
try {
|
|
1086
|
+
const fanKey = this.accountType === 'melcloud' ? 'FanSpeed' : 'SetFanSpeed';
|
|
1087
|
+
let flag = null;
|
|
1088
|
+
switch (mode) {
|
|
1089
|
+
case 0: //POWER ON,OFF
|
|
1090
|
+
deviceData.Device.Power = state;
|
|
1091
|
+
flag = AirConditioner.EffectiveFlags.Power;
|
|
1092
|
+
break;
|
|
1093
|
+
case 1: //OPERATING MODE HEAT
|
|
1094
|
+
button.previousValue = state ? deviceData.Device.OperationMode : button.previousValue ?? deviceData.Device.OperationMode;
|
|
1095
|
+
deviceData.Device.Power = true;
|
|
1096
|
+
deviceData.Device.OperationMode = state ? 1 : button.previousValue === 9 ? 1 : button.previousValue;
|
|
1097
|
+
flag = AirConditioner.EffectiveFlags.PowerOperationModeSetTemperature;
|
|
1098
|
+
break;
|
|
1099
|
+
case 2: //OPERATING MODE DRY
|
|
1100
|
+
button.previousValue = state ? deviceData.Device.OperationMode : button.previousValue ?? deviceData.Device.OperationMode;
|
|
1101
|
+
deviceData.Device.Power = true;
|
|
1102
|
+
deviceData.Device.OperationMode = state ? 2 : button.previousValue === 10 ? 2 : button.previousValue;
|
|
1103
|
+
flag = AirConditioner.EffectiveFlags.PowerOperationModeSetTemperature;
|
|
1104
|
+
break
|
|
1105
|
+
case 3: //OPERATING MODE COOL
|
|
1106
|
+
button.previousValue = state ? deviceData.Device.OperationMode : button.previousValue ?? deviceData.Device.OperationMode;
|
|
1107
|
+
deviceData.Device.Power = true;
|
|
1108
|
+
deviceData.Device.OperationMode = state ? 3 : button.previousValue === 11 ? 3 : button.previousValue;
|
|
1109
|
+
flag = AirConditioner.EffectiveFlags.PowerOperationModeSetTemperature;
|
|
1110
|
+
break;
|
|
1111
|
+
case 4: //OPERATING MODE FAN
|
|
1112
|
+
button.previousValue = state ? deviceData.Device.OperationMode : button.previousValue ?? deviceData.Device.OperationMode;
|
|
1113
|
+
deviceData.Device.Power = true;
|
|
1114
|
+
deviceData.Device.OperationMode = state ? 7 : button.previousValue;
|
|
1115
|
+
flag = AirConditioner.EffectiveFlags.PowerOperationModeSetTemperature;
|
|
1116
|
+
break;
|
|
1117
|
+
case 5: //OPERATING MODE AUTO
|
|
1118
|
+
button.previousValue = state ? deviceData.Device.OperationMode : button.previousValue ?? deviceData.Device.OperationMode;
|
|
1119
|
+
deviceData.Device.Power = true;
|
|
1120
|
+
deviceData.Device.OperationMode = state ? 8 : button.previousValue;
|
|
1121
|
+
flag = AirConditioner.EffectiveFlags.PowerOperationModeSetTemperature;
|
|
1122
|
+
break;
|
|
1123
|
+
case 6: //OPERATING MODE PURIFY
|
|
1124
|
+
button.previousValue = state ? deviceData.Device.OperationMode : button.previousValue ?? deviceData.Device.OperationMode;
|
|
1125
|
+
deviceData.Device.Power = true;
|
|
1126
|
+
deviceData.Device.OperationMode = state ? 12 : button.previousValue;
|
|
1127
|
+
flag = AirConditioner.EffectiveFlags.PowerOperationModeSetTemperature;
|
|
1128
|
+
break;
|
|
1129
|
+
case 7: //OPERATING MODE DRY CONTROL HIDE
|
|
1130
|
+
deviceData.HideDryModeControl = state;
|
|
1131
|
+
break;
|
|
1132
|
+
case 10: //VANE H SWING MODE AUTO
|
|
1133
|
+
button.previousValue = state ? deviceData.Device.VaneHorizontalDirection : button.previousValue ?? deviceData.Device.VaneHorizontalDirection;
|
|
1134
|
+
deviceData.Device.Power = true;
|
|
1135
|
+
deviceData.Device.VaneHorizontalDirection = state ? 0 : button.previousValue;
|
|
1136
|
+
flag = AirConditioner.EffectiveFlags.PowerVaneHorizontal;
|
|
1137
|
+
break;
|
|
1138
|
+
case 11: //VANE H SWING MODE 1
|
|
1139
|
+
button.previousValue = state ? deviceData.Device.VaneHorizontalDirection : button.previousValue ?? deviceData.Device.VaneHorizontalDirection;
|
|
1140
|
+
deviceData.Device.Power = true;
|
|
1141
|
+
deviceData.Device.VaneHorizontalDirection = state ? 1 : button.previousValue;
|
|
1142
|
+
flag = AirConditioner.EffectiveFlags.PowerVaneHorizontal;
|
|
1143
|
+
break;
|
|
1144
|
+
case 12: //VANE H SWING MODE 2
|
|
1145
|
+
button.previousValue = state ? deviceData.Device.VaneHorizontalDirection : button.previousValue ?? deviceData.Device.VaneHorizontalDirection;
|
|
1146
|
+
deviceData.Device.Power = true;
|
|
1147
|
+
deviceData.Device.VaneHorizontalDirection = state ? 2 : button.previousValue;
|
|
1148
|
+
flag = AirConditioner.EffectiveFlags.PowerVaneHorizontal;
|
|
1149
|
+
break;
|
|
1150
|
+
case 13: //VANE H SWING MODE 3
|
|
1151
|
+
button.previousValue = state ? deviceData.Device.VaneHorizontalDirection : button.previousValue ?? deviceData.Device.VaneHorizontalDirection;
|
|
1152
|
+
deviceData.Device.Power = true;
|
|
1153
|
+
deviceData.Device.VaneHorizontalDirection = state ? 3 : button.previousValue;
|
|
1154
|
+
flag = AirConditioner.EffectiveFlags.PowerVaneHorizontal;
|
|
1155
|
+
break;
|
|
1156
|
+
case 14: //VANE H SWING MODE 4
|
|
1157
|
+
button.previousValue = state ? deviceData.Device.VaneHorizontalDirection : button.previousValue ?? deviceData.Device.VaneHorizontalDirection;
|
|
1158
|
+
deviceData.Device.Power = true;
|
|
1159
|
+
deviceData.Device.VaneHorizontalDirection = state ? 4 : button.previousValue;
|
|
1160
|
+
flag = AirConditioner.EffectiveFlags.PowerVaneHorizontal;
|
|
1161
|
+
break;
|
|
1162
|
+
case 15: //VANE H SWING MODE 5
|
|
1163
|
+
button.previousValue = state ? deviceData.Device.VaneHorizontalDirection : button.previousValue ?? deviceData.Device.VaneHorizontalDirection;
|
|
1164
|
+
deviceData.Device.Power = true;
|
|
1165
|
+
deviceData.Device.VaneHorizontalDirection = state ? 5 : button.previousValue;
|
|
1166
|
+
flag = AirConditioner.EffectiveFlags.PowerVaneHorizontal;
|
|
1167
|
+
break;
|
|
1168
|
+
case 16: //VANE H SWING MODE SPLIT
|
|
1169
|
+
button.previousValue = state ? deviceData.Device.VaneHorizontalDirection : button.previousValue ?? deviceData.Device.VaneHorizontalDirection;
|
|
1170
|
+
deviceData.Device.Power = true;
|
|
1171
|
+
deviceData.Device.VaneHorizontalDirection = state ? 8 : button.previousValue;
|
|
1172
|
+
flag = AirConditioner.EffectiveFlags.PowerVaneHorizontal;
|
|
1173
|
+
break;
|
|
1174
|
+
case 17: //VANE H SWING MODE SWING
|
|
1175
|
+
button.previousValue = state ? deviceData.Device.VaneHorizontalDirection : button.previousValue ?? deviceData.Device.VaneHorizontalDirection;
|
|
1176
|
+
deviceData.Device.Power = true;
|
|
1177
|
+
deviceData.Device.VaneHorizontalDirection = state ? 12 : button.previousValue;
|
|
1178
|
+
flag = AirConditioner.EffectiveFlags.PowerVaneHorizontal;
|
|
1179
|
+
break;
|
|
1180
|
+
case 20: //VANE V SWING MODE AUTO
|
|
1181
|
+
button.previousValue = state ? deviceData.Device.VaneVerticalDirection : button.previousValue ?? deviceData.Device.VaneVerticalDirection;
|
|
1182
|
+
deviceData.Device.Power = true;
|
|
1183
|
+
deviceData.Device.VaneVerticalDirection = state ? 0 : button.previousValue;
|
|
1184
|
+
flag = AirConditioner.EffectiveFlags.PowerVaneVertical;
|
|
1185
|
+
break;
|
|
1186
|
+
case 21: //VANE V SWING MODE 1
|
|
1187
|
+
button.previousValue = state ? deviceData.Device.VaneVerticalDirection : button.previousValue ?? deviceData.Device.VaneVerticalDirection;
|
|
1188
|
+
deviceData.Device.Power = true;
|
|
1189
|
+
deviceData.Device.VaneVerticalDirection = state ? 1 : button.previousValue;
|
|
1190
|
+
flag = AirConditioner.EffectiveFlags.PowerVaneVertical;
|
|
1191
|
+
break;
|
|
1192
|
+
case 22: //VANE V SWING MODE 2
|
|
1193
|
+
button.previousValue = state ? deviceData.Device.VaneVerticalDirection : button.previousValue ?? deviceData.Device.VaneVerticalDirection;
|
|
1194
|
+
deviceData.Device.Power = true;
|
|
1195
|
+
deviceData.Device.VaneVerticalDirection = state ? 2 : button.previousValue;
|
|
1196
|
+
flag = AirConditioner.EffectiveFlags.PowerVaneVertical;
|
|
1197
|
+
break;
|
|
1198
|
+
case 23: //VANE V SWING MODE 3
|
|
1199
|
+
button.previousValue = state ? deviceData.Device.VaneVerticalDirection : button.previousValue ?? deviceData.Device.VaneVerticalDirection;
|
|
1200
|
+
deviceData.Device.Power = true;
|
|
1201
|
+
deviceData.Device.VaneVerticalDirection = state ? 3 : button.previousValue;
|
|
1202
|
+
flag = AirConditioner.EffectiveFlags.PowerVaneVertical;
|
|
1203
|
+
break;
|
|
1204
|
+
case 24: //VANE V SWING MODE 4
|
|
1205
|
+
button.previousValue = state ? deviceData.Device.VaneVerticalDirection : button.previousValue ?? deviceData.Device.VaneVerticalDirection;
|
|
1206
|
+
deviceData.Device.Power = true;
|
|
1207
|
+
deviceData.Device.VaneVerticalDirection = state ? 4 : button.previousValue;
|
|
1208
|
+
flag = AirConditioner.EffectiveFlags.PowerVaneVertical;
|
|
1209
|
+
break;
|
|
1210
|
+
case 25: //VANE V SWING MODE 5
|
|
1211
|
+
button.previousValue = state ? deviceData.Device.VaneVerticalDirection : button.previousValue ?? deviceData.Device.VaneVerticalDirection;
|
|
1212
|
+
deviceData.Device.Power = true;
|
|
1213
|
+
deviceData.Device.VaneVerticalDirection = state ? 5 : button.previousValue;
|
|
1214
|
+
flag = AirConditioner.EffectiveFlags.PowerVaneVertical;
|
|
1215
|
+
break;
|
|
1216
|
+
case 26: //VANE V SWING MODE SWING
|
|
1217
|
+
button.previousValue = state ? deviceData.Device.VaneVerticalDirection : button.previousValue ?? deviceData.Device.VaneVerticalDirection;
|
|
1218
|
+
deviceData.Device.Power = true;
|
|
1219
|
+
deviceData.Device.VaneVerticalDirection = state ? 7 : button.previousValue;
|
|
1220
|
+
flag = AirConditioner.EffectiveFlags.PowerVaneVertical;
|
|
1221
|
+
break;
|
|
1222
|
+
case 27: //VANE H/V CONTROLS HIDE
|
|
1223
|
+
deviceData.HideVaneControls = state;
|
|
1224
|
+
break;
|
|
1225
|
+
case 30: //FAN SPEED MODE AUTO
|
|
1226
|
+
button.previousValue = state ? deviceData.Device[fanKey] : button.previousValue ?? deviceData.Device[fanKey];
|
|
1227
|
+
deviceData.Device.Power = true;
|
|
1228
|
+
deviceData.Device[fanKey] = state ? 0 : button.previousValue;
|
|
1229
|
+
flag = AirConditioner.EffectiveFlags.PowerSetFanSpeed;
|
|
1230
|
+
break;
|
|
1231
|
+
case 31: //FAN SPEED MODE 1
|
|
1232
|
+
button.previousValue = state ? deviceData.Device[fanKey] : button.previousValue ?? deviceData.Device[fanKey];
|
|
1233
|
+
deviceData.Device.Power = true;
|
|
1234
|
+
deviceData.Device[fanKey] = state ? 1 : button.previousValue;
|
|
1235
|
+
flag = AirConditioner.EffectiveFlags.PowerSetFanSpeed;
|
|
1236
|
+
break;
|
|
1237
|
+
case 32: //FAN SPEED MODE 2
|
|
1238
|
+
button.previousValue = state ? deviceData.Device[fanKey] : button.previousValue ?? deviceData.Device[fanKey];
|
|
1239
|
+
deviceData.Device.Power = true;
|
|
1240
|
+
deviceData.Device[fanKey] = state ? 2 : button.previousValue;
|
|
1241
|
+
flag = AirConditioner.EffectiveFlags.PowerSetFanSpeed;
|
|
1242
|
+
break;
|
|
1243
|
+
case 33: //FAN SPEED MODE 3
|
|
1244
|
+
button.previousValue = state ? deviceData.Device[fanKey] : button.previousValue ?? deviceData.Device[fanKey];
|
|
1245
|
+
deviceData.Device.Power = true;
|
|
1246
|
+
deviceData.Device[fanKey] = state ? 3 : button.previousValue;
|
|
1247
|
+
flag = AirConditioner.EffectiveFlags.PowerSetFanSpeed;
|
|
1248
|
+
break;
|
|
1249
|
+
case 34: //FAN MODE 4
|
|
1250
|
+
button.previousValue = state ? deviceData.Device[fanKey] : button.previousValue ?? deviceData.Device[fanKey];
|
|
1251
|
+
deviceData.Device.Power = true;
|
|
1252
|
+
deviceData.Device[fanKey] = state ? 4 : button.previousValue;
|
|
1253
|
+
flag = AirConditioner.EffectiveFlags.PowerSetFanSpeed;
|
|
1254
|
+
break;
|
|
1255
|
+
case 35: //FAN SPEED MODE 5
|
|
1256
|
+
button.previousValue = state ? deviceData.Device[fanKey] : button.previousValue ?? deviceData.Device[fanKey];
|
|
1257
|
+
deviceData.Device.Power = true;
|
|
1258
|
+
deviceData.Device[fanKey] = state ? 5 : button.previousValue;
|
|
1259
|
+
flag = AirConditioner.EffectiveFlags.PowerSetFanSpeed;
|
|
1260
|
+
break;
|
|
1261
|
+
case 36: //FAN SPEED MODE 6
|
|
1262
|
+
button.previousValue = state ? deviceData.Device[fanKey] : button.previousValue ?? deviceData.Device[fanKey];
|
|
1263
|
+
deviceData.Device.Power = true;
|
|
1264
|
+
deviceData.Device[fanKey] = state ? 6 : button.previousValue;
|
|
1265
|
+
flag = AirConditioner.EffectiveFlags.PowerSetFanSpeed;
|
|
1266
|
+
break;
|
|
1267
|
+
case 37: //PHYSICAL LOCK CONTROLS
|
|
1268
|
+
deviceData.Device.ProhibitSetTemperature = state;
|
|
1269
|
+
deviceData.Device.ProhibitOperationMode = state;
|
|
1270
|
+
deviceData.Device.ProhibitPower = state;
|
|
1271
|
+
flag = AirConditioner.EffectiveFlags.Prohibit;
|
|
1272
|
+
break;
|
|
1273
|
+
case 38: //PHYSICAL LOCK CONTROLS POWER
|
|
1274
|
+
deviceData.Device.ProhibitPower = state;
|
|
1275
|
+
flag = AirConditioner.EffectiveFlags.Prohibit;
|
|
1276
|
+
break;
|
|
1277
|
+
case 39: //PHYSICAL LOCK CONTROLS MODE
|
|
1278
|
+
deviceData.Device.ProhibitOperationMode = state;
|
|
1279
|
+
flag = AirConditioner.EffectiveFlags.Prohibit;
|
|
1280
|
+
break;
|
|
1281
|
+
case 40: //PHYSICAL LOCK CONTROLS TEMP
|
|
1282
|
+
deviceData.Device.ProhibitSetTemperature = state;
|
|
1283
|
+
flag = AirConditioner.EffectiveFlags.Prohibit;
|
|
1284
|
+
break;
|
|
1285
|
+
default:
|
|
1286
|
+
if (this.logWarn) this.emit('warn', `Unknown button mode: ${mode}`);
|
|
1287
|
+
break;
|
|
1288
|
+
};
|
|
1289
|
+
|
|
1290
|
+
if (this.logInfo) this.emit('info', `${state ? `Set: ${name}` : `Unset: ${name}, Set: ${button.previousValue}`}`);
|
|
1291
|
+
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, flag);
|
|
1292
|
+
} catch (error) {
|
|
1293
|
+
if (this.logWarn) this.emit('warn', `Set button error: ${error}`);
|
|
1294
|
+
};
|
|
1295
|
+
});
|
|
1296
|
+
this.buttonControlServices.push(buttonControlService);
|
|
1297
|
+
accessory.addService(buttonControlService);
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
//sensor
|
|
1301
|
+
if (this.logDebug) this.emit('debug', `Prepare scene control sensor ${name} service`);
|
|
1302
|
+
const buttonControlSensorService = new serviceType(serviceName, `buttonControlSensorService${deviceId} ${i}`);
|
|
1303
|
+
buttonControlSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
1304
|
+
buttonControlSensorService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
1305
|
+
buttonControlSensorService.getCharacteristic(characteristicType)
|
|
1074
1306
|
.onGet(async () => {
|
|
1075
1307
|
const state = button.state;
|
|
1076
1308
|
return state;
|
|
1077
1309
|
})
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
const fanKey = this.accountType === 'melcloud' ? 'FanSpeed' : 'SetFanSpeed';
|
|
1081
|
-
let flag = null;
|
|
1082
|
-
switch (mode) {
|
|
1083
|
-
case 0: //POWER ON,OFF
|
|
1084
|
-
deviceData.Device.Power = state;
|
|
1085
|
-
flag = AirConditioner.EffectiveFlags.Power;
|
|
1086
|
-
break;
|
|
1087
|
-
case 1: //OPERATING MODE HEAT
|
|
1088
|
-
button.previousValue = state ? deviceData.Device.OperationMode : button.previousValue ?? deviceData.Device.OperationMode;
|
|
1089
|
-
deviceData.Device.Power = true;
|
|
1090
|
-
deviceData.Device.OperationMode = state ? 1 : button.previousValue === 9 ? 1 : button.previousValue;
|
|
1091
|
-
flag = AirConditioner.EffectiveFlags.PowerOperationModeSetTemperature;
|
|
1092
|
-
break;
|
|
1093
|
-
case 2: //OPERATING MODE DRY
|
|
1094
|
-
button.previousValue = state ? deviceData.Device.OperationMode : button.previousValue ?? deviceData.Device.OperationMode;
|
|
1095
|
-
deviceData.Device.Power = true;
|
|
1096
|
-
deviceData.Device.OperationMode = state ? 2 : button.previousValue === 10 ? 2 : button.previousValue;
|
|
1097
|
-
flag = AirConditioner.EffectiveFlags.PowerOperationModeSetTemperature;
|
|
1098
|
-
break
|
|
1099
|
-
case 3: //OPERATING MODE COOL
|
|
1100
|
-
button.previousValue = state ? deviceData.Device.OperationMode : button.previousValue ?? deviceData.Device.OperationMode;
|
|
1101
|
-
deviceData.Device.Power = true;
|
|
1102
|
-
deviceData.Device.OperationMode = state ? 3 : button.previousValue === 11 ? 3 : button.previousValue;
|
|
1103
|
-
flag = AirConditioner.EffectiveFlags.PowerOperationModeSetTemperature;
|
|
1104
|
-
break;
|
|
1105
|
-
case 4: //OPERATING MODE FAN
|
|
1106
|
-
button.previousValue = state ? deviceData.Device.OperationMode : button.previousValue ?? deviceData.Device.OperationMode;
|
|
1107
|
-
deviceData.Device.Power = true;
|
|
1108
|
-
deviceData.Device.OperationMode = state ? 7 : button.previousValue;
|
|
1109
|
-
flag = AirConditioner.EffectiveFlags.PowerOperationModeSetTemperature;
|
|
1110
|
-
break;
|
|
1111
|
-
case 5: //OPERATING MODE AUTO
|
|
1112
|
-
button.previousValue = state ? deviceData.Device.OperationMode : button.previousValue ?? deviceData.Device.OperationMode;
|
|
1113
|
-
deviceData.Device.Power = true;
|
|
1114
|
-
deviceData.Device.OperationMode = state ? 8 : button.previousValue;
|
|
1115
|
-
flag = AirConditioner.EffectiveFlags.PowerOperationModeSetTemperature;
|
|
1116
|
-
break;
|
|
1117
|
-
case 6: //OPERATING MODE PURIFY
|
|
1118
|
-
button.previousValue = state ? deviceData.Device.OperationMode : button.previousValue ?? deviceData.Device.OperationMode;
|
|
1119
|
-
deviceData.Device.Power = true;
|
|
1120
|
-
deviceData.Device.OperationMode = state ? 12 : button.previousValue;
|
|
1121
|
-
flag = AirConditioner.EffectiveFlags.PowerOperationModeSetTemperature;
|
|
1122
|
-
break;
|
|
1123
|
-
case 7: //OPERATING MODE DRY CONTROL HIDE
|
|
1124
|
-
deviceData.HideDryModeControl = state;
|
|
1125
|
-
break;
|
|
1126
|
-
case 10: //VANE H SWING MODE AUTO
|
|
1127
|
-
button.previousValue = state ? deviceData.Device.VaneHorizontalDirection : button.previousValue ?? deviceData.Device.VaneHorizontalDirection;
|
|
1128
|
-
deviceData.Device.Power = true;
|
|
1129
|
-
deviceData.Device.VaneHorizontalDirection = state ? 0 : button.previousValue;
|
|
1130
|
-
flag = AirConditioner.EffectiveFlags.PowerVaneHorizontal;
|
|
1131
|
-
break;
|
|
1132
|
-
case 11: //VANE H SWING MODE 1
|
|
1133
|
-
button.previousValue = state ? deviceData.Device.VaneHorizontalDirection : button.previousValue ?? deviceData.Device.VaneHorizontalDirection;
|
|
1134
|
-
deviceData.Device.Power = true;
|
|
1135
|
-
deviceData.Device.VaneHorizontalDirection = state ? 1 : button.previousValue;
|
|
1136
|
-
flag = AirConditioner.EffectiveFlags.PowerVaneHorizontal;
|
|
1137
|
-
break;
|
|
1138
|
-
case 12: //VANE H SWING MODE 2
|
|
1139
|
-
button.previousValue = state ? deviceData.Device.VaneHorizontalDirection : button.previousValue ?? deviceData.Device.VaneHorizontalDirection;
|
|
1140
|
-
deviceData.Device.Power = true;
|
|
1141
|
-
deviceData.Device.VaneHorizontalDirection = state ? 2 : button.previousValue;
|
|
1142
|
-
flag = AirConditioner.EffectiveFlags.PowerVaneHorizontal;
|
|
1143
|
-
break;
|
|
1144
|
-
case 13: //VANE H SWING MODE 3
|
|
1145
|
-
button.previousValue = state ? deviceData.Device.VaneHorizontalDirection : button.previousValue ?? deviceData.Device.VaneHorizontalDirection;
|
|
1146
|
-
deviceData.Device.Power = true;
|
|
1147
|
-
deviceData.Device.VaneHorizontalDirection = state ? 3 : button.previousValue;
|
|
1148
|
-
flag = AirConditioner.EffectiveFlags.PowerVaneHorizontal;
|
|
1149
|
-
break;
|
|
1150
|
-
case 14: //VANE H SWING MODE 4
|
|
1151
|
-
button.previousValue = state ? deviceData.Device.VaneHorizontalDirection : button.previousValue ?? deviceData.Device.VaneHorizontalDirection;
|
|
1152
|
-
deviceData.Device.Power = true;
|
|
1153
|
-
deviceData.Device.VaneHorizontalDirection = state ? 4 : button.previousValue;
|
|
1154
|
-
flag = AirConditioner.EffectiveFlags.PowerVaneHorizontal;
|
|
1155
|
-
break;
|
|
1156
|
-
case 15: //VANE H SWING MODE 5
|
|
1157
|
-
button.previousValue = state ? deviceData.Device.VaneHorizontalDirection : button.previousValue ?? deviceData.Device.VaneHorizontalDirection;
|
|
1158
|
-
deviceData.Device.Power = true;
|
|
1159
|
-
deviceData.Device.VaneHorizontalDirection = state ? 5 : button.previousValue;
|
|
1160
|
-
flag = AirConditioner.EffectiveFlags.PowerVaneHorizontal;
|
|
1161
|
-
break;
|
|
1162
|
-
case 16: //VANE H SWING MODE SPLIT
|
|
1163
|
-
button.previousValue = state ? deviceData.Device.VaneHorizontalDirection : button.previousValue ?? deviceData.Device.VaneHorizontalDirection;
|
|
1164
|
-
deviceData.Device.Power = true;
|
|
1165
|
-
deviceData.Device.VaneHorizontalDirection = state ? 8 : button.previousValue;
|
|
1166
|
-
flag = AirConditioner.EffectiveFlags.PowerVaneHorizontal;
|
|
1167
|
-
break;
|
|
1168
|
-
case 17: //VANE H SWING MODE SWING
|
|
1169
|
-
button.previousValue = state ? deviceData.Device.VaneHorizontalDirection : button.previousValue ?? deviceData.Device.VaneHorizontalDirection;
|
|
1170
|
-
deviceData.Device.Power = true;
|
|
1171
|
-
deviceData.Device.VaneHorizontalDirection = state ? 12 : button.previousValue;
|
|
1172
|
-
flag = AirConditioner.EffectiveFlags.PowerVaneHorizontal;
|
|
1173
|
-
break;
|
|
1174
|
-
case 20: //VANE V SWING MODE AUTO
|
|
1175
|
-
button.previousValue = state ? deviceData.Device.VaneVerticalDirection : button.previousValue ?? deviceData.Device.VaneVerticalDirection;
|
|
1176
|
-
deviceData.Device.Power = true;
|
|
1177
|
-
deviceData.Device.VaneVerticalDirection = state ? 0 : button.previousValue;
|
|
1178
|
-
flag = AirConditioner.EffectiveFlags.PowerVaneVertical;
|
|
1179
|
-
break;
|
|
1180
|
-
case 21: //VANE V SWING MODE 1
|
|
1181
|
-
button.previousValue = state ? deviceData.Device.VaneVerticalDirection : button.previousValue ?? deviceData.Device.VaneVerticalDirection;
|
|
1182
|
-
deviceData.Device.Power = true;
|
|
1183
|
-
deviceData.Device.VaneVerticalDirection = state ? 1 : button.previousValue;
|
|
1184
|
-
flag = AirConditioner.EffectiveFlags.PowerVaneVertical;
|
|
1185
|
-
break;
|
|
1186
|
-
case 22: //VANE V SWING MODE 2
|
|
1187
|
-
button.previousValue = state ? deviceData.Device.VaneVerticalDirection : button.previousValue ?? deviceData.Device.VaneVerticalDirection;
|
|
1188
|
-
deviceData.Device.Power = true;
|
|
1189
|
-
deviceData.Device.VaneVerticalDirection = state ? 2 : button.previousValue;
|
|
1190
|
-
flag = AirConditioner.EffectiveFlags.PowerVaneVertical;
|
|
1191
|
-
break;
|
|
1192
|
-
case 23: //VANE V SWING MODE 3
|
|
1193
|
-
button.previousValue = state ? deviceData.Device.VaneVerticalDirection : button.previousValue ?? deviceData.Device.VaneVerticalDirection;
|
|
1194
|
-
deviceData.Device.Power = true;
|
|
1195
|
-
deviceData.Device.VaneVerticalDirection = state ? 3 : button.previousValue;
|
|
1196
|
-
flag = AirConditioner.EffectiveFlags.PowerVaneVertical;
|
|
1197
|
-
break;
|
|
1198
|
-
case 24: //VANE V SWING MODE 4
|
|
1199
|
-
button.previousValue = state ? deviceData.Device.VaneVerticalDirection : button.previousValue ?? deviceData.Device.VaneVerticalDirection;
|
|
1200
|
-
deviceData.Device.Power = true;
|
|
1201
|
-
deviceData.Device.VaneVerticalDirection = state ? 4 : button.previousValue;
|
|
1202
|
-
flag = AirConditioner.EffectiveFlags.PowerVaneVertical;
|
|
1203
|
-
break;
|
|
1204
|
-
case 25: //VANE V SWING MODE 5
|
|
1205
|
-
button.previousValue = state ? deviceData.Device.VaneVerticalDirection : button.previousValue ?? deviceData.Device.VaneVerticalDirection;
|
|
1206
|
-
deviceData.Device.Power = true;
|
|
1207
|
-
deviceData.Device.VaneVerticalDirection = state ? 5 : button.previousValue;
|
|
1208
|
-
flag = AirConditioner.EffectiveFlags.PowerVaneVertical;
|
|
1209
|
-
break;
|
|
1210
|
-
case 26: //VANE V SWING MODE SWING
|
|
1211
|
-
button.previousValue = state ? deviceData.Device.VaneVerticalDirection : button.previousValue ?? deviceData.Device.VaneVerticalDirection;
|
|
1212
|
-
deviceData.Device.Power = true;
|
|
1213
|
-
deviceData.Device.VaneVerticalDirection = state ? 7 : button.previousValue;
|
|
1214
|
-
flag = AirConditioner.EffectiveFlags.PowerVaneVertical;
|
|
1215
|
-
break;
|
|
1216
|
-
case 27: //VANE H/V CONTROLS HIDE
|
|
1217
|
-
deviceData.HideVaneControls = state;
|
|
1218
|
-
break;
|
|
1219
|
-
case 30: //FAN SPEED MODE AUTO
|
|
1220
|
-
button.previousValue = state ? deviceData.Device[fanKey] : button.previousValue ?? deviceData.Device[fanKey];
|
|
1221
|
-
deviceData.Device.Power = true;
|
|
1222
|
-
deviceData.Device[fanKey] = state ? 0 : button.previousValue;
|
|
1223
|
-
flag = AirConditioner.EffectiveFlags.PowerSetFanSpeed;
|
|
1224
|
-
break;
|
|
1225
|
-
case 31: //FAN SPEED MODE 1
|
|
1226
|
-
button.previousValue = state ? deviceData.Device[fanKey] : button.previousValue ?? deviceData.Device[fanKey];
|
|
1227
|
-
deviceData.Device.Power = true;
|
|
1228
|
-
deviceData.Device[fanKey] = state ? 1 : button.previousValue;
|
|
1229
|
-
flag = AirConditioner.EffectiveFlags.PowerSetFanSpeed;
|
|
1230
|
-
break;
|
|
1231
|
-
case 32: //FAN SPEED MODE 2
|
|
1232
|
-
button.previousValue = state ? deviceData.Device[fanKey] : button.previousValue ?? deviceData.Device[fanKey];
|
|
1233
|
-
deviceData.Device.Power = true;
|
|
1234
|
-
deviceData.Device[fanKey] = state ? 2 : button.previousValue;
|
|
1235
|
-
flag = AirConditioner.EffectiveFlags.PowerSetFanSpeed;
|
|
1236
|
-
break;
|
|
1237
|
-
case 33: //FAN SPEED MODE 3
|
|
1238
|
-
button.previousValue = state ? deviceData.Device[fanKey] : button.previousValue ?? deviceData.Device[fanKey];
|
|
1239
|
-
deviceData.Device.Power = true;
|
|
1240
|
-
deviceData.Device[fanKey] = state ? 3 : button.previousValue;
|
|
1241
|
-
flag = AirConditioner.EffectiveFlags.PowerSetFanSpeed;
|
|
1242
|
-
break;
|
|
1243
|
-
case 34: //FAN MODE 4
|
|
1244
|
-
button.previousValue = state ? deviceData.Device[fanKey] : button.previousValue ?? deviceData.Device[fanKey];
|
|
1245
|
-
deviceData.Device.Power = true;
|
|
1246
|
-
deviceData.Device[fanKey] = state ? 4 : button.previousValue;
|
|
1247
|
-
flag = AirConditioner.EffectiveFlags.PowerSetFanSpeed;
|
|
1248
|
-
break;
|
|
1249
|
-
case 35: //FAN SPEED MODE 5
|
|
1250
|
-
button.previousValue = state ? deviceData.Device[fanKey] : button.previousValue ?? deviceData.Device[fanKey];
|
|
1251
|
-
deviceData.Device.Power = true;
|
|
1252
|
-
deviceData.Device[fanKey] = state ? 5 : button.previousValue;
|
|
1253
|
-
flag = AirConditioner.EffectiveFlags.PowerSetFanSpeed;
|
|
1254
|
-
break;
|
|
1255
|
-
case 36: //FAN SPEED MODE 6
|
|
1256
|
-
button.previousValue = state ? deviceData.Device[fanKey] : button.previousValue ?? deviceData.Device[fanKey];
|
|
1257
|
-
deviceData.Device.Power = true;
|
|
1258
|
-
deviceData.Device[fanKey] = state ? 6 : button.previousValue;
|
|
1259
|
-
flag = AirConditioner.EffectiveFlags.PowerSetFanSpeed;
|
|
1260
|
-
break;
|
|
1261
|
-
case 37: //PHYSICAL LOCK CONTROLS
|
|
1262
|
-
deviceData.Device.ProhibitSetTemperature = state;
|
|
1263
|
-
deviceData.Device.ProhibitOperationMode = state;
|
|
1264
|
-
deviceData.Device.ProhibitPower = state;
|
|
1265
|
-
flag = AirConditioner.EffectiveFlags.Prohibit;
|
|
1266
|
-
break;
|
|
1267
|
-
case 38: //PHYSICAL LOCK CONTROLS POWER
|
|
1268
|
-
deviceData.Device.ProhibitPower = state;
|
|
1269
|
-
flag = AirConditioner.EffectiveFlags.Prohibit;
|
|
1270
|
-
break;
|
|
1271
|
-
case 39: //PHYSICAL LOCK CONTROLS MODE
|
|
1272
|
-
deviceData.Device.ProhibitOperationMode = state;
|
|
1273
|
-
flag = AirConditioner.EffectiveFlags.Prohibit;
|
|
1274
|
-
break;
|
|
1275
|
-
case 40: //PHYSICAL LOCK CONTROLS TEMP
|
|
1276
|
-
deviceData.Device.ProhibitSetTemperature = state;
|
|
1277
|
-
flag = AirConditioner.EffectiveFlags.Prohibit;
|
|
1278
|
-
break;
|
|
1279
|
-
default:
|
|
1280
|
-
if (this.logWarn) this.emit('warn', `Unknown button mode: ${mode}`);
|
|
1281
|
-
break;
|
|
1282
|
-
};
|
|
1283
|
-
|
|
1284
|
-
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, flag);
|
|
1285
|
-
if (this.logInfo) this.emit('info', `${state ? `Set: ${name}` : `Unset: ${name}, Set: ${button.previousValue}`}`);
|
|
1286
|
-
} catch (error) {
|
|
1287
|
-
if (this.logWarn) this.emit('warn', `Set button error: ${error}`);
|
|
1288
|
-
};
|
|
1289
|
-
});
|
|
1290
|
-
this.buttonsServices.push(buttonService);
|
|
1291
|
-
accessory.addService(buttonService);
|
|
1310
|
+
this.buttonControlSensorServices.push(buttonControlSensorService);
|
|
1311
|
+
accessory.addService(buttonControlSensorService);
|
|
1292
1312
|
});
|
|
1293
1313
|
};
|
|
1294
1314
|
|
|
@@ -1804,9 +1824,14 @@ class DeviceAta extends EventEmitter {
|
|
|
1804
1824
|
break;
|
|
1805
1825
|
};
|
|
1806
1826
|
|
|
1807
|
-
//
|
|
1808
|
-
|
|
1809
|
-
|
|
1827
|
+
//control
|
|
1828
|
+
if (button.displayType > 3) {
|
|
1829
|
+
this.buttonControlServices?.[i]?.updateCharacteristic(Characteristic.On, button.state);
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
//sensor
|
|
1833
|
+
const characteristicType = scene.characteristicType;
|
|
1834
|
+
this.buttonControlSensorServices?.[i]?.updateCharacteristic(characteristicType, button.state);
|
|
1810
1835
|
});
|
|
1811
1836
|
};
|
|
1812
1837
|
|