homebridge-melcloud-control 4.2.5-beta.2 → 4.2.5-beta.21
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/index.js +1 -1
- package/package.json +1 -1
- package/src/constants.js +1 -0
- package/src/deviceata.js +256 -231
- package/src/deviceatw.js +185 -164
- package/src/deviceerv.js +128 -104
- package/src/melcloud.js +10 -17
- package/src/melcloudata.js +19 -27
- package/src/melcloudatw.js +10 -20
- package/src/melclouderv.js +10 -20
- package/src/melcloudhome.js +18 -40
package/src/deviceata.js
CHANGED
|
@@ -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
|
}
|
|
@@ -725,7 +725,7 @@ 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 ? '
|
|
728
|
+
if (this.logInfo) this.emit('info', `Frost protection: ${state ? 'Enabled' : 'Disabled'}`);
|
|
729
729
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'frostprotection');
|
|
730
730
|
} catch (error) {
|
|
731
731
|
if (this.logWarn) this.emit('warn', `Set frost protection error: ${error}`);
|
|
@@ -772,7 +772,7 @@ 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 ? '
|
|
775
|
+
if (this.logInfo) this.emit('info', `Overheat protection: ${state ? 'Enabled' : 'Disabled'}`);
|
|
776
776
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'overheatprotection');
|
|
777
777
|
} catch (error) {
|
|
778
778
|
if (this.logWarn) this.emit('warn', `Set overheat protection error: ${error}`);
|
|
@@ -818,7 +818,7 @@ 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 ? '
|
|
821
|
+
if (this.logInfo) this.emit('info', `Holiday mode: ${state ? 'Enabled' : 'Disabled'}`);
|
|
822
822
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'holidaymode');
|
|
823
823
|
} catch (error) {
|
|
824
824
|
if (this.logWarn) this.emit('warn', `Set holiday mode error: ${error}`);
|
|
@@ -900,7 +900,7 @@ class DeviceAta extends EventEmitter {
|
|
|
900
900
|
break;
|
|
901
901
|
};
|
|
902
902
|
|
|
903
|
-
if (this.logInfo) this.emit('info', `Preset ${name}: ${state ? 'Set
|
|
903
|
+
if (this.logInfo) this.emit('info', `Preset: ${name}: ${state ? 'Set' : 'Unset'}`);
|
|
904
904
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.Presets);
|
|
905
905
|
} catch (error) {
|
|
906
906
|
if (this.logWarn) this.emit('warn', `Set preset error: ${error}`);
|
|
@@ -957,7 +957,7 @@ 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 ? '
|
|
960
|
+
if (this.logInfo) this.emit('info', `Schedules: ${state ? 'Enabled' : 'Disabled'}`);
|
|
961
961
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'schedule');
|
|
962
962
|
} catch (error) {
|
|
963
963
|
if (this.logWarn) this.emit('warn', `Set schedules error: ${error}`);
|
|
@@ -1026,7 +1026,7 @@ 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 ? '
|
|
1029
|
+
if (this.logInfo) this.emit('info', `Scene ${name}: ${state ? 'Set' : 'Unset'}`);
|
|
1030
1030
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'scene', sceneData);
|
|
1031
1031
|
} catch (error) {
|
|
1032
1032
|
if (this.logWarn) this.emit('warn', `Set scene error: ${error}`);
|
|
@@ -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', `Button ${name}: ${state ? `Enabled` : `Disabled`}`);
|
|
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
|
-
if (this.logInfo) this.emit('info', `${state ? `Set: ${name}` : `Unset: ${name}, Set: ${button.previousValue}`}`);
|
|
1285
|
-
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, flag);
|
|
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
|
|