homebridge-melcloud-control 4.4.1-beta.2 → 4.4.1-beta.4
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/index.js +31 -31
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -31,12 +31,12 @@ class MelCloudPlatform {
|
|
|
31
31
|
api.on('didFinishLaunching', async () => {
|
|
32
32
|
//loop through accounts
|
|
33
33
|
for (const account of config.accounts) {
|
|
34
|
-
const {
|
|
35
|
-
if (!
|
|
36
|
-
log.warn(`Account ${!
|
|
34
|
+
const { name, user, passwd, language, type } = account;
|
|
35
|
+
if (!name || accountsName.includes(name) || !user || !passwd || !language || !type) {
|
|
36
|
+
log.warn(`Account ${!name ? 'name missing' : (accountsName.includes(name) ? 'name duplicated' : name)} ${!user ? ', user missing' : ''}${!passwd ? ', password missing' : ''}${!language ? ', language missing' : ''}${!type ? ', type disabled' : ''} in config, will not be published in the Home app`);
|
|
37
37
|
continue;
|
|
38
38
|
}
|
|
39
|
-
accountsName.push(
|
|
39
|
+
accountsName.push(name);
|
|
40
40
|
const accountRefreshInterval = (account.refreshInterval ?? 120) * 1000
|
|
41
41
|
|
|
42
42
|
//log config
|
|
@@ -50,7 +50,7 @@ class MelCloudPlatform {
|
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
if (logLevel.debug) {
|
|
53
|
-
log.info(`${
|
|
53
|
+
log.info(`${name}, debug: did finish launching.`);
|
|
54
54
|
const safeConfig = {
|
|
55
55
|
...account,
|
|
56
56
|
passwd: 'removed',
|
|
@@ -61,12 +61,12 @@ class MelCloudPlatform {
|
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
};
|
|
64
|
-
log.info(`${
|
|
64
|
+
log.info(`${name}, Config: ${JSON.stringify(safeConfig, null, 2)}`);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
//define directory and file paths
|
|
68
|
-
const accountFile = `${prefDir}/${
|
|
69
|
-
const buildingsFile = `${prefDir}/${
|
|
68
|
+
const accountFile = `${prefDir}/${name}_Account`;
|
|
69
|
+
const buildingsFile = `${prefDir}/${name}_Buildings`;
|
|
70
70
|
|
|
71
71
|
try {
|
|
72
72
|
//create impulse generator
|
|
@@ -89,24 +89,24 @@ class MelCloudPlatform {
|
|
|
89
89
|
if (logLevel.warn) log.warn(`Unknown account type: ${account.type}.`);
|
|
90
90
|
return;
|
|
91
91
|
}
|
|
92
|
-
melcloud.on('success', (msg) => log.success(`${
|
|
93
|
-
.on('info', (msg) => log.info(`${
|
|
94
|
-
.on('debug', (msg) => log.info(`${
|
|
95
|
-
.on('warn', (msg) => log.warn(`${
|
|
96
|
-
.on('error', (msg) => log.error(`${
|
|
92
|
+
melcloud.on('success', (msg) => log.success(`${name}, ${msg}`))
|
|
93
|
+
.on('info', (msg) => log.info(`${name}, ${msg}`))
|
|
94
|
+
.on('debug', (msg) => log.info(`${name}, debug: ${msg}`))
|
|
95
|
+
.on('warn', (msg) => log.warn(`${name}, ${msg}`))
|
|
96
|
+
.on('error', (msg) => log.error(`${name}, ${msg}`));
|
|
97
97
|
|
|
98
98
|
//connect
|
|
99
99
|
const accountInfo = await melcloud.connect();
|
|
100
100
|
if (!accountInfo?.State) {
|
|
101
|
-
if (logLevel.warn) log.warn(`${
|
|
101
|
+
if (logLevel.warn) log.warn(`${name}, ${accountInfo?.Info}`);
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
|
-
if (logLevel.success) log.success(`${
|
|
104
|
+
if (logLevel.success) log.success(`${name}, ${accountInfo.Info}`);
|
|
105
105
|
|
|
106
106
|
//check devices list
|
|
107
107
|
const melcloudDevicesList = await melcloud.checkDevicesList();
|
|
108
108
|
if (!melcloudDevicesList.State) {
|
|
109
|
-
if (logLevel.warn) log.warn(`${
|
|
109
|
+
if (logLevel.warn) log.warn(`${name}, ${melcloudDevicesList.Info}`);
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
112
112
|
if (logLevel.debug) log.info(melcloudDevicesList.Info);
|
|
@@ -120,26 +120,26 @@ class MelCloudPlatform {
|
|
|
120
120
|
const atwDevices = (account.atwDevices || []).filter(device => device.id != null && String(device.id) !== '0');
|
|
121
121
|
const ervDevices = (account.ervDevices || []).filter(device => device.id != null && String(device.id) !== '0');
|
|
122
122
|
const devices = [...ataDevices, ...atwDevices, ...ervDevices];
|
|
123
|
-
if (logLevel.debug) log.info(`${
|
|
123
|
+
if (logLevel.debug) log.info(`${name}, found configured devices ATA: ${ataDevices.length}, ATW: ${atwDevices.length}, ERV: ${ervDevices.length}.`);
|
|
124
124
|
|
|
125
125
|
for (const [index, device] of devices.entries()) {
|
|
126
126
|
device.id = String(device.id);
|
|
127
127
|
const deviceName = device.name;
|
|
128
128
|
const deviceType = device.type;
|
|
129
129
|
const deviceTypeString = device.typeString;
|
|
130
|
-
const defaultTempsFile = `${prefDir}/${
|
|
130
|
+
const defaultTempsFile = `${prefDir}/${name}_${device.id}_Temps`;
|
|
131
131
|
|
|
132
132
|
//chack device is not disabled in config
|
|
133
133
|
const displayType = device.displayType;
|
|
134
134
|
if (!displayType) {
|
|
135
|
-
if (logLevel.warn) log.warn(`${
|
|
135
|
+
if (logLevel.warn) log.warn(`${name}, ${deviceTypeString}, ${deviceName}, disabled in configuration, will not be published in the Home app.`);
|
|
136
136
|
continue;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
//chack device from config exist on melcloud
|
|
140
140
|
const deviceExistInMelCloud = melcloudDevicesList.Devices.some(dev => dev.DeviceID === device.id);
|
|
141
141
|
if (!deviceExistInMelCloud) {
|
|
142
|
-
if (logLevel.warn) log.warn(`${
|
|
142
|
+
if (logLevel.warn) log.warn(`${name}, ${deviceTypeString}, ${deviceName}, not exist on server, please login to MELCLoud from plugin UI to fix this issue.`);
|
|
143
143
|
continue;
|
|
144
144
|
}
|
|
145
145
|
|
|
@@ -160,7 +160,7 @@ class MelCloudPlatform {
|
|
|
160
160
|
if (logLevel.debug) log.debug(`Default temperature file created: ${defaultTempsFile}`);
|
|
161
161
|
}
|
|
162
162
|
} catch (error) {
|
|
163
|
-
if (logLevel.error) log.error(`${
|
|
163
|
+
if (logLevel.error) log.error(`${name}, ${deviceTypeString}, ${deviceName}, File init error: ${error.message}`);
|
|
164
164
|
continue;
|
|
165
165
|
}
|
|
166
166
|
}
|
|
@@ -179,37 +179,37 @@ class MelCloudPlatform {
|
|
|
179
179
|
configuredDevice = new DeviceErv(api, account, device, defaultTempsFile, accountInfo, accountFile, melcloud, melcloudDevicesList);
|
|
180
180
|
break;
|
|
181
181
|
default:
|
|
182
|
-
if (logLevel.warn) log.warn(`${
|
|
182
|
+
if (logLevel.warn) log.warn(`${name}, ${deviceTypeString}, ${deviceName}, unknown device: ${deviceType}.`);
|
|
183
183
|
return;
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
configuredDevice.on('devInfo', (info) => logLevel.devInfo && log.info(info))
|
|
187
|
-
.on('success', (msg) => log.success(`${
|
|
188
|
-
.on('info', (msg) => log.info(`${
|
|
189
|
-
.on('debug', (msg) => log.info(`${
|
|
190
|
-
.on('warn', (msg) => log.warn(`${
|
|
191
|
-
.on('error', (msg) => log.error(`${
|
|
187
|
+
.on('success', (msg) => log.success(`${name}, ${deviceTypeString}, ${deviceName}, ${msg}`))
|
|
188
|
+
.on('info', (msg) => log.info(`${name}, ${deviceTypeString}, ${deviceName}, ${msg}`))
|
|
189
|
+
.on('debug', (msg) => log.info(`${name}, ${deviceTypeString}, ${deviceName}, debug: ${msg}`))
|
|
190
|
+
.on('warn', (msg) => log.warn(`${name}, ${deviceTypeString}, ${deviceName}, ${msg}`))
|
|
191
|
+
.on('error', (msg) => log.error(`${name}, ${deviceTypeString}, ${deviceName}, ${msg}`));
|
|
192
192
|
|
|
193
193
|
const accessory = await configuredDevice.start();
|
|
194
194
|
if (accessory) {
|
|
195
195
|
api.publishExternalAccessories(PluginName, [accessory]);
|
|
196
|
-
if (logLevel.success) log.success(`${
|
|
196
|
+
if (logLevel.success) log.success(`${name}, ${deviceTypeString}, ${deviceName}, Published as external accessory.`);
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
//stop start impulse generator
|
|
201
201
|
await impulseGenerator.state(false);
|
|
202
202
|
} catch (error) {
|
|
203
|
-
if (logLevel.error) log.error(`${
|
|
203
|
+
if (logLevel.error) log.error(`${name}, Start impulse generator error, ${error.message ?? error}, trying again.`);
|
|
204
204
|
}
|
|
205
205
|
}).on('state', (state) => {
|
|
206
|
-
if (logLevel.debug) log.info(`${
|
|
206
|
+
if (logLevel.debug) log.info(`${name}, Start impulse generator ${state ? 'started' : 'stopped'}.`);
|
|
207
207
|
});
|
|
208
208
|
|
|
209
209
|
//start impulse generator
|
|
210
210
|
await impulseGenerator.state(true, [{ name: 'start', sampling: 120000 }]);
|
|
211
211
|
} catch (error) {
|
|
212
|
-
if (logLevel.error) log.error(`${
|
|
212
|
+
if (logLevel.error) log.error(`${name}, Did finish launching error: ${error.message ?? error}.`);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.4.1-beta.
|
|
4
|
+
"version": "4.4.1-beta.4",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|