homebridge-melcloud-control 4.3.9-beta.10 → 4.3.9-beta.12
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 +4 -2
- package/src/melcloudata.js +4 -5
- package/src/melcloudatw.js +23 -15
- package/src/melclouderv.js +5 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.3.9-beta.
|
|
4
|
+
"version": "4.3.9-beta.12",
|
|
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
|
@@ -61,9 +61,11 @@ export const AirConditioner = {
|
|
|
61
61
|
OperationModeMapStringToEnum: { "0": 0, "Heat": 1, "Dry": 2, "Cool": 3, "4": 4, "5": 5, "6": 6, "Fan": 7, "Automatic": 8, "Isee Heat": 9, "Isee Dry": 10, "Isee Cool": 11 },
|
|
62
62
|
OperationModeMapEnumToString: { 0: "0", 1: "Heat", 2: "Dry", 3: "Cool", 4: "4", 5: "5", 6: "6", 7: "Fan", 8: "Automatic", 9: "Isee Heat", 10: "Isee Dry", 11: "Isee Cool" },
|
|
63
63
|
OperationModeMapEnumToEnumWs: { 0: 0, 1: 1, 2: 2, 3: 3, 4: 7, 5: 8, 6: 9, 7: 10, 8: 11 },
|
|
64
|
-
FanSpeedMapStringToEnum: { "Auto": 0, "One": 1, "Two": 2, "Three": 3, "Four": 4, "Five": 5 },
|
|
64
|
+
FanSpeedMapStringToEnum: { "Auto": 0, "One": 1, "Two": 2, "Three": 3, "Four": 4, "Five": 5, "0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5 },
|
|
65
65
|
FanSpeedMapEnumToString: { 0: "Auto", 1: "One", 2: "Two", 3: "Three", 4: "Four", 5: "Five" },
|
|
66
|
-
|
|
66
|
+
SetFanSpeedMapStringToEnum: { "Auto": 0, "One": 1, "Two": 2, "Three": 3, "Four": 4, "Five": 5, "0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5 },
|
|
67
|
+
SetFanSpeedMapEnumToString: { 0: "Auto", 1: "One", 2: "Two", 3: "Three", 4: "Four", 5: "Five" },
|
|
68
|
+
AktualFanSpeedMapStringToEnum: { "Auto": 0, "One": 1, "Two": 2, "Three": 3, "Four": 4, "Five": 5, "0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5 },
|
|
67
69
|
AktualFanSpeedMapEnumToString: { 0: "Quiet", 1: "One", 2: "Two", 3: "Three", 4: "Four", 5: "Five" },
|
|
68
70
|
VaneVerticalDirectionMapStringToEnum: { "Auto": 0, "One": 1, "Two": 2, "Three": 3, "Four": 4, "Five": 5, "Six": 6, "Swing": 7 },
|
|
69
71
|
VaneVerticalDirectionMapEnumToString: { 0: "Auto", 1: "One", 2: "Two", 3: "Three", 4: "Four", 5: "Five", 6: "Six", 7: "Swing" },
|
package/src/melcloudata.js
CHANGED
|
@@ -35,7 +35,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
35
35
|
deviceData.Scenes = devicesData.Scenes ?? [];
|
|
36
36
|
|
|
37
37
|
//update state
|
|
38
|
-
if (!this.logDebug) this.emit('debug', `Request update
|
|
38
|
+
if (!this.logDebug) this.emit('debug', `Request update settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
|
|
39
39
|
await this.updateState(deviceData);
|
|
40
40
|
}).on('webSocket', async (parsedMessage) => {
|
|
41
41
|
try {
|
|
@@ -63,12 +63,11 @@ class MelCloudAta extends EventEmitter {
|
|
|
63
63
|
|
|
64
64
|
//update device settings
|
|
65
65
|
if (key in deviceData.Device) {
|
|
66
|
-
|
|
67
|
-
deviceData.Device[key] = parsedValue;
|
|
66
|
+
deviceData.Device[key] = value;
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
69
|
|
|
71
|
-
if (!this.logDebug) this.emit('debug', `WS update
|
|
70
|
+
if (!this.logDebug) this.emit('debug', `WS update settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
|
|
72
71
|
updateState = true;
|
|
73
72
|
break;
|
|
74
73
|
case 'unitHolidayModeTriggered':
|
|
@@ -110,7 +109,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
110
109
|
} else {
|
|
111
110
|
deviceData.Device.OperationMode = AirConditioner.OperationModeMapStringToEnum[deviceData.Device.OperationMode] ?? deviceData.Device.OperationMode;
|
|
112
111
|
deviceData.Device.ActualFanSpeed = AirConditioner.AktualFanSpeedMapStringToEnum[deviceData.Device.ActualFanSpeed] ?? deviceData.Device.ActualFanSpeed;
|
|
113
|
-
deviceData.Device.SetFanSpeed = AirConditioner.
|
|
112
|
+
deviceData.Device.SetFanSpeed = AirConditioner.SetFanSpeedMapStringToEnum[deviceData.Device.SetFanSpeed] ?? deviceData.Device.SetFanSpeed;
|
|
114
113
|
deviceData.Device.VaneHorizontalDirection = AirConditioner.VaneHorizontalDirectionMapStringToEnum[deviceData.Device.VaneHorizontalDirection] ?? deviceData.Device.VaneHorizontalDirection;
|
|
115
114
|
deviceData.Device.VaneVerticalDirection = AirConditioner.VaneVerticalDirectionMapStringToEnum[deviceData.Device.VaneVerticalDirection] ?? deviceData.Device.VaneVerticalDirection;
|
|
116
115
|
}
|
package/src/melcloudatw.js
CHANGED
|
@@ -35,14 +35,10 @@ class MelCloudAtw extends EventEmitter {
|
|
|
35
35
|
deviceData.Scenes = devicesData.Scenes ?? [];
|
|
36
36
|
|
|
37
37
|
//update state
|
|
38
|
+
if (this.logDebug) this.emit('debug', `Request update settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
|
|
38
39
|
await this.updateState(deviceData);
|
|
39
|
-
}).on('
|
|
40
|
+
}).on('webSocket', async (parsedMessage) => {
|
|
40
41
|
try {
|
|
41
|
-
const parsedMessage = JSON.parse(message);
|
|
42
|
-
const stringifyMessage = JSON.stringify(parsedMessage, null, 2);
|
|
43
|
-
if (this.logDebug) this.emit('debug', `Incoming message: ${stringifyMessage}`);
|
|
44
|
-
if (parsedMessage.message === 'Forbidden') return;
|
|
45
|
-
|
|
46
42
|
const messageData = parsedMessage?.[0]?.Data;
|
|
47
43
|
if (!messageData || !deviceData) return;
|
|
48
44
|
|
|
@@ -51,15 +47,27 @@ class MelCloudAtw extends EventEmitter {
|
|
|
51
47
|
switch (unitId) {
|
|
52
48
|
case this.deviceId:
|
|
53
49
|
const messageType = parsedMessage[0].messageType;
|
|
50
|
+
const settings = this.functions.parseArrayNameValue(messageData.settings);
|
|
54
51
|
switch (messageType) {
|
|
55
52
|
case 'unitStateChanged':
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
|
|
54
|
+
//update values
|
|
55
|
+
for (const [key, value] of Object.entries(settings)) {
|
|
56
|
+
if (!this.functions.isValidValue(value)) continue;
|
|
57
|
+
|
|
58
|
+
//update holiday mode
|
|
59
|
+
if (key === 'HolidayMode') {
|
|
60
|
+
deviceData.HolidayMode.Enabled = value;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//update device settings
|
|
65
|
+
if (key in deviceData.Device) {
|
|
66
|
+
deviceData.Device[key] = value;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (this.logDebug) this.emit('debug', `WS update settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
|
|
63
71
|
updateState = true;
|
|
64
72
|
break;
|
|
65
73
|
case 'unitHolidayModeTriggered':
|
|
@@ -83,7 +91,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
83
91
|
}
|
|
84
92
|
|
|
85
93
|
//update state
|
|
86
|
-
if (updateState) await this.updateState(deviceData);
|
|
94
|
+
if (updateState) await this.updateState(deviceData, 'ws');
|
|
87
95
|
} catch (error) {
|
|
88
96
|
if (this.logError) this.emit('error', `Web socket process message error: ${error}`);
|
|
89
97
|
}
|
|
@@ -228,7 +236,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
228
236
|
}
|
|
229
237
|
|
|
230
238
|
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
|
|
231
|
-
|
|
239
|
+
|
|
232
240
|
await axios(path, {
|
|
233
241
|
method: 'POST',
|
|
234
242
|
baseURL: ApiUrls.BaseURL,
|
package/src/melclouderv.js
CHANGED
|
@@ -35,6 +35,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
35
35
|
deviceData.Scenes = devicesData.Scenes ?? [];
|
|
36
36
|
|
|
37
37
|
//update state
|
|
38
|
+
if (this.logDebug) this.emit('debug', `Request update settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
|
|
38
39
|
await this.updateState(deviceData);
|
|
39
40
|
}).on('webSocket', async (parsedMessage) => {
|
|
40
41
|
try {
|
|
@@ -65,6 +66,8 @@ class MelCloudErv extends EventEmitter {
|
|
|
65
66
|
deviceData.Device[key] = value;
|
|
66
67
|
}
|
|
67
68
|
}
|
|
69
|
+
|
|
70
|
+
if (this.logDebug) this.emit('debug', `WS update settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
|
|
68
71
|
updateState = true;
|
|
69
72
|
break;
|
|
70
73
|
case 'unitHolidayModeTriggered':
|
|
@@ -88,7 +91,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
88
91
|
}
|
|
89
92
|
|
|
90
93
|
//update state
|
|
91
|
-
if (updateState) await this.updateState(deviceData);
|
|
94
|
+
if (updateState) await this.updateState(deviceData, 'ws');
|
|
92
95
|
} catch (error) {
|
|
93
96
|
if (this.logError) this.emit('error', `Web socket process message error: ${error}`);
|
|
94
97
|
}
|
|
@@ -233,7 +236,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
233
236
|
}
|
|
234
237
|
|
|
235
238
|
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
|
|
236
|
-
|
|
239
|
+
|
|
237
240
|
await axios(path, {
|
|
238
241
|
method: 'POST',
|
|
239
242
|
baseURL: ApiUrls.BaseURL,
|