homebridge-melcloud-control 4.3.9-beta.10 → 4.3.9-beta.11
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 +3 -3
- package/src/melcloudatw.js +24 -15
- package/src/melclouderv.js +8 -4
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.11",
|
|
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
|
@@ -54,16 +54,16 @@ class MelCloudAta extends EventEmitter {
|
|
|
54
54
|
//update values
|
|
55
55
|
for (const [key, value] of Object.entries(settings)) {
|
|
56
56
|
if (!this.functions.isValidValue(value)) continue;
|
|
57
|
+
let parsedValue = this.functions.convertValue(value);
|
|
57
58
|
|
|
58
59
|
//update holiday mode
|
|
59
60
|
if (key === 'HolidayMode') {
|
|
60
|
-
deviceData.HolidayMode.Enabled =
|
|
61
|
+
deviceData.HolidayMode.Enabled = parsedValue;
|
|
61
62
|
continue;
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
//update device settings
|
|
65
66
|
if (key in deviceData.Device) {
|
|
66
|
-
let parsedValue = this.functions.convertValue(value);
|
|
67
67
|
deviceData.Device[key] = parsedValue;
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -110,7 +110,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
110
110
|
} else {
|
|
111
111
|
deviceData.Device.OperationMode = AirConditioner.OperationModeMapStringToEnum[deviceData.Device.OperationMode] ?? deviceData.Device.OperationMode;
|
|
112
112
|
deviceData.Device.ActualFanSpeed = AirConditioner.AktualFanSpeedMapStringToEnum[deviceData.Device.ActualFanSpeed] ?? deviceData.Device.ActualFanSpeed;
|
|
113
|
-
deviceData.Device.SetFanSpeed = AirConditioner.
|
|
113
|
+
deviceData.Device.SetFanSpeed = AirConditioner.SetFanSpeedMapStringToEnum[deviceData.Device.SetFanSpeed] ?? deviceData.Device.SetFanSpeed;
|
|
114
114
|
deviceData.Device.VaneHorizontalDirection = AirConditioner.VaneHorizontalDirectionMapStringToEnum[deviceData.Device.VaneHorizontalDirection] ?? deviceData.Device.VaneHorizontalDirection;
|
|
115
115
|
deviceData.Device.VaneVerticalDirection = AirConditioner.VaneVerticalDirectionMapStringToEnum[deviceData.Device.VaneVerticalDirection] ?? deviceData.Device.VaneVerticalDirection;
|
|
116
116
|
}
|
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 device 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,28 @@ 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
|
+
let parsedValue = this.functions.convertValue(value);
|
|
58
|
+
|
|
59
|
+
//update holiday mode
|
|
60
|
+
if (key === 'HolidayMode') {
|
|
61
|
+
deviceData.HolidayMode.Enabled = parsedValue;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//update device settings
|
|
66
|
+
if (key in deviceData.Device) {
|
|
67
|
+
deviceData.Device[key] = parsedValue;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (this.logDebug) this.emit('debug', `WS update device settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
|
|
63
72
|
updateState = true;
|
|
64
73
|
break;
|
|
65
74
|
case 'unitHolidayModeTriggered':
|
|
@@ -83,7 +92,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
83
92
|
}
|
|
84
93
|
|
|
85
94
|
//update state
|
|
86
|
-
if (updateState) await this.updateState(deviceData);
|
|
95
|
+
if (updateState) await this.updateState(deviceData, 'ws');
|
|
87
96
|
} catch (error) {
|
|
88
97
|
if (this.logError) this.emit('error', `Web socket process message error: ${error}`);
|
|
89
98
|
}
|
|
@@ -228,7 +237,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
228
237
|
}
|
|
229
238
|
|
|
230
239
|
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
|
|
231
|
-
|
|
240
|
+
|
|
232
241
|
await axios(path, {
|
|
233
242
|
method: 'POST',
|
|
234
243
|
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 device settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
|
|
38
39
|
await this.updateState(deviceData);
|
|
39
40
|
}).on('webSocket', async (parsedMessage) => {
|
|
40
41
|
try {
|
|
@@ -53,18 +54,21 @@ class MelCloudErv extends EventEmitter {
|
|
|
53
54
|
//update values
|
|
54
55
|
for (const [key, value] of Object.entries(settings)) {
|
|
55
56
|
if (!this.functions.isValidValue(value)) continue;
|
|
57
|
+
let parsedValue = this.functions.convertValue(value);
|
|
56
58
|
|
|
57
59
|
//update holiday mode
|
|
58
60
|
if (key === 'HolidayMode') {
|
|
59
|
-
deviceData.HolidayMode.Enabled =
|
|
61
|
+
deviceData.HolidayMode.Enabled = parsedValue;
|
|
60
62
|
continue;
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
//update device settings
|
|
64
66
|
if (key in deviceData.Device) {
|
|
65
|
-
deviceData.Device[key] =
|
|
67
|
+
deviceData.Device[key] = parsedValue;
|
|
66
68
|
}
|
|
67
69
|
}
|
|
70
|
+
|
|
71
|
+
if (this.logDebug) this.emit('debug', `WS update device settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
|
|
68
72
|
updateState = true;
|
|
69
73
|
break;
|
|
70
74
|
case 'unitHolidayModeTriggered':
|
|
@@ -88,7 +92,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
88
92
|
}
|
|
89
93
|
|
|
90
94
|
//update state
|
|
91
|
-
if (updateState) await this.updateState(deviceData);
|
|
95
|
+
if (updateState) await this.updateState(deviceData, 'ws');
|
|
92
96
|
} catch (error) {
|
|
93
97
|
if (this.logError) this.emit('error', `Web socket process message error: ${error}`);
|
|
94
98
|
}
|
|
@@ -233,7 +237,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
233
237
|
}
|
|
234
238
|
|
|
235
239
|
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
|
|
236
|
-
|
|
240
|
+
|
|
237
241
|
await axios(path, {
|
|
238
242
|
method: 'POST',
|
|
239
243
|
baseURL: ApiUrls.BaseURL,
|