homebridge-melcloud-control 4.2.5-beta.2 → 4.2.5-beta.4
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/config.schema.json +36 -18
- package/package.json +1 -1
- package/src/deviceata.js +250 -225
- package/src/deviceatw.js +181 -160
- package/src/deviceerv.js +124 -100
package/src/deviceerv.js
CHANGED
|
@@ -82,8 +82,8 @@ class DeviceErv extends EventEmitter {
|
|
|
82
82
|
//buttons configured
|
|
83
83
|
for (const button of this.buttons) {
|
|
84
84
|
button.name = button.name || 'Button'
|
|
85
|
-
button.serviceType = [
|
|
86
|
-
button.characteristicType = [
|
|
85
|
+
button.serviceType = serviceType[button.displayType];
|
|
86
|
+
button.characteristicType = characteristicType[button.displayType];
|
|
87
87
|
button.state = false;
|
|
88
88
|
button.previousValue = null;
|
|
89
89
|
}
|
|
@@ -975,116 +975,135 @@ class DeviceErv extends EventEmitter {
|
|
|
975
975
|
|
|
976
976
|
//buttons services
|
|
977
977
|
if (this.buttons.length > 0) {
|
|
978
|
-
if (this.logDebug) this.emit('debug', `Prepare buttons services`);
|
|
979
|
-
this.
|
|
978
|
+
if (this.logDebug) this.emit('debug', `Prepare buttons / sensors services`);
|
|
979
|
+
this.buttonControlServices = [];
|
|
980
|
+
this.buttonControlSensorServices = [];
|
|
980
981
|
this.buttons.forEach((button, i) => {
|
|
981
982
|
//get button mode
|
|
982
983
|
const mode = button.mode;
|
|
983
984
|
|
|
984
985
|
//get button name
|
|
985
|
-
const
|
|
986
|
+
const name = button.name;
|
|
986
987
|
|
|
987
988
|
//get button name prefix
|
|
988
989
|
const namePrefix = button.namePrefix;
|
|
989
990
|
|
|
990
|
-
const serviceName1 = namePrefix ? `${accessoryName} ${
|
|
991
|
+
const serviceName1 = namePrefix ? `${accessoryName} ${name}` : name;
|
|
991
992
|
const serviceType = button.serviceType;
|
|
992
993
|
const characteristicType = button.characteristicType;
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
994
|
+
|
|
995
|
+
//control
|
|
996
|
+
if (button.displayType > 3) {
|
|
997
|
+
if (this.logDebug) this.emit('debug', `Prepare button control ${name} service`);
|
|
998
|
+
const buttonControlService = new serviceType(serviceName1, `buttonControlService${deviceId} ${i}`);
|
|
999
|
+
buttonControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
1000
|
+
buttonControlService.setCharacteristic(Characteristic.ConfiguredName, serviceName1);
|
|
1001
|
+
buttonControlService.getCharacteristic(Characteristic.On)
|
|
1002
|
+
.onGet(async () => {
|
|
1003
|
+
const state = button.state;
|
|
1004
|
+
return state;
|
|
1005
|
+
})
|
|
1006
|
+
.onSet(async (state) => {
|
|
1007
|
+
try {
|
|
1008
|
+
let flag = null;
|
|
1009
|
+
switch (mode) {
|
|
1010
|
+
case 0: //POWER ON,OFF
|
|
1011
|
+
deviceData.Device.Power = state;
|
|
1012
|
+
flag = Ventilation.EffectiveFlags.Power;
|
|
1013
|
+
break;
|
|
1014
|
+
case 1: //OPERATING MODE RECOVERY
|
|
1015
|
+
button.previousValue = state ? deviceData.Device.VentilationMode : button.previousValue ?? deviceData.Device.VentilationMode;
|
|
1016
|
+
deviceData.Device.Power = true;
|
|
1017
|
+
deviceData.Device.VentilationMode = state ? 0 : button.previousValue;
|
|
1018
|
+
flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
|
|
1019
|
+
break;
|
|
1020
|
+
case 2: //OPERATING MODE BYPASS
|
|
1021
|
+
button.previousValue = state ? deviceData.Device.VentilationMode : button.previousValue ?? deviceData.Device.VentilationMode;
|
|
1022
|
+
deviceData.Device.Power = true;
|
|
1023
|
+
deviceData.Device.VentilationMode = state ? 1 : button.previousValue;
|
|
1024
|
+
flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
|
|
1025
|
+
break
|
|
1026
|
+
case 3: //OPERATING MODE AUTO
|
|
1027
|
+
button.previousValue = state ? deviceData.Device.VentilationMode : button.previousValue ?? deviceData.Device.VentilationMode;
|
|
1028
|
+
deviceData.Device.Power = true;
|
|
1029
|
+
deviceData.Device.VentilationMode = state ? 2 : button.previousValue;
|
|
1030
|
+
flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
|
|
1031
|
+
break;
|
|
1032
|
+
case 4: //NIGHT PURGE MODE
|
|
1033
|
+
deviceData.Device.Power = true;
|
|
1034
|
+
deviceData.Device.NightPurgeMode = state;
|
|
1035
|
+
flag = Ventilation.EffectiveFlags.Power
|
|
1036
|
+
break;
|
|
1037
|
+
case 10: //FAN SPEED MODE AUTO
|
|
1038
|
+
button.previousValue = state ? deviceData.Device.SetFanSpeed : button.previousValue ?? deviceData.Device.SetFanSpeed;
|
|
1039
|
+
deviceData.Device.Power = true;
|
|
1040
|
+
deviceData.Device.SetFanSpeed = state ? 0 : button.previousValue;
|
|
1041
|
+
flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
|
|
1042
|
+
break;
|
|
1043
|
+
case 11: //FAN SPEED MODE 1
|
|
1044
|
+
button.previousValue = state ? deviceData.Device.SetFanSpeed : button.previousValue ?? deviceData.Device.SetFanSpeed;
|
|
1045
|
+
deviceData.Device.Power = true;
|
|
1046
|
+
deviceData.Device.SetFanSpeed = state ? 1 : button.previousValue;
|
|
1047
|
+
flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
|
|
1048
|
+
break;
|
|
1049
|
+
case 12: //FAN SPEED MODE 2
|
|
1050
|
+
button.previousValue = state ? deviceData.Device.SetFanSpeed : button.previousValue ?? deviceData.Device.SetFanSpeed;
|
|
1051
|
+
deviceData.Device.Power = true;
|
|
1052
|
+
deviceData.Device.SetFanSpeed = state ? 2 : button.previousValue;
|
|
1053
|
+
flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
|
|
1054
|
+
break;
|
|
1055
|
+
case 13: //FAN SPEED MODE 3
|
|
1056
|
+
button.previousValue = state ? deviceData.Device.SetFanSpeed : button.previousValue ?? deviceData.Device.SetFanSpeed;
|
|
1057
|
+
deviceData.Device.Power = true;
|
|
1058
|
+
deviceData.Device.SetFanSpeed = state ? 3 : button.previousValue;
|
|
1059
|
+
flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
|
|
1060
|
+
break;
|
|
1061
|
+
case 14: //FAN MODE 4
|
|
1062
|
+
button.previousValue = state ? deviceData.Device.SetFanSpeed : button.previousValue ?? deviceData.Device.SetFanSpeed;
|
|
1063
|
+
deviceData.Device.Power = true;
|
|
1064
|
+
deviceData.Device.SetFanSpeed = state ? 4 : button.previousValue;
|
|
1065
|
+
flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
|
|
1066
|
+
break;
|
|
1067
|
+
case 15: //PHYSICAL LOCK CONTROLS
|
|
1068
|
+
deviceData.Device = deviceData.Device;
|
|
1069
|
+
flag = Ventilation.EffectiveFlags.Prohibit;
|
|
1070
|
+
break;
|
|
1071
|
+
case 16: //ROOM TEMP HIDE
|
|
1072
|
+
deviceData.HideRoomTemperature = state;
|
|
1073
|
+
break;
|
|
1074
|
+
case 17: //SUPPLY TEMP HIDE
|
|
1075
|
+
deviceData.HideSupplyTemperature = state;
|
|
1076
|
+
break;
|
|
1077
|
+
case 18: //OUTDOOR EMP HIDE
|
|
1078
|
+
deviceData.hideOutdoorTemperature = state;
|
|
1079
|
+
break;
|
|
1080
|
+
default:
|
|
1081
|
+
if (this.logWarn) this.emit('warn', `Unknown button mode: ${mode}`);
|
|
1082
|
+
break;
|
|
1083
|
+
};
|
|
1084
|
+
|
|
1085
|
+
if (this.logInfo) this.emit('info', `${state ? `Set: ${name}` : `Unset: ${name}, Set: ${button.previousValue}`}`);
|
|
1086
|
+
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, flag);
|
|
1087
|
+
} catch (error) {
|
|
1088
|
+
if (this.logWarn) this.emit('warn', `Set button error: ${error}`);
|
|
1089
|
+
};
|
|
1090
|
+
});
|
|
1091
|
+
this.buttonControlServices.push(buttonControlService);
|
|
1092
|
+
accessory.addService(buttonControlService);
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
//sensor
|
|
1096
|
+
if (this.logDebug) this.emit('debug', `Prepare button control sensor ${name} service`);
|
|
1097
|
+
const buttonControlSensorService = new serviceType(serviceName1, `buttonControlSensorService${deviceId} ${i}`);
|
|
1098
|
+
buttonControlSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
1099
|
+
buttonControlSensorService.setCharacteristic(Characteristic.ConfiguredName, serviceName1);
|
|
1100
|
+
buttonControlSensorService.getCharacteristic(characteristicType)
|
|
997
1101
|
.onGet(async () => {
|
|
998
1102
|
const state = button.state;
|
|
999
1103
|
return state;
|
|
1000
1104
|
})
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
let flag = null;
|
|
1004
|
-
switch (mode) {
|
|
1005
|
-
case 0: //POWER ON,OFF
|
|
1006
|
-
deviceData.Device.Power = state;
|
|
1007
|
-
flag = Ventilation.EffectiveFlags.Power;
|
|
1008
|
-
break;
|
|
1009
|
-
case 1: //OPERATING MODE RECOVERY
|
|
1010
|
-
button.previousValue = state ? deviceData.Device.VentilationMode : button.previousValue ?? deviceData.Device.VentilationMode;
|
|
1011
|
-
deviceData.Device.Power = true;
|
|
1012
|
-
deviceData.Device.VentilationMode = state ? 0 : button.previousValue;
|
|
1013
|
-
flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
|
|
1014
|
-
break;
|
|
1015
|
-
case 2: //OPERATING MODE BYPASS
|
|
1016
|
-
button.previousValue = state ? deviceData.Device.VentilationMode : button.previousValue ?? deviceData.Device.VentilationMode;
|
|
1017
|
-
deviceData.Device.Power = true;
|
|
1018
|
-
deviceData.Device.VentilationMode = state ? 1 : button.previousValue;
|
|
1019
|
-
flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
|
|
1020
|
-
break
|
|
1021
|
-
case 3: //OPERATING MODE AUTO
|
|
1022
|
-
button.previousValue = state ? deviceData.Device.VentilationMode : button.previousValue ?? deviceData.Device.VentilationMode;
|
|
1023
|
-
deviceData.Device.Power = true;
|
|
1024
|
-
deviceData.Device.VentilationMode = state ? 2 : button.previousValue;
|
|
1025
|
-
flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
|
|
1026
|
-
break;
|
|
1027
|
-
case 4: //NIGHT PURGE MODE
|
|
1028
|
-
deviceData.Device.Power = true;
|
|
1029
|
-
deviceData.Device.NightPurgeMode = state;
|
|
1030
|
-
flag = Ventilation.EffectiveFlags.Power
|
|
1031
|
-
break;
|
|
1032
|
-
case 10: //FAN SPEED MODE AUTO
|
|
1033
|
-
button.previousValue = state ? deviceData.Device.SetFanSpeed : button.previousValue ?? deviceData.Device.SetFanSpeed;
|
|
1034
|
-
deviceData.Device.Power = true;
|
|
1035
|
-
deviceData.Device.SetFanSpeed = state ? 0 : button.previousValue;
|
|
1036
|
-
flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
|
|
1037
|
-
break;
|
|
1038
|
-
case 11: //FAN SPEED MODE 1
|
|
1039
|
-
button.previousValue = state ? deviceData.Device.SetFanSpeed : button.previousValue ?? deviceData.Device.SetFanSpeed;
|
|
1040
|
-
deviceData.Device.Power = true;
|
|
1041
|
-
deviceData.Device.SetFanSpeed = state ? 1 : button.previousValue;
|
|
1042
|
-
flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
|
|
1043
|
-
break;
|
|
1044
|
-
case 12: //FAN SPEED MODE 2
|
|
1045
|
-
button.previousValue = state ? deviceData.Device.SetFanSpeed : button.previousValue ?? deviceData.Device.SetFanSpeed;
|
|
1046
|
-
deviceData.Device.Power = true;
|
|
1047
|
-
deviceData.Device.SetFanSpeed = state ? 2 : button.previousValue;
|
|
1048
|
-
flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
|
|
1049
|
-
break;
|
|
1050
|
-
case 13: //FAN SPEED MODE 3
|
|
1051
|
-
button.previousValue = state ? deviceData.Device.SetFanSpeed : button.previousValue ?? deviceData.Device.SetFanSpeed;
|
|
1052
|
-
deviceData.Device.Power = true;
|
|
1053
|
-
deviceData.Device.SetFanSpeed = state ? 3 : button.previousValue;
|
|
1054
|
-
flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
|
|
1055
|
-
break;
|
|
1056
|
-
case 14: //FAN MODE 4
|
|
1057
|
-
button.previousValue = state ? deviceData.Device.SetFanSpeed : button.previousValue ?? deviceData.Device.SetFanSpeed;
|
|
1058
|
-
deviceData.Device.Power = true;
|
|
1059
|
-
deviceData.Device.SetFanSpeed = state ? 4 : button.previousValue;
|
|
1060
|
-
flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
|
|
1061
|
-
break;
|
|
1062
|
-
case 15: //PHYSICAL LOCK CONTROLS
|
|
1063
|
-
deviceData.Device = deviceData.Device;
|
|
1064
|
-
flag = Ventilation.EffectiveFlags.Prohibit;
|
|
1065
|
-
break;
|
|
1066
|
-
case 16: //ROOM TEMP HIDE
|
|
1067
|
-
deviceData.HideRoomTemperature = state;
|
|
1068
|
-
break;
|
|
1069
|
-
case 17: //SUPPLY TEMP HIDE
|
|
1070
|
-
deviceData.HideSupplyTemperature = state;
|
|
1071
|
-
break;
|
|
1072
|
-
case 18: //OUTDOOR EMP HIDE
|
|
1073
|
-
deviceData.hideOutdoorTemperature = state;
|
|
1074
|
-
break;
|
|
1075
|
-
default:
|
|
1076
|
-
if (this.logWarn) this.emit('warn', `Unknown button mode: ${mode}`);
|
|
1077
|
-
break;
|
|
1078
|
-
};
|
|
1079
|
-
|
|
1080
|
-
if (this.logInfo) this.emit('info', `${state ? `Set: ${buttonName}` : `Unset: ${buttonName}, Set: ${button.previousValue}`}`);
|
|
1081
|
-
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, flag);
|
|
1082
|
-
} catch (error) {
|
|
1083
|
-
if (this.logWarn) this.emit('warn', `Set button error: ${error}`);
|
|
1084
|
-
};
|
|
1085
|
-
});
|
|
1086
|
-
this.buttonsServices.push(buttonService);
|
|
1087
|
-
accessory.addService(buttonService);
|
|
1105
|
+
this.buttonControlSensorServices.push(buttonControlSensorService);
|
|
1106
|
+
accessory.addService(buttonControlSensorService);
|
|
1088
1107
|
});
|
|
1089
1108
|
};
|
|
1090
1109
|
|
|
@@ -1500,9 +1519,14 @@ class DeviceErv extends EventEmitter {
|
|
|
1500
1519
|
break;
|
|
1501
1520
|
};
|
|
1502
1521
|
|
|
1503
|
-
//
|
|
1504
|
-
|
|
1505
|
-
|
|
1522
|
+
//control
|
|
1523
|
+
if (button.displayType > 3) {
|
|
1524
|
+
this.buttonControlServices?.[i]?.updateCharacteristic(Characteristic.On, button.state);
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
//sensor
|
|
1528
|
+
const characteristicType = scene.characteristicType;
|
|
1529
|
+
this.buttonControlSensorServices?.[i]?.updateCharacteristic(characteristicType, button.state);
|
|
1506
1530
|
});
|
|
1507
1531
|
};
|
|
1508
1532
|
|