homebridge-melcloud-control 4.0.0-beta.168 → 4.0.0-beta.169
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/deviceata.js +9 -15
- package/src/melcloudata.js +28 -49
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.169",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|
package/src/deviceata.js
CHANGED
|
@@ -18,7 +18,6 @@ class DeviceAta extends EventEmitter {
|
|
|
18
18
|
//account config
|
|
19
19
|
this.account = account;
|
|
20
20
|
this.device = device;
|
|
21
|
-
this.accountMelcloud = account.displayType === 'melcloud' ? true : false;
|
|
22
21
|
this.accountType = account.displayType;
|
|
23
22
|
this.displayMode = device.displayMode;
|
|
24
23
|
this.temperatureSensor = device.temperatureSensor || false;
|
|
@@ -941,12 +940,6 @@ class DeviceAta extends EventEmitter {
|
|
|
941
940
|
this.informationService?.setCharacteristic(Characteristic.FirmwareRevision, this.firmwareAppVersion);
|
|
942
941
|
})
|
|
943
942
|
.on('deviceState', async (deviceData) => {
|
|
944
|
-
if (this.accountType === 'melcloudhome') {
|
|
945
|
-
deviceData.Device.OperationMode = AirConditioner.OperationModeMapStringToEnum[deviceData.Device.OperationMode];
|
|
946
|
-
deviceData.Device.VaneVerticalDirection = AirConditioner.VaneVerticalDirectionMapStringToEnum[deviceData.Device.VaneVerticalDirection];
|
|
947
|
-
deviceData.Device.VaneHorizontalDirection = AirConditioner.VaneHorizontalDirectionMapStringToEnum[deviceData.Device.VaneHorizontalDirection];
|
|
948
|
-
deviceData.Device.ActualFanSpeed = AirConditioner.FanSpeedMapStringToEnum[deviceData.Device.ActualFanSpeed];
|
|
949
|
-
}
|
|
950
943
|
this.deviceData = deviceData;
|
|
951
944
|
|
|
952
945
|
//presets
|
|
@@ -957,18 +950,19 @@ class DeviceAta extends EventEmitter {
|
|
|
957
950
|
const hideDryModeControl = deviceData.HideDryModeControl ?? false;
|
|
958
951
|
|
|
959
952
|
//device info
|
|
953
|
+
const accountTypeMelcloud = this.accountType === 'melcloud';
|
|
960
954
|
const supportsAutomaticFanSpeed = deviceData.Device.HasAutomaticFanSpeed ?? false;
|
|
961
|
-
const supportsAirDirectionFunction =
|
|
962
|
-
const supportsSwingFunction =
|
|
963
|
-
const supportsWideVane =
|
|
955
|
+
const supportsAirDirectionFunction = accountTypeMelcloud ? deviceData.Device.AirDirectionFunction : deviceData.Device.HasAirDirectionFunction;;
|
|
956
|
+
const supportsSwingFunction = accountTypeMelcloud ? deviceData.Device.SwingFunction : deviceData.Device.HasSwing;
|
|
957
|
+
const supportsWideVane = accountTypeMelcloud ? deviceData.Device.ModelSupportsWideVane : deviceData.Device.SupportsWideVane;
|
|
964
958
|
const supportsOutdoorTemperature = deviceData.Device.HasOutdoorTemperature ?? false;
|
|
965
|
-
const supportsFanSpeed =
|
|
966
|
-
const supportsAuto1 =
|
|
959
|
+
const supportsFanSpeed = accountTypeMelcloud ? deviceData.Device.ModelSupportsFanSpeed : deviceData.Device.NumberOfFanSpeeds > 0;
|
|
960
|
+
const supportsAuto1 = accountTypeMelcloud ? deviceData.Device.ModelSupportsAuto : deviceData.Device.HasAutoOperationMode;
|
|
967
961
|
const supportsAuto = this.autoDryFanMode >= 1 && supportsAuto1
|
|
968
|
-
const supportsHeat1 =
|
|
962
|
+
const supportsHeat1 = accountTypeMelcloud ? deviceData.Device.ModelSupportsHeat : deviceData.Device.HasHeatOperationMode
|
|
969
963
|
const supportsHeat = this.heatDryFanMode >= 1 && supportsHeat1;
|
|
970
|
-
const supportsDry =
|
|
971
|
-
const supportsCool1 =
|
|
964
|
+
const supportsDry = accountTypeMelcloud ? deviceData.Device.ModelSupportsDry : deviceData.Device.HasDryOperationMode;
|
|
965
|
+
const supportsCool1 = accountTypeMelcloud ? deviceData.Device.ModelSupportsCool : deviceData.Device.HasCoolOperationMode;
|
|
972
966
|
const supportsCool = this.coolDryFanMode >= 1 && supportsCool1;
|
|
973
967
|
const numberOfFanSpeeds = supportsFanSpeed ? deviceData.Device.NumberOfFanSpeeds : 0;
|
|
974
968
|
const minTempHeat = 10;
|
package/src/melcloudata.js
CHANGED
|
@@ -54,12 +54,23 @@ class MelCloudAta extends EventEmitter {
|
|
|
54
54
|
return null;
|
|
55
55
|
}
|
|
56
56
|
const deviceData = devicesData.find(device => device.DeviceID === this.deviceId);
|
|
57
|
-
if (this.
|
|
57
|
+
if (this.accountType === 'melcloudhome') {
|
|
58
|
+
deviceData.Device.OperationMode = AirConditioner.OperationModeMapStringToEnum[deviceData.Device.OperationMode];
|
|
59
|
+
deviceData.Device.ActualFanSpeed = AirConditioner.FanSpeedMapStringToEnum[deviceData.Device.ActualFanSpeed];
|
|
60
|
+
deviceData.Device.VaneVerticalDirection = AirConditioner.VaneVerticalDirectionMapStringToEnum[deviceData.Device.VaneVerticalDirection];
|
|
61
|
+
deviceData.Device.VaneHorizontalDirection = AirConditioner.VaneHorizontalDirectionMapStringToEnum[deviceData.Device.VaneHorizontalDirection];
|
|
62
|
+
deviceData.Device.DefaultHeatingSetTemperature = 20;
|
|
63
|
+
deviceData.Device.DefaultCoolingSetTemperature = 23;
|
|
64
|
+
deviceData.Device.FirmwareAppVersion = '4.0.0';
|
|
65
|
+
deviceData.Device.SerialNumber = deviceData.Device.DeviceID || '4.0.0';
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (!this.logDebug) this.emit('warn', `Device Data: ${JSON.stringify(deviceData, null, 2)}`);
|
|
58
69
|
|
|
59
70
|
//device info
|
|
60
71
|
const hideVaneControls = deviceData.HideVaneControls ?? false;
|
|
61
72
|
const hideDryModeControl = deviceData.HideDryModeControl ?? false;
|
|
62
|
-
const serialNumber = deviceData.SerialNumber
|
|
73
|
+
const serialNumber = deviceData.SerialNumber;
|
|
63
74
|
|
|
64
75
|
//device
|
|
65
76
|
const fanKey = this.accountType === 'melcloud' ? 'FanSpeed' : 'SetFanSpeed';
|
|
@@ -82,58 +93,26 @@ class MelCloudAta extends EventEmitter {
|
|
|
82
93
|
const inStandbyMode = device.InStandbyMode;
|
|
83
94
|
const defaultCoolingSetTemperature = device.DefaultCoolingSetTemperature;
|
|
84
95
|
const defaultHeatingSetTemperature = device.DefaultHeatingSetTemperature;
|
|
85
|
-
const firmwareAppVersion = device.FirmwareAppVersion
|
|
96
|
+
const firmwareAppVersion = device.FirmwareAppVersion;
|
|
86
97
|
|
|
87
98
|
//units
|
|
88
99
|
const units = Array.isArray(device.Units) ? device.Units : [];
|
|
89
100
|
const unitsCount = units.length;
|
|
90
101
|
const manufacturer = 'Mitsubishi';
|
|
91
102
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
let modelOutdoor = false;
|
|
106
|
-
let typeOutdoor = 0;
|
|
107
|
-
|
|
108
|
-
//units array
|
|
109
|
-
for (const unit of units) {
|
|
110
|
-
const unitId = unit.ID;
|
|
111
|
-
const unitDevice = unit.Device;
|
|
112
|
-
const unitSerialNumber = unit.SerialNumber ?? 'Undefined';
|
|
113
|
-
const unitModelNumber = unit.ModelNumber;
|
|
114
|
-
const unitModel = unit.Model ?? false;
|
|
115
|
-
const unitType = unit.UnitType;
|
|
116
|
-
const unitIsIndoor = unit.IsIndoor ?? false;
|
|
117
|
-
|
|
118
|
-
switch (unitIsIndoor) {
|
|
119
|
-
case true:
|
|
120
|
-
idIndoor = unitId;
|
|
121
|
-
deviceIndoor = unitDevice;
|
|
122
|
-
serialNumberIndoor = unitSerialNumber;
|
|
123
|
-
modelNumberIndoor = unitModelNumber;
|
|
124
|
-
modelIndoor = unitModel;
|
|
125
|
-
typeIndoor = unitType;
|
|
126
|
-
break;
|
|
127
|
-
case false:
|
|
128
|
-
idOutdoor = unitId;
|
|
129
|
-
deviceOutdoor = unitDevice;
|
|
130
|
-
serialNumberOutdoor = unitSerialNumber;
|
|
131
|
-
modelNumberOutdoor = unitModelNumber;
|
|
132
|
-
modelOutdoor = unitModel;
|
|
133
|
-
typeOutdoor = unitType;
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
103
|
+
const { indoor, outdoor } = units.reduce((acc, unit) => {
|
|
104
|
+
const target = unit.IsIndoor ? 'indoor' : 'outdoor';
|
|
105
|
+
acc[target] = {
|
|
106
|
+
id: unit.ID,
|
|
107
|
+
device: unit.Device,
|
|
108
|
+
serialNumber: unit.SerialNumber ?? 'Undefined',
|
|
109
|
+
modelNumber: unit.ModelNumber ?? 0,
|
|
110
|
+
model: unit.Model ?? false,
|
|
111
|
+
type: unit.UnitType ?? 0
|
|
112
|
+
};
|
|
113
|
+
return acc;
|
|
114
|
+
}, { indoor: {}, outdoor: {} });
|
|
115
|
+
|
|
137
116
|
|
|
138
117
|
//display info if units are not configured in MELCloud service
|
|
139
118
|
if (unitsCount === 0) {
|
|
@@ -180,7 +159,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
180
159
|
this.deviceState = deviceState;
|
|
181
160
|
|
|
182
161
|
//emit info
|
|
183
|
-
this.emit('deviceInfo', manufacturer,
|
|
162
|
+
this.emit('deviceInfo', manufacturer, indoor, outdoor, serialNumber, firmwareAppVersion);
|
|
184
163
|
|
|
185
164
|
//emit state
|
|
186
165
|
this.emit('deviceState', deviceData);
|