homebridge-melcloud-control 2.5.0-beta.20 → 2.5.0-beta.22
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.
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
|
|
65
65
|
const accountConfigured = pluginConfig[0].accounts[i].name && pluginConfig[0].accounts[i].user && pluginConfig[0].accounts[i].passwd && pluginConfig[0].accounts[i].language;
|
|
66
66
|
const setButtonState = accountConfigured ? document.getElementById('logIn').removeAttribute('disabled') : document.getElementById('logIn').setAttribute('disabled');
|
|
67
|
+
document.getElementById('configButton').setAttribute('disabled');
|
|
67
68
|
await homebridge.updatePluginConfig(pluginConfig);
|
|
68
69
|
this.deviceIndex = i;
|
|
69
70
|
});
|
|
@@ -106,16 +107,12 @@
|
|
|
106
107
|
const user = pluginConfig[0].accounts[this.deviceIndex].user;
|
|
107
108
|
const passwd = pluginConfig[0].accounts[this.deviceIndex].passwd;
|
|
108
109
|
const language = pluginConfig[0].accounts[this.deviceIndex].language;
|
|
109
|
-
const enableDebugMode = pluginConfig[0].accounts[this.deviceIndex].enableDebugMode;
|
|
110
|
-
const refreshInterval = pluginConfig[0].accounts[this.deviceIndex].refreshInterval;
|
|
111
110
|
|
|
112
111
|
const payload = {
|
|
113
112
|
accountName: accountName,
|
|
114
113
|
user: user,
|
|
115
114
|
passwd: passwd,
|
|
116
|
-
language: language
|
|
117
|
-
enableDebugMode: enableDebugMode,
|
|
118
|
-
refreshInterval: refreshInterval
|
|
115
|
+
language: language
|
|
119
116
|
};
|
|
120
117
|
const response = await homebridge.request('/connect', payload);
|
|
121
118
|
const info = response.info ?? '';
|
|
@@ -131,8 +128,9 @@
|
|
|
131
128
|
};
|
|
132
129
|
|
|
133
130
|
const devicesCount = devices.length;
|
|
134
|
-
document.getElementById('info').innerHTML =
|
|
131
|
+
document.getElementById('info').innerHTML = `Success, found ${devicesCount} ${devicesCount !== 1 ? 'devices' : 'device'}. Now You can start to configure it.`;
|
|
135
132
|
document.getElementById('info').style.color = 'green';
|
|
133
|
+
document.getElementById('configButton').removeAttribute('disabled');
|
|
136
134
|
await homebridge.updatePluginConfig(pluginConfig);
|
|
137
135
|
await homebridge.savePluginConfig(pluginConfig);
|
|
138
136
|
break;
|
package/homebridge-ui/server.js
CHANGED
|
@@ -19,19 +19,17 @@ 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 = {
|
|
34
|
-
info: '
|
|
32
|
+
info: '',
|
|
35
33
|
status: 0,
|
|
36
34
|
data: devices
|
|
37
35
|
};
|
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.22",
|
|
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 = {
|
|
@@ -33,7 +34,7 @@ class MelCloud extends EventEmitter {
|
|
|
33
34
|
this.impulseGenerator = new ImpulseGenerator();
|
|
34
35
|
this.impulseGenerator.on('checkDevicesList', async () => {
|
|
35
36
|
try {
|
|
36
|
-
await this.chackDevicesList();
|
|
37
|
+
await this.chackDevicesList(this.contextKey);
|
|
37
38
|
} catch (error) {
|
|
38
39
|
this.emit('error', `Check devices list: ${error}.`);
|
|
39
40
|
};
|
|
@@ -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',
|