homebridge-melcloud-control 4.3.11-beta.0 → 4.3.11-beta.2
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/melcloud.js +1 -0
- package/src/melcloudata.js +9 -8
- package/src/melcloudatw.js +8 -7
- package/src/melclouderv.js +8 -7
- package/src/melcloudhome.js +2 -0
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.11-beta.
|
|
4
|
+
"version": "4.3.11-beta.2",
|
|
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
|
@@ -58,8 +58,8 @@ export const TemperatureDisplayUnits = ["°C", "°F"];
|
|
|
58
58
|
|
|
59
59
|
export const AirConditioner = {
|
|
60
60
|
SystemMapEnumToString: { 0: "Air Conditioner Off", 1: "Air Conditioner On", 2: "Air Conditioner Offline" },
|
|
61
|
-
OperationModeMapStringToEnum: { "0": 0, "Heat": 1, "Dry": 2, "Cool": 3, "4": 4, "5": 5, "6": 6, "Fan": 7, "Automatic": 8, "Isee
|
|
62
|
-
OperationModeMapEnumToString: { 0: "0", 1: "Heat", 2: "Dry", 3: "Cool", 4: "4", 5: "5", 6: "6", 7: "Fan", 8: "Automatic", 9: "Isee
|
|
61
|
+
OperationModeMapStringToEnum: { "0": 0, "Heat": 1, "Dry": 2, "Cool": 3, "4": 4, "5": 5, "6": 6, "Fan": 7, "Automatic": 8, "Heat Isee": 9, "Dry Isee": 10, "Cool Isee": 11 },
|
|
62
|
+
OperationModeMapEnumToString: { 0: "0", 1: "Heat", 2: "Dry", 3: "Cool", 4: "4", 5: "5", 6: "6", 7: "Fan", 8: "Automatic", 9: "Heat Isee", 10: "Dry Isee", 11: "Cool Isee" },
|
|
63
63
|
OperationModeMapEnumToEnumWs: { 0: 0, 1: 1, 2: 2, 3: 3, 4: 7, 5: 8, 6: 9, 7: 10, 8: 11 },
|
|
64
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" },
|
package/src/melcloud.js
CHANGED
package/src/melcloudata.js
CHANGED
|
@@ -28,16 +28,17 @@ class MelCloudAta extends EventEmitter {
|
|
|
28
28
|
|
|
29
29
|
//handle melcloud events
|
|
30
30
|
let deviceData = null;
|
|
31
|
-
melcloud.on('
|
|
31
|
+
melcloud.on('headers', (headers) => {
|
|
32
|
+
this.headers = headers;
|
|
33
|
+
}).on('devicesList', async (devicesData) => {
|
|
32
34
|
try {
|
|
33
|
-
this.headers = devicesData.Headers;
|
|
34
35
|
deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
|
|
35
36
|
if (!deviceData) return;
|
|
36
37
|
deviceData.Scenes = devicesData.Scenes ?? [];
|
|
37
38
|
|
|
38
39
|
//update state
|
|
39
40
|
if (this.logDebug) this.emit('debug', `Request update settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
|
|
40
|
-
await this.updateState(deviceData);
|
|
41
|
+
await this.updateState('request', deviceData);
|
|
41
42
|
} catch (error) {
|
|
42
43
|
if (this.logError) this.emit('error', `Request process message error: ${error}`);
|
|
43
44
|
}
|
|
@@ -95,14 +96,14 @@ class MelCloudAta extends EventEmitter {
|
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
//update state
|
|
98
|
-
if (updateState) await this.updateState(
|
|
99
|
+
if (updateState) await this.updateState('ws', deviceData);
|
|
99
100
|
} catch (error) {
|
|
100
101
|
if (this.logError) this.emit('error', `Web socket process message error: ${error}`);
|
|
101
102
|
}
|
|
102
103
|
});
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
async updateState(
|
|
106
|
+
async updateState(type, deviceData) {
|
|
106
107
|
try {
|
|
107
108
|
if (this.accountType === 'melcloudhome') {
|
|
108
109
|
|
|
@@ -148,7 +149,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
148
149
|
}, { indoor: {}, outdoor: {} });
|
|
149
150
|
|
|
150
151
|
//display info if units are not configured in MELCloud service
|
|
151
|
-
if (unitsCount === 0 && this.logDebug) if (this.logDebug) this.emit('debug', `Units are not configured in MELCloud service`);
|
|
152
|
+
if (this.accountType === 'melcloud' && unitsCount === 0 && this.logDebug) if (this.logDebug) this.emit('debug', `Units are not configured in MELCloud service`);
|
|
152
153
|
|
|
153
154
|
//filter info
|
|
154
155
|
const { Device: _ignored, ...info } = deviceData;
|
|
@@ -187,7 +188,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
187
188
|
this.headers = devicesData.Headers;
|
|
188
189
|
const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
|
|
189
190
|
deviceData.Scenes = devicesData.Scenes ?? [];
|
|
190
|
-
await this.updateState(deviceData);
|
|
191
|
+
await this.updateState('request', deviceData);
|
|
191
192
|
|
|
192
193
|
return true;
|
|
193
194
|
} catch (error) {
|
|
@@ -327,7 +328,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
327
328
|
//sens payload
|
|
328
329
|
headers['Content-Type'] = 'application/json; charset=utf-8';
|
|
329
330
|
headers.Origin = ApiUrlsHome.Origin;
|
|
330
|
-
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
|
|
331
|
+
if (!this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}`);
|
|
331
332
|
|
|
332
333
|
await axios(path, {
|
|
333
334
|
method: method,
|
package/src/melcloudatw.js
CHANGED
|
@@ -28,16 +28,17 @@ class MelCloudAtw extends EventEmitter {
|
|
|
28
28
|
|
|
29
29
|
//handle melcloud events
|
|
30
30
|
let deviceData = null;
|
|
31
|
-
melcloud.on('
|
|
31
|
+
melcloud.on('headers', (headers) => {
|
|
32
|
+
this.headers = headers;
|
|
33
|
+
}).on('devicesList', async (devicesData) => {
|
|
32
34
|
try {
|
|
33
|
-
this.headers = devicesData.Headers;
|
|
34
35
|
deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
|
|
35
36
|
if (!deviceData) return;
|
|
36
37
|
deviceData.Scenes = devicesData.Scenes ?? [];
|
|
37
38
|
|
|
38
39
|
//update state
|
|
39
40
|
if (this.logDebug) this.emit('debug', `Request update settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
|
|
40
|
-
await this.updateState(deviceData);
|
|
41
|
+
await this.updateState('request', deviceData);
|
|
41
42
|
} catch (error) {
|
|
42
43
|
if (this.logError) this.emit('error', `Request process message error: ${error}`);
|
|
43
44
|
}
|
|
@@ -95,14 +96,14 @@ class MelCloudAtw extends EventEmitter {
|
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
//update state
|
|
98
|
-
if (updateState) await this.updateState(
|
|
99
|
+
if (updateState) await this.updateState('ws', deviceData);
|
|
99
100
|
} catch (error) {
|
|
100
101
|
if (this.logError) this.emit('error', `Web socket process message error: ${error}`);
|
|
101
102
|
}
|
|
102
103
|
});
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
async updateState(
|
|
106
|
+
async updateState(type, deviceData) {
|
|
106
107
|
try {
|
|
107
108
|
if (this.accountType === 'melcloudhome') {
|
|
108
109
|
deviceData.Device.OperationMode = HeatPump.OperationModeMapStringToEnum[deviceData.Device.OperationMode] ?? deviceData.Device.OperationMode;
|
|
@@ -135,7 +136,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
135
136
|
}, { indoor: {}, outdoor: {} });
|
|
136
137
|
|
|
137
138
|
//display info if units are not configured in MELCloud service
|
|
138
|
-
if (unitsCount === 0 && this.logDebug) if (this.logDebug) this.emit('debug', `Units are not configured in MELCloud service`);
|
|
139
|
+
if (this.accountType === 'melcloud' && unitsCount === 0 && this.logDebug) if (this.logDebug) this.emit('debug', `Units are not configured in MELCloud service`);
|
|
139
140
|
|
|
140
141
|
//filter info
|
|
141
142
|
const { Device: _ignored, ...info } = deviceData;
|
|
@@ -174,7 +175,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
174
175
|
this.headers = devicesData.Headers;
|
|
175
176
|
const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
|
|
176
177
|
deviceData.Scenes = devicesData.Scenes ?? [];
|
|
177
|
-
await this.updateState(deviceData);
|
|
178
|
+
await this.updateState('request', deviceData);
|
|
178
179
|
|
|
179
180
|
return true;
|
|
180
181
|
} catch (error) {
|
package/src/melclouderv.js
CHANGED
|
@@ -28,16 +28,17 @@ class MelCloudErv extends EventEmitter {
|
|
|
28
28
|
|
|
29
29
|
//handle melcloud events
|
|
30
30
|
let deviceData = null;
|
|
31
|
-
melcloud.on('
|
|
31
|
+
melcloud.on('headers', (headers) => {
|
|
32
|
+
this.headers = headers;
|
|
33
|
+
}).on('devicesList', async (devicesData) => {
|
|
32
34
|
try {
|
|
33
|
-
this.headers = devicesData.Headers;
|
|
34
35
|
deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
|
|
35
36
|
if (!deviceData) return;
|
|
36
37
|
deviceData.Scenes = devicesData.Scenes ?? [];
|
|
37
38
|
|
|
38
39
|
//update state
|
|
39
40
|
if (this.logDebug) this.emit('debug', `Request update settings: ${JSON.stringify(deviceData.Device, null, 2)}`);
|
|
40
|
-
await this.updateState(deviceData);
|
|
41
|
+
await this.updateState('request', deviceData);
|
|
41
42
|
} catch (error) {
|
|
42
43
|
if (this.logError) this.emit('error', `Request process message error: ${error}`);
|
|
43
44
|
}
|
|
@@ -95,14 +96,14 @@ class MelCloudErv extends EventEmitter {
|
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
//update state
|
|
98
|
-
if (updateState) await this.updateState(
|
|
99
|
+
if (updateState) await this.updateState('ws', deviceData);
|
|
99
100
|
} catch (error) {
|
|
100
101
|
if (this.logError) this.emit('error', `Web socket process message error: ${error}`);
|
|
101
102
|
}
|
|
102
103
|
});
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
async updateState(
|
|
106
|
+
async updateState(type, deviceData) {
|
|
106
107
|
try {
|
|
107
108
|
if (this.accountType === 'melcloudhome') {
|
|
108
109
|
//read default temps
|
|
@@ -134,7 +135,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
134
135
|
}, { indoor: {}, outdoor: {} });
|
|
135
136
|
|
|
136
137
|
//display info if units are not configured in MELCloud service
|
|
137
|
-
if (unitsCount === 0 && this.logDebug) if (this.logDebug) this.emit('debug', `Units are not configured in MELCloud service`);
|
|
138
|
+
if (this.accountType === 'melcloud' && unitsCount === 0 && this.logDebug) if (this.logDebug) this.emit('debug', `Units are not configured in MELCloud service`);
|
|
138
139
|
|
|
139
140
|
//filter info
|
|
140
141
|
const { Device: _ignored, ...info } = deviceData;
|
|
@@ -173,7 +174,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
173
174
|
this.headers = devicesData.Headers;
|
|
174
175
|
const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
|
|
175
176
|
deviceData.Scenes = devicesData.Scenes ?? [];
|
|
176
|
-
await this.updateState(deviceData);
|
|
177
|
+
await this.updateState('request', deviceData);
|
|
177
178
|
|
|
178
179
|
return true;
|
|
179
180
|
} catch (error) {
|
package/src/melcloudhome.js
CHANGED