homebridge-melcloud-control 2.5.0-beta.21 → 2.5.0-beta.23
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/public/index.html +1 -5
- package/homebridge-ui/server.js +1 -3
- package/package.json +1 -1
- package/src/melcloud.js +16 -18
|
@@ -107,16 +107,12 @@
|
|
|
107
107
|
const user = pluginConfig[0].accounts[this.deviceIndex].user;
|
|
108
108
|
const passwd = pluginConfig[0].accounts[this.deviceIndex].passwd;
|
|
109
109
|
const language = pluginConfig[0].accounts[this.deviceIndex].language;
|
|
110
|
-
const enableDebugMode = pluginConfig[0].accounts[this.deviceIndex].enableDebugMode;
|
|
111
|
-
const refreshInterval = pluginConfig[0].accounts[this.deviceIndex].refreshInterval;
|
|
112
110
|
|
|
113
111
|
const payload = {
|
|
114
112
|
accountName: accountName,
|
|
115
113
|
user: user,
|
|
116
114
|
passwd: passwd,
|
|
117
|
-
language: language
|
|
118
|
-
enableDebugMode: enableDebugMode,
|
|
119
|
-
refreshInterval: refreshInterval
|
|
115
|
+
language: language
|
|
120
116
|
};
|
|
121
117
|
const response = await homebridge.request('/connect', payload);
|
|
122
118
|
const info = response.info ?? '';
|
package/homebridge-ui/server.js
CHANGED
|
@@ -19,15 +19,13 @@ class PluginUiServer extends HomebridgePluginUiServer {
|
|
|
19
19
|
const user = payload.user;
|
|
20
20
|
const passwd = payload.passwd;
|
|
21
21
|
const language = payload.language;
|
|
22
|
-
const enableDebugMode = payload.enableDebugMode;
|
|
23
|
-
const refreshInterval = payload.refreshInterval;
|
|
24
22
|
const accountInfoFile = `${this.homebridgeStoragePath}/melcloud/${accountName}_Account`;
|
|
25
23
|
const deviceInfoFile = `${this.homebridgeStoragePath}/melcloud/${accountName}_Device_`;
|
|
26
24
|
const buildingsFile = `${this.homebridgeStoragePath}/melcloud/${accountName}_Buildings`;
|
|
27
25
|
|
|
28
26
|
try {
|
|
29
27
|
let data = {};
|
|
30
|
-
const melCloud = new MelCloud(user, passwd, language, accountInfoFile, deviceInfoFile, buildingsFile,
|
|
28
|
+
const melCloud = new MelCloud(user, passwd, language, accountInfoFile, deviceInfoFile, buildingsFile, false, 0, true);
|
|
31
29
|
const contextKey = await melCloud.connect();
|
|
32
30
|
const devices = await melCloud.chackDevicesList(contextKey);
|
|
33
31
|
return data = {
|
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.23",
|
|
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
|
@@ -10,12 +10,13 @@ const CONSTANTS = require('./constants.json');
|
|
|
10
10
|
class MelCloud extends EventEmitter {
|
|
11
11
|
constructor(user, passwd, language, accountInfoFile, deviceInfoFile, buildingsFile, enableDebugMode, refreshInterval, connectForConfig) {
|
|
12
12
|
super();
|
|
13
|
-
this.enableDebugMode = enableDebugMode;
|
|
14
13
|
this.accountInfoFile = accountInfoFile;
|
|
15
14
|
this.buildingsFile = buildingsFile;
|
|
16
15
|
this.deviceInfoFile = deviceInfoFile;
|
|
16
|
+
this.enableDebugMode = enableDebugMode;
|
|
17
17
|
this.refreshInterval = refreshInterval;
|
|
18
18
|
this.connectForConfig = connectForConfig;
|
|
19
|
+
this.contextKey = '';
|
|
19
20
|
this.devicesId = [];
|
|
20
21
|
|
|
21
22
|
this.options = {
|
|
@@ -30,16 +31,16 @@ class MelCloud extends EventEmitter {
|
|
|
30
31
|
}
|
|
31
32
|
};
|
|
32
33
|
|
|
33
|
-
this.impulseGenerator = new ImpulseGenerator();
|
|
34
|
-
this.impulseGenerator.on('checkDevicesList', async () => {
|
|
35
|
-
try {
|
|
36
|
-
await this.chackDevicesList();
|
|
37
|
-
} catch (error) {
|
|
38
|
-
this.emit('error', `Check devices list: ${error}.`);
|
|
39
|
-
};
|
|
40
|
-
}).on('state', (state) => { });
|
|
41
|
-
|
|
42
34
|
if (!connectForConfig) {
|
|
35
|
+
this.impulseGenerator = new ImpulseGenerator();
|
|
36
|
+
this.impulseGenerator.on('checkDevicesList', async () => {
|
|
37
|
+
try {
|
|
38
|
+
await this.chackDevicesList(this.contextKey);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
this.emit('error', `Check devices list: ${error}.`);
|
|
41
|
+
};
|
|
42
|
+
}).on('state', (state) => { });
|
|
43
|
+
|
|
43
44
|
this.connect();
|
|
44
45
|
};
|
|
45
46
|
};
|
|
@@ -81,18 +82,17 @@ class MelCloud extends EventEmitter {
|
|
|
81
82
|
this.emit('warn', `Context key: ${contextKey}, missing.`)
|
|
82
83
|
return;
|
|
83
84
|
};
|
|
84
|
-
|
|
85
85
|
this.accountInfo = accountInfo;
|
|
86
86
|
this.contextKey = contextKey;
|
|
87
87
|
|
|
88
|
-
//save melcloud info to the file
|
|
89
|
-
await this.saveData(this.accountInfoFile, accountInfo);
|
|
90
|
-
|
|
91
88
|
//return if connect for config
|
|
92
89
|
if (this.connectForConfig) {
|
|
93
90
|
return contextKey;
|
|
94
91
|
};
|
|
95
92
|
|
|
93
|
+
//save melcloud info to the file
|
|
94
|
+
await this.saveData(this.accountInfoFile, accountInfo);
|
|
95
|
+
|
|
96
96
|
//check devices list
|
|
97
97
|
await this.chackDevicesList(contextKey);
|
|
98
98
|
|
|
@@ -109,10 +109,8 @@ class MelCloud extends EventEmitter {
|
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
async chackDevicesList(
|
|
112
|
+
async chackDevicesList(contextKey) {
|
|
113
113
|
try {
|
|
114
|
-
const contextKey = this.contextKey ?? key;
|
|
115
|
-
|
|
116
114
|
//create axios instance get
|
|
117
115
|
const axiosInstanceGet = axios.create({
|
|
118
116
|
method: 'GET',
|
|
@@ -191,7 +189,7 @@ class MelCloud extends EventEmitter {
|
|
|
191
189
|
|
|
192
190
|
return true;
|
|
193
191
|
} catch (error) {
|
|
194
|
-
this.impulseGenerator.stop();
|
|
192
|
+
const stop = connectForConfig ? false : this.impulseGenerator.stop();
|
|
195
193
|
throw new Error(`Scanning for devices error: ${error.message ?? error}.`);
|
|
196
194
|
};
|
|
197
195
|
}
|