homebridge-melcloud-control 4.0.0-beta.40 → 4.0.0-beta.42
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/config.schema.json +3 -3
- package/homebridge-ui/public/index.html +3 -3
- package/index.js +4 -4
- package/package.json +1 -1
- package/src/melcloud.js +18 -30
package/config.schema.json
CHANGED
|
@@ -212,19 +212,19 @@
|
|
|
212
212
|
{
|
|
213
213
|
"title": "None/Disabled",
|
|
214
214
|
"enum": [
|
|
215
|
-
"
|
|
215
|
+
"disabled"
|
|
216
216
|
]
|
|
217
217
|
},
|
|
218
218
|
{
|
|
219
219
|
"title": "MELCLoud",
|
|
220
220
|
"enum": [
|
|
221
|
-
"
|
|
221
|
+
"melcloud"
|
|
222
222
|
]
|
|
223
223
|
},
|
|
224
224
|
{
|
|
225
225
|
"title": "MELCLoud Home",
|
|
226
226
|
"enum": [
|
|
227
|
-
"
|
|
227
|
+
"melcloudhome"
|
|
228
228
|
]
|
|
229
229
|
}
|
|
230
230
|
]
|
|
@@ -79,9 +79,9 @@
|
|
|
79
79
|
<div class="mb-2">
|
|
80
80
|
<label for="displayType" class="form-label">Account Type</label>
|
|
81
81
|
<select id="displayType" name="displayType" class="form-control">
|
|
82
|
-
<option value="
|
|
83
|
-
<option value="
|
|
84
|
-
<option value="
|
|
82
|
+
<option value="disabled">None/Disabled</option>
|
|
83
|
+
<option value="melcloud">MELCloud</option>
|
|
84
|
+
<option value="melcloudhome">MELCloud Home</option>
|
|
85
85
|
</select>
|
|
86
86
|
</div>
|
|
87
87
|
|
package/index.js
CHANGED
|
@@ -30,8 +30,8 @@ class MelCloudPlatform {
|
|
|
30
30
|
api.on('didFinishLaunching', async () => {
|
|
31
31
|
//loop through accounts
|
|
32
32
|
for (const account of config.accounts) {
|
|
33
|
-
const displayType = account.displayType ||
|
|
34
|
-
if (displayType ===
|
|
33
|
+
const displayType = account.displayType || 'disabled';
|
|
34
|
+
if (displayType === 'disabled') continue;
|
|
35
35
|
|
|
36
36
|
const accountName = account.name;
|
|
37
37
|
const user = account.user;
|
|
@@ -106,9 +106,9 @@ class MelCloudPlatform {
|
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
const accountInfo = response.accountInfo
|
|
109
|
+
const accountInfo = response.accountInfo;
|
|
110
110
|
const contextKey = response.contextKey;
|
|
111
|
-
const useFahrenheit = response.useFahrenheit
|
|
111
|
+
const useFahrenheit = response.useFahrenheit;
|
|
112
112
|
|
|
113
113
|
if (!contextKey) {
|
|
114
114
|
return;
|
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.42",
|
|
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
|
@@ -162,28 +162,15 @@ class MelCloud extends EventEmitter {
|
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
async checkMelcloudHomeDevicesList(
|
|
165
|
+
async checkMelcloudHomeDevicesList(contextKey) {
|
|
166
166
|
try {
|
|
167
|
-
const c1 = cookies.c1.trim();
|
|
168
|
-
const c2 = cookies.c2.trim();
|
|
169
|
-
|
|
170
|
-
const cookie = [
|
|
171
|
-
'__Secure-monitorandcontrol=chunks-2',
|
|
172
|
-
`__Secure-monitorandcontrolC1=${c1}`,
|
|
173
|
-
`__Secure-monitorandcontrolC2=${c2}`,
|
|
174
|
-
].join('; ');
|
|
175
|
-
|
|
176
167
|
const axiosInstance = axios.create({
|
|
168
|
+
method: 'GET',
|
|
177
169
|
baseURL: ApiUrlsHome.BaseURL,
|
|
178
|
-
timeout: 20000,
|
|
179
|
-
httpsAgent: new Agent({
|
|
180
|
-
keepAlive: false,
|
|
181
|
-
rejectUnauthorized: false
|
|
182
|
-
}),
|
|
183
170
|
headers: {
|
|
184
171
|
'Accept': '*/*',
|
|
185
172
|
'Accept-Language': 'en-US,en;q=0.9',
|
|
186
|
-
'Cookie':
|
|
173
|
+
'Cookie': contextKey,
|
|
187
174
|
'User-Agent': 'homebridge-melcloud-control/4.0.0',
|
|
188
175
|
'DNT': '1',
|
|
189
176
|
'Origin': 'https://melcloudhome.com',
|
|
@@ -192,11 +179,12 @@ class MelCloud extends EventEmitter {
|
|
|
192
179
|
'Sec-Fetch-Mode': 'cors',
|
|
193
180
|
'Sec-Fetch-Site': 'same-origin',
|
|
194
181
|
'X-CSRF': '1'
|
|
195
|
-
}
|
|
182
|
+
},
|
|
183
|
+
...this.axiosDefaults
|
|
196
184
|
});
|
|
197
185
|
|
|
198
186
|
if (this.logDebug) this.emit('debug', `Scanning for devices`);
|
|
199
|
-
const listDevicesData = await axiosInstance
|
|
187
|
+
const listDevicesData = await axiosInstance(ApiUrlsHome.GetUserContext);
|
|
200
188
|
const buildingsList = listDevicesData.data.buildings;
|
|
201
189
|
if (this.logDebug) this.emit('debug', `Buildings: ${JSON.stringify(buildingsList, null, 2)}`);
|
|
202
190
|
|
|
@@ -276,7 +264,7 @@ class MelCloud extends EventEmitter {
|
|
|
276
264
|
}
|
|
277
265
|
|
|
278
266
|
const accountInfo = {};
|
|
279
|
-
const contextKey = {
|
|
267
|
+
const contextKey = ['__Secure-monitorandcontrol=chunks-2', `__Secure-monitorandcontrolC1=${c1}`, `__Secure-monitorandcontrolC2=${c2}`,].join('; ');
|
|
280
268
|
const useFahrenheit = false;
|
|
281
269
|
this.contextKey = contextKey;
|
|
282
270
|
|
|
@@ -291,30 +279,30 @@ class MelCloud extends EventEmitter {
|
|
|
291
279
|
}
|
|
292
280
|
|
|
293
281
|
async connect() {
|
|
294
|
-
let response =
|
|
282
|
+
let response = {};
|
|
295
283
|
switch (this.displayType) {
|
|
296
|
-
case "
|
|
284
|
+
case "melcloud":
|
|
297
285
|
response = await this.connectToMelCloud();
|
|
298
286
|
return response
|
|
299
|
-
case "
|
|
287
|
+
case "melcloudhome":
|
|
300
288
|
response = await this.connectToMelCloudHome();
|
|
301
289
|
return response
|
|
302
290
|
default:
|
|
303
|
-
return
|
|
291
|
+
return response
|
|
304
292
|
}
|
|
305
293
|
}
|
|
306
294
|
|
|
307
|
-
async checkDevicesList(
|
|
308
|
-
let devices =
|
|
295
|
+
async checkDevicesList(contextKey) {
|
|
296
|
+
let devices = [];
|
|
309
297
|
switch (this.displayType) {
|
|
310
|
-
case "
|
|
311
|
-
devices = await this.checkMelcloudDevicesList(
|
|
298
|
+
case "melcloud":
|
|
299
|
+
devices = await this.checkMelcloudDevicesList(contextKey);
|
|
312
300
|
return devices
|
|
313
|
-
case "
|
|
314
|
-
devices = await this.checkMelcloudHomeDevicesList(
|
|
301
|
+
case "melcloudhome":
|
|
302
|
+
devices = await this.checkMelcloudHomeDevicesList(contextKey);
|
|
315
303
|
return devices
|
|
316
304
|
default:
|
|
317
|
-
return
|
|
305
|
+
return devices;
|
|
318
306
|
}
|
|
319
307
|
}
|
|
320
308
|
|