homebridge-melcloud-control 2.5.0-beta.78 → 2.5.0-beta.79
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 +17 -15
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "2.5.0-beta.
|
|
4
|
+
"version": "2.5.0-beta.79",
|
|
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
|
@@ -8,15 +8,15 @@ const ImpulseGenerator = require('./impulsegenerator.js');
|
|
|
8
8
|
const CONSTANTS = require('./constants.json');
|
|
9
9
|
|
|
10
10
|
class MelCloud extends EventEmitter {
|
|
11
|
-
constructor(user, passwd, language, accountInfoFile, deviceInfoFile, buildingsFile, enableDebugMode, refreshInterval,
|
|
11
|
+
constructor(user, passwd, language, accountInfoFile, deviceInfoFile, buildingsFile, enableDebugMode, refreshInterval, requestConfig) {
|
|
12
12
|
super();
|
|
13
13
|
this.accountInfoFile = accountInfoFile;
|
|
14
14
|
this.buildingsFile = buildingsFile;
|
|
15
15
|
this.deviceInfoFile = deviceInfoFile;
|
|
16
16
|
this.enableDebugMode = enableDebugMode;
|
|
17
17
|
this.refreshInterval = refreshInterval;
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
18
|
+
this.requestConfig = requestConfig;
|
|
19
|
+
this.emitData = true;
|
|
20
20
|
this.contextKey = '';
|
|
21
21
|
this.devicesId = [];
|
|
22
22
|
|
|
@@ -32,7 +32,7 @@ class MelCloud extends EventEmitter {
|
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
if (!
|
|
35
|
+
if (!requestConfig) {
|
|
36
36
|
this.impulseGenerator = new ImpulseGenerator();
|
|
37
37
|
this.impulseGenerator.on('checkDevicesList', async () => {
|
|
38
38
|
try {
|
|
@@ -86,14 +86,14 @@ class MelCloud extends EventEmitter {
|
|
|
86
86
|
this.accountInfo = accountInfo;
|
|
87
87
|
this.contextKey = contextKey;
|
|
88
88
|
|
|
89
|
+
//save melcloud info to the file
|
|
90
|
+
await this.saveData(this.accountInfoFile, accountInfo);
|
|
91
|
+
|
|
89
92
|
//return if connect for config
|
|
90
|
-
if (this.
|
|
93
|
+
if (this.requestConfig) {
|
|
91
94
|
return contextKey;
|
|
92
95
|
};
|
|
93
96
|
|
|
94
|
-
//save melcloud info to the file
|
|
95
|
-
await this.saveData(this.accountInfoFile, accountInfo);
|
|
96
|
-
|
|
97
97
|
//check devices list
|
|
98
98
|
await this.chackDevicesList(contextKey);
|
|
99
99
|
|
|
@@ -166,11 +166,6 @@ class MelCloud extends EventEmitter {
|
|
|
166
166
|
}
|
|
167
167
|
const debug3 = this.enableDebugMode ? this.emit('debug', `Found: ${devicesCount} devices.`) : false;
|
|
168
168
|
|
|
169
|
-
//return devices list for config
|
|
170
|
-
if (this.connectForConfig) {
|
|
171
|
-
return devices;
|
|
172
|
-
};
|
|
173
|
-
|
|
174
169
|
//get device info fom devices
|
|
175
170
|
for (const deviceInfo of devices) {
|
|
176
171
|
const deviceId = deviceInfo.DeviceID
|
|
@@ -182,9 +177,16 @@ class MelCloud extends EventEmitter {
|
|
|
182
177
|
const debug = this.enableDebugMode ? this.emit('debug', `Device: ${deviceName} info saved.`) : false;
|
|
183
178
|
};
|
|
184
179
|
|
|
180
|
+
//return devices list for config
|
|
181
|
+
if (this.requestConfig) {
|
|
182
|
+
return devices;
|
|
183
|
+
};
|
|
184
|
+
|
|
185
185
|
//emit check devices list complete
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
if (!this.requestConfig && this.emitData) {
|
|
187
|
+
this.emit('checkDevicesListComplete', this.accountInfo, contextKey)
|
|
188
|
+
this.emitData = false;
|
|
189
|
+
};
|
|
188
190
|
|
|
189
191
|
return true;
|
|
190
192
|
} catch (error) {
|