homebridge-melcloud-control 4.0.0-beta.167 → 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/constants.js +2 -2
- package/src/deviceata.js +12 -17
- package/src/melcloudata.js +30 -51
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/constants.js
CHANGED
|
@@ -41,8 +41,8 @@ export const AirConditioner = {
|
|
|
41
41
|
CurrentOperationModeThermostatMapEnumToString: { 0: "Inactive", 1: "Heating", 2: "Cooling" },
|
|
42
42
|
OperationModeMapStringToEnum: { "0": 0, "Heat": 1, "Dry": 2, "Cool": 3, "4": 4, "5": 5, "6": 6, "Fan": 7, "Auto": 8, "Isee Heat": 9, "Isee Dry": 10, "Isee Cool": 11 },
|
|
43
43
|
OperationModeMapEnumToString: { 0: "0", 1: "Heat", 2: "Dry", 3: "Cool", 4: "4", 5: "5", 6: "6", 7: "Fan", 8: "Auto", 9: "Isee Heat", 10: "Isee Dry", 11: "Isee Cool" },
|
|
44
|
-
FanSpeedMapStringToEnum: { "Auto": 0, "One": 1, "Two": 2, "Three": 3, "Four": 4, "Five": 5
|
|
45
|
-
FanSpeedMapEnumToString: { 0: "Auto", 1: "One", 2: "Two", 3: "Three", 4: "Four", 5: "Five" },
|
|
44
|
+
FanSpeedMapStringToEnum: { "Auto": 0, "One": 1, "Two": 2, "Three": 3, "Four": 4, "Five": 5 },
|
|
45
|
+
FanSpeedMapEnumToString: { 0: "Auto", 1: "One", 2: "Two", 3: "Three", 4: "Four", 5: "Five", 6: "Auto"},
|
|
46
46
|
VaneVerticalDirectionMapStringToEnum: { "Auto": 0, "One": 1, "Two": 2, "Three": 3, "Four": 4, "Five": 5, "Six": 6, "Swing": 7 },
|
|
47
47
|
VaneVerticalDirectionMapEnumToString: { 0: "Auto", 1: "One", 2: "Two", 3: "Three", 4: "Four", 5: "Five", 6: "Six", 7: "Swing" },
|
|
48
48
|
VaneHorizontalDirectionMapStringToEnum: { "Auto": 0, "Left": 1, "LeftCenter": 2, "Center": 3, "RightCenter": 4, "Right": 5, "Six": 6, "Seven": 7, "Split": 8, "Nine": 9, "Ten": 10, "Eleven": 11, "Swing": 12 },
|
package/src/deviceata.js
CHANGED
|
@@ -16,9 +16,9 @@ class DeviceAta extends EventEmitter {
|
|
|
16
16
|
AccessoryUUID = api.hap.uuid;
|
|
17
17
|
|
|
18
18
|
//account config
|
|
19
|
-
this.
|
|
20
|
-
this.accountType = account.displayType;
|
|
19
|
+
this.account = account;
|
|
21
20
|
this.device = device;
|
|
21
|
+
this.accountType = account.displayType;
|
|
22
22
|
this.displayMode = device.displayMode;
|
|
23
23
|
this.temperatureSensor = device.temperatureSensor || false;
|
|
24
24
|
this.temperatureSensorOutdoor = device.temperatureSensorOutdoor || false;
|
|
@@ -917,7 +917,7 @@ class DeviceAta extends EventEmitter {
|
|
|
917
917
|
async start() {
|
|
918
918
|
try {
|
|
919
919
|
//melcloud device
|
|
920
|
-
this.melCloudAta = new MelCloudAta(this.device, this.devicesFile)
|
|
920
|
+
this.melCloudAta = new MelCloudAta(this.account, this.device, this.devicesFile)
|
|
921
921
|
.on('deviceInfo', (manufacturer, modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion) => {
|
|
922
922
|
if (this.logDeviceInfo && this.displayDeviceInfo) {
|
|
923
923
|
this.emit('devInfo', `---- ${this.deviceTypeText}: ${this.deviceName} ----`);
|
|
@@ -940,12 +940,6 @@ class DeviceAta extends EventEmitter {
|
|
|
940
940
|
this.informationService?.setCharacteristic(Characteristic.FirmwareRevision, this.firmwareAppVersion);
|
|
941
941
|
})
|
|
942
942
|
.on('deviceState', async (deviceData) => {
|
|
943
|
-
if (this.accountType === 'melcloudhome') {
|
|
944
|
-
deviceData.Device.OperationMode = AirConditioner.OperationModeMapStringToEnum[deviceData.Device.OperationMode];
|
|
945
|
-
deviceData.Device.VaneVerticalDirection = AirConditioner.VaneVerticalDirectionMapStringToEnum[deviceData.Device.VaneVerticalDirection];
|
|
946
|
-
deviceData.Device.VaneHorizontalDirection = AirConditioner.VaneHorizontalDirectionMapStringToEnum[deviceData.Device.VaneHorizontalDirection];
|
|
947
|
-
deviceData.Device.ActualFanSpeed = AirConditioner.FanSpeedMapStringToEnum[deviceData.Device.ActualFanSpeed];
|
|
948
|
-
}
|
|
949
943
|
this.deviceData = deviceData;
|
|
950
944
|
|
|
951
945
|
//presets
|
|
@@ -956,18 +950,19 @@ class DeviceAta extends EventEmitter {
|
|
|
956
950
|
const hideDryModeControl = deviceData.HideDryModeControl ?? false;
|
|
957
951
|
|
|
958
952
|
//device info
|
|
953
|
+
const accountTypeMelcloud = this.accountType === 'melcloud';
|
|
959
954
|
const supportsAutomaticFanSpeed = deviceData.Device.HasAutomaticFanSpeed ?? false;
|
|
960
|
-
const supportsAirDirectionFunction =
|
|
961
|
-
const supportsSwingFunction =
|
|
962
|
-
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;
|
|
963
958
|
const supportsOutdoorTemperature = deviceData.Device.HasOutdoorTemperature ?? false;
|
|
964
|
-
const supportsFanSpeed =
|
|
965
|
-
const supportsAuto1 =
|
|
959
|
+
const supportsFanSpeed = accountTypeMelcloud ? deviceData.Device.ModelSupportsFanSpeed : deviceData.Device.NumberOfFanSpeeds > 0;
|
|
960
|
+
const supportsAuto1 = accountTypeMelcloud ? deviceData.Device.ModelSupportsAuto : deviceData.Device.HasAutoOperationMode;
|
|
966
961
|
const supportsAuto = this.autoDryFanMode >= 1 && supportsAuto1
|
|
967
|
-
const supportsHeat1 =
|
|
962
|
+
const supportsHeat1 = accountTypeMelcloud ? deviceData.Device.ModelSupportsHeat : deviceData.Device.HasHeatOperationMode
|
|
968
963
|
const supportsHeat = this.heatDryFanMode >= 1 && supportsHeat1;
|
|
969
|
-
const supportsDry =
|
|
970
|
-
const supportsCool1 =
|
|
964
|
+
const supportsDry = accountTypeMelcloud ? deviceData.Device.ModelSupportsDry : deviceData.Device.HasDryOperationMode;
|
|
965
|
+
const supportsCool1 = accountTypeMelcloud ? deviceData.Device.ModelSupportsCool : deviceData.Device.HasCoolOperationMode;
|
|
971
966
|
const supportsCool = this.coolDryFanMode >= 1 && supportsCool1;
|
|
972
967
|
const numberOfFanSpeeds = supportsFanSpeed ? deviceData.Device.NumberOfFanSpeeds : 0;
|
|
973
968
|
const minTempHeat = 10;
|
package/src/melcloudata.js
CHANGED
|
@@ -5,9 +5,9 @@ import Functions from './functions.js';
|
|
|
5
5
|
import { ApiUrls, ApiUrlsHome, AirConditioner } from './constants.js';
|
|
6
6
|
|
|
7
7
|
class MelCloudAta extends EventEmitter {
|
|
8
|
-
constructor(device, devicesFile) {
|
|
8
|
+
constructor(account, device, devicesFile) {
|
|
9
9
|
super();
|
|
10
|
-
this.accountType =
|
|
10
|
+
this.accountType = account.displayType
|
|
11
11
|
this.deviceId = device.id;
|
|
12
12
|
this.logWarn = device.log?.warn;
|
|
13
13
|
this.logDebug = device.log?.debug;
|
|
@@ -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);
|