homebridge-melcloud-control 4.0.0-beta.416 → 4.0.0-beta.418
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/melcloud.js +22 -27
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.418",
|
|
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
|
@@ -25,19 +25,8 @@ class MelCloud extends EventEmitter {
|
|
|
25
25
|
this.devicesId = [];
|
|
26
26
|
this.contextKey = '';
|
|
27
27
|
this.functions = new Functions();
|
|
28
|
-
|
|
29
28
|
this.tokens = null;
|
|
30
29
|
|
|
31
|
-
this.loginData = {
|
|
32
|
-
Email: user,
|
|
33
|
-
Password: passwd,
|
|
34
|
-
Language: language,
|
|
35
|
-
AppVersion: '1.34.12',
|
|
36
|
-
CaptchaChallenge: '',
|
|
37
|
-
CaptchaResponse: '',
|
|
38
|
-
Persist: true
|
|
39
|
-
};
|
|
40
|
-
|
|
41
30
|
if (!requestConfig) {
|
|
42
31
|
this.impulseGenerator = new ImpulseGenerator()
|
|
43
32
|
.on('connect', async () => {
|
|
@@ -144,18 +133,26 @@ class MelCloud extends EventEmitter {
|
|
|
144
133
|
}
|
|
145
134
|
}
|
|
146
135
|
|
|
147
|
-
|
|
148
136
|
async connectToMelCloud() {
|
|
149
137
|
if (this.logDebug) this.emit('debug', `Connecting to MELCloud`);
|
|
150
138
|
|
|
151
139
|
try {
|
|
152
140
|
const axiosInstanceLogin = axios.create({
|
|
153
|
-
method: 'POST',
|
|
154
141
|
baseURL: ApiUrls.BaseURL,
|
|
155
142
|
timeout: 15000,
|
|
156
143
|
});
|
|
157
144
|
|
|
158
|
-
const
|
|
145
|
+
const loginData = {
|
|
146
|
+
Email: this.user,
|
|
147
|
+
Password: this.passwd,
|
|
148
|
+
Language: this.language,
|
|
149
|
+
AppVersion: '1.34.12',
|
|
150
|
+
CaptchaChallenge: '',
|
|
151
|
+
CaptchaResponse: '',
|
|
152
|
+
Persist: true
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const accountData = await axiosInstanceLogin.post(ApiUrls.ClientLogin, { data: loginData });
|
|
159
156
|
const account = accountData.data;
|
|
160
157
|
const accountInfo = account.LoginData;
|
|
161
158
|
const contextKey = accountInfo?.ContextKey;
|
|
@@ -177,16 +174,6 @@ class MelCloud extends EventEmitter {
|
|
|
177
174
|
return null;
|
|
178
175
|
}
|
|
179
176
|
|
|
180
|
-
this.axiosInstancePost = axios.create({
|
|
181
|
-
method: 'POST',
|
|
182
|
-
baseURL: ApiUrls.BaseURL,
|
|
183
|
-
timeout: 15000,
|
|
184
|
-
headers: {
|
|
185
|
-
'X-MitsContextKey': contextKey,
|
|
186
|
-
'content-type': 'application/json'
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
|
|
190
177
|
await this.functions.saveData(this.accountFile, accountInfo);
|
|
191
178
|
this.emit('success', `Connect to MELCloud Success`);
|
|
192
179
|
|
|
@@ -200,7 +187,6 @@ class MelCloud extends EventEmitter {
|
|
|
200
187
|
async checkMelcloudHomeDevicesList(contextKey) {
|
|
201
188
|
try {
|
|
202
189
|
const axiosInstance = axios.create({
|
|
203
|
-
method: 'GET',
|
|
204
190
|
baseURL: ApiUrlsHome.BaseURL,
|
|
205
191
|
timeout: 25000,
|
|
206
192
|
headers: {
|
|
@@ -219,7 +205,7 @@ class MelCloud extends EventEmitter {
|
|
|
219
205
|
});
|
|
220
206
|
|
|
221
207
|
if (this.logDebug) this.emit('debug', `Scanning for devices`);
|
|
222
|
-
const listDevicesData = await axiosInstance(ApiUrlsHome.GetUserContext);
|
|
208
|
+
const listDevicesData = await axiosInstance.get(ApiUrlsHome.GetUserContext);
|
|
223
209
|
const buildingsList = listDevicesData.data.buildings;
|
|
224
210
|
if (this.logDebug) this.emit('debug', `Buildings: ${JSON.stringify(buildingsList, null, 2)}`);
|
|
225
211
|
|
|
@@ -524,8 +510,17 @@ class MelCloud extends EventEmitter {
|
|
|
524
510
|
|
|
525
511
|
async send(accountInfo) {
|
|
526
512
|
try {
|
|
513
|
+
const axiosInstance = axios.create({
|
|
514
|
+
baseURL: ApiUrls.BaseURL,
|
|
515
|
+
timeout: 15000,
|
|
516
|
+
headers: {
|
|
517
|
+
'X-MitsContextKey': this.contextKey,
|
|
518
|
+
'content-type': 'application/json'
|
|
519
|
+
}
|
|
520
|
+
});
|
|
521
|
+
|
|
527
522
|
const options = { data: accountInfo };
|
|
528
|
-
await
|
|
523
|
+
await axiosInstance.post(ApiUrls.UpdateApplicationOptions, options);
|
|
529
524
|
await this.functions.saveData(this.accountFile, accountInfo);
|
|
530
525
|
return true;
|
|
531
526
|
} catch (error) {
|