homebridge-melcloud-control 2.5.0-beta.15 → 2.5.0-beta.17
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 +0 -16
- package/homebridge-ui/server.js +11 -40
- package/package.json +1 -1
- package/src/melcloud.js +15 -12
|
@@ -137,22 +137,6 @@
|
|
|
137
137
|
await homebridge.savePluginConfig(pluginConfig);
|
|
138
138
|
break;
|
|
139
139
|
case 1:
|
|
140
|
-
document.getElementById('info').innerHTML = info;
|
|
141
|
-
document.getElementById('info').style.color = 'green';
|
|
142
|
-
break;
|
|
143
|
-
case 2:
|
|
144
|
-
document.getElementById('info').innerHTML = info;
|
|
145
|
-
document.getElementById('info').style.color = 'white';
|
|
146
|
-
break;
|
|
147
|
-
case 3:
|
|
148
|
-
document.getElementById('info').innerHTML = info;
|
|
149
|
-
document.getElementById('info').style.color = 'gray';
|
|
150
|
-
break;
|
|
151
|
-
case 4:
|
|
152
|
-
document.getElementById('info').innerHTML = info;
|
|
153
|
-
document.getElementById('info').style.color = 'yellow';
|
|
154
|
-
break;
|
|
155
|
-
case 5:
|
|
156
140
|
document.getElementById('info').innerHTML = info;
|
|
157
141
|
document.getElementById('info').style.color = 'red';
|
|
158
142
|
break;
|
package/homebridge-ui/server.js
CHANGED
|
@@ -25,50 +25,21 @@ class PluginUiServer extends HomebridgePluginUiServer {
|
|
|
25
25
|
const deviceInfoFile = `${this.homebridgeStoragePath}/melcloud/${accountName}_Device_`;
|
|
26
26
|
const buildingsFile = `${this.homebridgeStoragePath}/melcloud/${accountName}_Buildings`;
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
try {
|
|
29
|
+
let data = {};
|
|
30
|
+
const melCloud = new MelCloud(user, passwd, language, accountInfoFile, deviceInfoFile, buildingsFile, enableDebugMode, refreshInterval, true);
|
|
31
|
+
const devices = melCloud.chackDevicesList();
|
|
32
|
+
return data = {
|
|
32
33
|
info: 'Check devices list complete.',
|
|
33
34
|
status: 0,
|
|
34
35
|
data: devices
|
|
35
36
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
return data;
|
|
44
|
-
})
|
|
45
|
-
.on('message', (message) => {
|
|
46
|
-
data = {
|
|
47
|
-
info: message,
|
|
48
|
-
status: 2
|
|
49
|
-
};
|
|
50
|
-
return data;
|
|
51
|
-
})
|
|
52
|
-
.on('debug', (debug) => {
|
|
53
|
-
data = {
|
|
54
|
-
info: debug,
|
|
55
|
-
status: 3
|
|
56
|
-
};
|
|
57
|
-
return data;
|
|
58
|
-
})
|
|
59
|
-
.on('warn', (warn) => {
|
|
60
|
-
return data = {
|
|
61
|
-
info: warn,
|
|
62
|
-
status: 4
|
|
63
|
-
};
|
|
64
|
-
})
|
|
65
|
-
.on('error', async (error) => {
|
|
66
|
-
data = {
|
|
67
|
-
info: error,
|
|
68
|
-
status: 5
|
|
69
|
-
};
|
|
70
|
-
return data;
|
|
71
|
-
});
|
|
37
|
+
} catch (error) {
|
|
38
|
+
return data = {
|
|
39
|
+
info: error,
|
|
40
|
+
status: 1
|
|
41
|
+
};
|
|
42
|
+
};
|
|
72
43
|
};
|
|
73
44
|
};
|
|
74
45
|
|
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.17",
|
|
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
|
@@ -121,17 +121,21 @@ class MelCloud extends EventEmitter {
|
|
|
121
121
|
//save melcloud info to the file
|
|
122
122
|
await this.saveData(this.accountInfoFile, accountInfo);
|
|
123
123
|
|
|
124
|
-
//
|
|
125
|
-
|
|
124
|
+
//return if connect for config
|
|
125
|
+
if (!this.connectForConfig) {
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
//check devices list
|
|
128
|
+
await this.chackDevicesList();
|
|
129
129
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const startImpulseGenerator = this.connectForConfig ? false : this.impulseGenerator.start(timers);
|
|
130
|
+
//emit connect success
|
|
131
|
+
this.emit('success', `Connect to MELCloud Success.`)
|
|
133
132
|
|
|
134
|
-
|
|
133
|
+
//start impulse generator
|
|
134
|
+
const timers = [{ name: 'checkDevicesList', sampling: this.refreshInterval }];
|
|
135
|
+
this.impulseGenerator.start(timers);
|
|
136
|
+
|
|
137
|
+
return true;
|
|
138
|
+
};
|
|
135
139
|
} catch (error) {
|
|
136
140
|
this.emit('error', `Connect to MELCloud error: ${error.message ?? error}.`);
|
|
137
141
|
};
|
|
@@ -176,11 +180,10 @@ class MelCloud extends EventEmitter {
|
|
|
176
180
|
}
|
|
177
181
|
const debug3 = this.enableDebugMode ? this.emit('debug', `Found: ${devicesCount} devices.`) : false;
|
|
178
182
|
|
|
179
|
-
//
|
|
180
|
-
this.emit('devicesList', devices);
|
|
183
|
+
//return devices list for config
|
|
181
184
|
if (this.connectForConfig) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
185
|
+
return devices;
|
|
186
|
+
};
|
|
184
187
|
|
|
185
188
|
//get device info fom devices
|
|
186
189
|
for (const deviceInfo of devices) {
|