homebridge-melcloud-control 3.9.8-beta.0 → 3.9.8-beta.1
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/homebridge-ui/server.js +2 -2
- package/package.json +1 -1
- package/src/melcloud.js +35 -17
package/homebridge-ui/server.js
CHANGED
|
@@ -23,8 +23,8 @@ class PluginUiServer extends HomebridgePluginUiServer {
|
|
|
23
23
|
const melCloud = new MelCloud(user, passwd, language, accountFile, buildingsFile, devicesFile, false, true);
|
|
24
24
|
|
|
25
25
|
try {
|
|
26
|
-
await melCloud.connect();
|
|
27
|
-
const devices = await melCloud.chackDevicesList();
|
|
26
|
+
const response = await melCloud.connect();
|
|
27
|
+
const devices = await melCloud.chackDevicesList(response.contextKey);
|
|
28
28
|
return devices;
|
|
29
29
|
} catch (error) {
|
|
30
30
|
throw new Error(`MELCloud error: ${error.message ?? error}.`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "3.9.8-beta.
|
|
4
|
+
"version": "3.9.8-beta.1",
|
|
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/melcloud.js
CHANGED
|
@@ -29,18 +29,6 @@ class MelCloud extends EventEmitter {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
this.axiosInstance = axios.create({
|
|
33
|
-
baseURL: ApiUrls.BaseURL,
|
|
34
|
-
timeout: 15000,
|
|
35
|
-
withCredentials: true,
|
|
36
|
-
maxContentLength: 100000000,
|
|
37
|
-
maxBodyLength: 1000000000,
|
|
38
|
-
httpsAgent: new Agent({
|
|
39
|
-
keepAlive: false,
|
|
40
|
-
rejectUnauthorized: false
|
|
41
|
-
})
|
|
42
|
-
});
|
|
43
|
-
|
|
44
32
|
if (!requestConfig) {
|
|
45
33
|
this.impulseGenerator = new ImpulseGenerator()
|
|
46
34
|
.on('checkDevicesList', async () => {
|
|
@@ -55,10 +43,27 @@ class MelCloud extends EventEmitter {
|
|
|
55
43
|
};
|
|
56
44
|
};
|
|
57
45
|
|
|
58
|
-
async chackDevicesList() {
|
|
46
|
+
async chackDevicesList(contextKey) {
|
|
59
47
|
try {
|
|
48
|
+
//create axios instance get
|
|
49
|
+
const axiosInstanceGet = axios.create({
|
|
50
|
+
method: 'GET',
|
|
51
|
+
baseURL: ApiUrls.BaseURL,
|
|
52
|
+
timeout: 10000,
|
|
53
|
+
headers: {
|
|
54
|
+
'X-MitsContextKey': contextKey
|
|
55
|
+
},
|
|
56
|
+
maxContentLength: 100000000,
|
|
57
|
+
maxBodyLength: 1000000000,
|
|
58
|
+
withCredentials: true,
|
|
59
|
+
httpsAgent: new Agent({
|
|
60
|
+
keepAlive: false,
|
|
61
|
+
rejectUnauthorized: false
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
|
|
60
65
|
if (this.enableDebugMode) this.emit('debug', `Scanning for devices`);
|
|
61
|
-
const listDevicesData = await
|
|
66
|
+
const listDevicesData = await axiosInstanceGet(ApiUrls.ListDevices);
|
|
62
67
|
const buildingsList = listDevicesData.data;
|
|
63
68
|
if (this.enableDebugMode) this.emit('debug', `Buildings: ${JSON.stringify(buildingsList, null, 2)}`);
|
|
64
69
|
|
|
@@ -107,7 +112,19 @@ class MelCloud extends EventEmitter {
|
|
|
107
112
|
if (this.enableDebugMode) this.emit('debug', `Connecting to MELCloud`);
|
|
108
113
|
|
|
109
114
|
try {
|
|
110
|
-
const
|
|
115
|
+
const axiosInstanceLogin = axios.create({
|
|
116
|
+
method: 'POST',
|
|
117
|
+
baseURL: ApiUrls.BaseURL,
|
|
118
|
+
timeout: 10000,
|
|
119
|
+
withCredentials: true,
|
|
120
|
+
maxContentLength: 100000000,
|
|
121
|
+
maxBodyLength: 1000000000,
|
|
122
|
+
httpsAgent: new Agent({
|
|
123
|
+
keepAlive: false,
|
|
124
|
+
rejectUnauthorized: false
|
|
125
|
+
})
|
|
126
|
+
});
|
|
127
|
+
const accountData = await axiosInstanceLogin(ApiUrls.ClientLogin, this.options);
|
|
111
128
|
const account = accountData.data;
|
|
112
129
|
const accountInfo = account.LoginData;
|
|
113
130
|
const contextKey = accountInfo.ContextKey;
|
|
@@ -132,7 +149,8 @@ class MelCloud extends EventEmitter {
|
|
|
132
149
|
};
|
|
133
150
|
|
|
134
151
|
//create axios instance post
|
|
135
|
-
this.
|
|
152
|
+
this.axiosInstancePost = axios.create({
|
|
153
|
+
method: 'POST',
|
|
136
154
|
baseURL: ApiUrls.BaseURL,
|
|
137
155
|
timeout: 10000,
|
|
138
156
|
headers: {
|
|
@@ -172,7 +190,7 @@ class MelCloud extends EventEmitter {
|
|
|
172
190
|
data: accountInfo
|
|
173
191
|
};
|
|
174
192
|
|
|
175
|
-
await this.
|
|
193
|
+
await this.axiosInstancePost(ApiUrls.UpdateApplicationOptions, options);
|
|
176
194
|
await this.functions.saveData(this.accountFile, accountInfo);
|
|
177
195
|
return true;
|
|
178
196
|
} catch (error) {
|