homebridge-melcloud-control 4.3.5-beta.15 → 4.3.5-beta.17
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/index.js +1 -1
- package/package.json +1 -1
- package/src/deviceata.js +1 -1
- package/src/melcloudata.js +56 -66
- package/src/melcloudhome.js +3 -1
package/index.js
CHANGED
|
@@ -93,7 +93,7 @@ class MelCloudPlatform {
|
|
|
93
93
|
melcloud = new MelCloud(account, accountFile, buildingsFile, devicesFile, true);
|
|
94
94
|
break;
|
|
95
95
|
case 'melcloudhome':
|
|
96
|
-
timmers = [{ name: 'connect', sampling: 3300000 }, { name: 'checkDevicesList', sampling:
|
|
96
|
+
timmers = [{ name: 'connect', sampling: 3300000 }, { name: 'checkDevicesList', sampling: 3000 }];
|
|
97
97
|
melcloud = new MelCloudHome(account, accountFile, buildingsFile, devicesFile, true);
|
|
98
98
|
break;
|
|
99
99
|
default:
|
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.5-beta.
|
|
4
|
+
"version": "4.3.5-beta.17",
|
|
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
|
@@ -1878,7 +1878,7 @@ class DeviceAta extends EventEmitter {
|
|
|
1878
1878
|
if (this.restFul.enable || this.mqtt.enable) await this.externalIntegrations();
|
|
1879
1879
|
|
|
1880
1880
|
//prepare accessory
|
|
1881
|
-
await new Promise(r => setTimeout(r,
|
|
1881
|
+
await new Promise(r => setTimeout(r, 5000));
|
|
1882
1882
|
const accessory = await this.prepareAccessory();
|
|
1883
1883
|
return accessory;
|
|
1884
1884
|
} catch (error) {
|
package/src/melcloudata.js
CHANGED
|
@@ -25,86 +25,76 @@ class MelCloudAta extends EventEmitter {
|
|
|
25
25
|
//set default values
|
|
26
26
|
this.deviceData = {};
|
|
27
27
|
this.headers = {};
|
|
28
|
-
this.
|
|
28
|
+
this.firstRun = true;
|
|
29
29
|
|
|
30
30
|
let deviceData = null;
|
|
31
31
|
melcloud.on('devicesList', async (devicesData) => {
|
|
32
32
|
this.headers = devicesData.Headers;
|
|
33
|
-
const webSocket = devicesData.WebSocket;
|
|
34
33
|
deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
|
|
35
34
|
if (!deviceData) return;
|
|
36
35
|
deviceData.Scenes = devicesData.Scenes ?? [];
|
|
37
36
|
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
//update state
|
|
38
|
+
await this.updateState(deviceData);
|
|
39
|
+
})
|
|
40
|
+
.on('webSocket', async (parsedMessage) => {
|
|
41
41
|
try {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
//update holiday mode
|
|
65
|
-
if (key === 'HolidayMode') {
|
|
66
|
-
deviceData.HolidayMode.Enabled = value;
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
42
|
+
const messageData = parsedMessage?.[0]?.Data;
|
|
43
|
+
if (!messageData || !deviceData) return;
|
|
44
|
+
|
|
45
|
+
let updateState = false;
|
|
46
|
+
const unitId = messageData?.id;
|
|
47
|
+
switch (unitId) {
|
|
48
|
+
case this.deviceId:
|
|
49
|
+
if (!this.logDebug) this.emit('debug', `Incoming message: ${stringifyMessage}`);
|
|
50
|
+
const messageType = parsedMessage[0].messageType;
|
|
51
|
+
const settings = this.functions.parseArrayNameValue(messageData.settings);
|
|
52
|
+
switch (messageType) {
|
|
53
|
+
case 'unitStateChanged':
|
|
54
|
+
|
|
55
|
+
//update values
|
|
56
|
+
for (const [key, value] of Object.entries(settings)) {
|
|
57
|
+
if (!this.functions.isValidValue(value)) continue;
|
|
58
|
+
|
|
59
|
+
//update holiday mode
|
|
60
|
+
if (key === 'HolidayMode') {
|
|
61
|
+
deviceData.HolidayMode.Enabled = value;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
69
64
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
65
|
+
//update device settings
|
|
66
|
+
if (key in deviceData.Device) {
|
|
67
|
+
deviceData.Device[key] = value;
|
|
74
68
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
69
|
+
}
|
|
70
|
+
updateState = true;
|
|
71
|
+
break;
|
|
72
|
+
case 'unitHolidayModeTriggered':
|
|
73
|
+
deviceData.Device.Power = settings.Power;
|
|
74
|
+
deviceData.HolidayMode.Enabled = settings.HolidayMode;
|
|
75
|
+
deviceData.HolidayMode.Active = messageData.active;
|
|
76
|
+
updateState = true;
|
|
77
|
+
break;
|
|
78
|
+
case 'unitWifiSignalChanged':
|
|
79
|
+
deviceData.Rssi = messageData.rssi;
|
|
80
|
+
updateState = true;
|
|
81
|
+
break;
|
|
82
|
+
default:
|
|
83
|
+
if (this.logDebug) this.emit('debug', `Unit ${unitId}, received unknown message type: ${stringifyMessage}`);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
break;
|
|
87
|
+
default:
|
|
88
|
+
if (this.logDebug) this.emit('debug', `Incoming unknown unit id: ${stringifyMessage}`);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
96
91
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
});
|
|
92
|
+
//update state
|
|
93
|
+
if (updateState) await this.updateState(deviceData);
|
|
100
94
|
} catch (error) {
|
|
101
|
-
if (this.logError) this.emit('error', `
|
|
95
|
+
if (this.logError) this.emit('error', `Web socket process message error: ${error}`);
|
|
102
96
|
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
//update state
|
|
106
|
-
await this.updateState(deviceData);
|
|
107
|
-
});
|
|
97
|
+
});
|
|
108
98
|
}
|
|
109
99
|
|
|
110
100
|
async updateState(deviceData) {
|
package/src/melcloudhome.js
CHANGED
|
@@ -254,6 +254,9 @@ class MelCloudHome extends EventEmitter {
|
|
|
254
254
|
const parsedMessage = JSON.parse(message);
|
|
255
255
|
const stringifyMessage = JSON.stringify(parsedMessage, null, 2);
|
|
256
256
|
if (this.logDebug) this.emit('debug', `Incoming message: ${stringifyMessage}`);
|
|
257
|
+
if (parsedMessage.message === 'Forbidden') return;
|
|
258
|
+
|
|
259
|
+
this.emit('webSocket', parsedMessage);
|
|
257
260
|
});
|
|
258
261
|
} catch (error) {
|
|
259
262
|
if (this.logError) this.emit('error', `Socket connection failed: ${error}`);
|
|
@@ -266,7 +269,6 @@ class MelCloudHome extends EventEmitter {
|
|
|
266
269
|
devicesList.Devices = devices;
|
|
267
270
|
devicesList.Scenes = scenes;
|
|
268
271
|
devicesList.Headers = this.headers;
|
|
269
|
-
devicesList.WebSocket = this.socket;
|
|
270
272
|
this.emit('devicesList', devicesList);
|
|
271
273
|
|
|
272
274
|
await this.functions.saveData(this.devicesFile, devicesList);
|