homebridge-melcloud-control 4.0.0-beta.32 → 4.0.0-beta.34
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 +2 -1
- package/index.js +3 -3
- package/package.json +1 -1
- package/src/melcloud.js +9 -6
package/config.schema.json
CHANGED
package/index.js
CHANGED
|
@@ -90,7 +90,7 @@ class MelCloudPlatform {
|
|
|
90
90
|
.on('start', async () => {
|
|
91
91
|
try {
|
|
92
92
|
//melcloud account
|
|
93
|
-
const melCloud = new MelCloud(user, passwd, language, accountFile, buildingsFile, devicesFile, logLevel.warn, logLevel.debug, false)
|
|
93
|
+
const melCloud = new MelCloud(displayType, user, passwd, language, accountFile, buildingsFile, devicesFile, logLevel.warn, logLevel.debug, false)
|
|
94
94
|
.on('success', (msg) => logLevel.success && log.success(`${accountName}, ${msg}`))
|
|
95
95
|
.on('info', (msg) => logLevel.info && log.info(`${accountName}, ${msg}`))
|
|
96
96
|
.on('debug', (msg) => logLevel.debug && log.info(`${accountName}, debug: ${msg}`))
|
|
@@ -100,7 +100,7 @@ class MelCloudPlatform {
|
|
|
100
100
|
//connect
|
|
101
101
|
let response;
|
|
102
102
|
try {
|
|
103
|
-
response = await melCloud.connect(
|
|
103
|
+
response = await melCloud.connect();
|
|
104
104
|
} catch (error) {
|
|
105
105
|
if (logLevel.error) log.error(`${accountName}, Connect error: ${error.message ?? error}`);
|
|
106
106
|
return;
|
|
@@ -117,7 +117,7 @@ class MelCloudPlatform {
|
|
|
117
117
|
//check devices list
|
|
118
118
|
let devicesInMelcloud;
|
|
119
119
|
try {
|
|
120
|
-
devicesInMelcloud = await melCloud.checkDevicesList(
|
|
120
|
+
devicesInMelcloud = await melCloud.checkDevicesList(contextKey);
|
|
121
121
|
return
|
|
122
122
|
} catch (error) {
|
|
123
123
|
if (logLevel.error) log.error(`${accountName}, Check devices list 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": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.34",
|
|
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
|
@@ -7,8 +7,9 @@ import Functions from './functions.js';
|
|
|
7
7
|
import { ApiUrls, ApiUrlsHome } from './constants.js';
|
|
8
8
|
|
|
9
9
|
class MelCloud extends EventEmitter {
|
|
10
|
-
constructor(user, passwd, language, accountFile, buildingsFile, devicesFile, logWarn, logDebug, requestConfig) {
|
|
10
|
+
constructor(displayType, user, passwd, language, accountFile, buildingsFile, devicesFile, logWarn, logDebug, requestConfig) {
|
|
11
11
|
super();
|
|
12
|
+
this.displayType = displayType;
|
|
12
13
|
this.user = user;
|
|
13
14
|
this.passwd = passwd;
|
|
14
15
|
this.language = language;
|
|
@@ -275,10 +276,12 @@ class MelCloud extends EventEmitter {
|
|
|
275
276
|
if (this.logWarn) this.emit('warn', `Cookies C1/C2 missing`);
|
|
276
277
|
return null;
|
|
277
278
|
}
|
|
279
|
+
const cookies = { c1, c2 };
|
|
280
|
+
this.contextKey = cookies;
|
|
278
281
|
|
|
279
282
|
this.emit('success', `Connect to MELCloud Home Success`);
|
|
280
283
|
|
|
281
|
-
return
|
|
284
|
+
return cookies;
|
|
282
285
|
} catch (error) {
|
|
283
286
|
throw new Error(`Connect to MELCloud Home error: ${error.message}`);
|
|
284
287
|
} finally {
|
|
@@ -286,9 +289,9 @@ class MelCloud extends EventEmitter {
|
|
|
286
289
|
}
|
|
287
290
|
}
|
|
288
291
|
|
|
289
|
-
async connect(
|
|
292
|
+
async connect() {
|
|
290
293
|
let response = null;
|
|
291
|
-
switch (
|
|
294
|
+
switch (this.displayType) {
|
|
292
295
|
case 1:
|
|
293
296
|
response = await this.connectToMelCloud();
|
|
294
297
|
return response
|
|
@@ -300,9 +303,9 @@ class MelCloud extends EventEmitter {
|
|
|
300
303
|
}
|
|
301
304
|
}
|
|
302
305
|
|
|
303
|
-
async checkDevicesList(
|
|
306
|
+
async checkDevicesList(key) {
|
|
304
307
|
let devices = null;
|
|
305
|
-
switch (
|
|
308
|
+
switch (this.displayType) {
|
|
306
309
|
case 1:
|
|
307
310
|
devices = await this.checkMelcloudDevicesList(key);
|
|
308
311
|
return devices
|