homebridge-melcloud-control 3.8.7 → 3.8.8
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 +57 -187
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -77,7 +77,7 @@ class MelCloudPlatform {
|
|
|
77
77
|
const buildingsFile = `${prefDir}/${accountName}_Buildings`;
|
|
78
78
|
const devicesFile = `${prefDir}/${accountName}_Devices`;
|
|
79
79
|
|
|
80
|
-
//set refresh interval
|
|
80
|
+
//set account refresh interval
|
|
81
81
|
const refreshInterval = account.refreshInterval * 1000 || 120000;
|
|
82
82
|
|
|
83
83
|
try {
|
|
@@ -110,185 +110,55 @@ class MelCloudPlatform {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
//check devices list
|
|
113
|
-
const
|
|
114
|
-
if (
|
|
113
|
+
const devicesInMelcloud = await melCloud.chackDevicesList(contextKey);
|
|
114
|
+
if (devicesInMelcloud === false) {
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
//start impulse generator
|
|
118
|
+
//start account impulse generator
|
|
119
119
|
await melCloud.impulseGenerator.start([{ name: 'checkDevicesList', sampling: refreshInterval }]);
|
|
120
120
|
|
|
121
|
-
//
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const emitLog = disableLogInfo ? false : log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, ${info}.`);
|
|
161
|
-
})
|
|
162
|
-
.on('debug', (debug) => {
|
|
163
|
-
const emitLog = !enableDebugMode ? false : log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, debug: ${debug}.`);
|
|
164
|
-
})
|
|
165
|
-
.on('warn', (warn) => {
|
|
166
|
-
const emitLog = disableLogWarn ? false : log.warn(`${accountName}, ${deviceTypeText}, ${deviceName}, ${warn}.`);
|
|
167
|
-
})
|
|
168
|
-
.on('error', (error) => {
|
|
169
|
-
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error}.`);
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
//create impulse generator
|
|
173
|
-
const impulseGenerator = new ImpulseGenerator();
|
|
174
|
-
impulseGenerator.on('start', async () => {
|
|
175
|
-
try {
|
|
176
|
-
const startDone = await airConditioner.start();
|
|
177
|
-
const stopImpulseGenerator = startDone ? await impulseGenerator.stop() : false;
|
|
178
|
-
|
|
179
|
-
//start impulse generator
|
|
180
|
-
const startImpulseGenerator = stopImpulseGenerator ? await airConditioner.startImpulseGenerator() : false
|
|
181
|
-
} catch (error) {
|
|
182
|
-
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error}, trying again.`);
|
|
183
|
-
};
|
|
184
|
-
}).on('state', (state) => {
|
|
185
|
-
const emitLog = !enableDebugMode ? false : state ? log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, Start impulse generator started.`) : log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, Start impulse generator stopped.`);
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
//start impulse generator
|
|
189
|
-
await impulseGenerator.start([{ name: 'start', sampling: 45000 }]);
|
|
190
|
-
};
|
|
191
|
-
} catch (error) {
|
|
192
|
-
const emitLog = disableLogError ? false : log.error(`${accountName}, ATA did finish launching error: ${error}.`);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
//Heat Pump 1
|
|
196
|
-
try {
|
|
197
|
-
const atwDevices = account.atwDevices ?? [];
|
|
198
|
-
const emitLog = !enableDebugMode ? false : log.info(`Found configured ATW devices: ${atwDevices.length}.`);
|
|
199
|
-
for (const device of atwDevices) {
|
|
200
|
-
|
|
201
|
-
//chack device from config exist on melcloud
|
|
202
|
-
const deviceId = device.id;
|
|
203
|
-
const displayMode = device.displayMode > 0;
|
|
204
|
-
const deviceExistInMelCloud = devices.some(dev => dev.DeviceID === deviceId);
|
|
205
|
-
if (!deviceExistInMelCloud || !displayMode) {
|
|
206
|
-
continue;
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
const deviceName = device.name;
|
|
210
|
-
const deviceTypeText = device.typeString;
|
|
211
|
-
const deviceRefreshInterval = device.refreshInterval * 1000 || 5000;
|
|
212
|
-
const heatPump = new DeviceAtw(api, account, device, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, deviceRefreshInterval, useFahrenheit, restFul, mqtt)
|
|
213
|
-
heatPump.on('publishAccessory', (accessory) => {
|
|
214
|
-
|
|
215
|
-
//publish device
|
|
216
|
-
api.publishExternalAccessories(PluginName, [accessory]);
|
|
217
|
-
const emitLog = disableLogSuccess ? false : log.success(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`);
|
|
218
|
-
})
|
|
219
|
-
.on('melCloud', async (key, value) => {
|
|
220
|
-
try {
|
|
221
|
-
accountInfo[key] = value;
|
|
222
|
-
await melCloud.send(accountInfo);
|
|
223
|
-
} catch (error) {
|
|
224
|
-
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error}.`);
|
|
225
|
-
};
|
|
226
|
-
})
|
|
227
|
-
.on('devInfo', (devInfo) => {
|
|
228
|
-
const emitLog = disableLogDeviceInfo ? false : log.info(devInfo);
|
|
229
|
-
})
|
|
230
|
-
.on('success', (success) => {
|
|
231
|
-
const emitLog = disableLogSuccess ? false : log.success(`${accountName}, ${deviceTypeText}, ${deviceName}, ${success}.`);
|
|
232
|
-
})
|
|
233
|
-
.on('info', (info) => {
|
|
234
|
-
const emitLog = disableLogInfo ? false : log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, ${info}.`);
|
|
235
|
-
})
|
|
236
|
-
.on('debug', (debug) => {
|
|
237
|
-
const emitLog = !enableDebugMode ? false : log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, debug: ${debug}.`);
|
|
238
|
-
})
|
|
239
|
-
.on('warn', (warn) => {
|
|
240
|
-
const emitLog = disableLogWarn ? false : log.warn(`${accountName}, ${deviceTypeText}, ${deviceName}, ${warn}.`);
|
|
241
|
-
})
|
|
242
|
-
.on('error', (error) => {
|
|
243
|
-
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error}.`);
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
//create impulse generator
|
|
247
|
-
const impulseGenerator = new ImpulseGenerator();
|
|
248
|
-
impulseGenerator.on('start', async () => {
|
|
249
|
-
try {
|
|
250
|
-
const startDone = await heatPump.start();
|
|
251
|
-
const stopImpulseGenerator = startDone ? await impulseGenerator.stop() : false;
|
|
252
|
-
|
|
253
|
-
//start impulse generator
|
|
254
|
-
const startImpulseGenerator = stopImpulseGenerator ? await heatPump.startImpulseGenerator() : false
|
|
255
|
-
} catch (error) {
|
|
256
|
-
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error}, trying again.`);
|
|
257
|
-
};
|
|
258
|
-
}).on('state', (state) => {
|
|
259
|
-
const emitLog = !enableDebugMode ? false : state ? log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, Start impulse generator started.`) : log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, Start impulse generator stopped.`);
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
//start impulse generator
|
|
263
|
-
await impulseGenerator.start([{ name: 'start', sampling: 45000 }]);
|
|
264
|
-
};
|
|
265
|
-
} catch (error) {
|
|
266
|
-
const emitLog = disableLogError ? false : log.error(`${accountName}, ATW did finish launching error: ${error}.`);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
//Energy Recovery Ventilation 3
|
|
270
|
-
try {
|
|
271
|
-
const ervDevices = account.ervDevices ?? [];
|
|
272
|
-
const emitLog = !enableDebugMode ? false : log.info(`Found configured ERV devices: ${ervDevices.length}.`);
|
|
273
|
-
for (const device of ervDevices) {
|
|
274
|
-
|
|
275
|
-
//chack device from config exist on melcloud
|
|
276
|
-
const deviceId = device.id;
|
|
277
|
-
const displayMode = device.displayMode > 0;
|
|
278
|
-
const deviceExistInMelCloud = devices.some(dev => dev.DeviceID === deviceId);
|
|
279
|
-
if (!deviceExistInMelCloud || !displayMode) {
|
|
280
|
-
continue;
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
const deviceName = device.name;
|
|
284
|
-
const deviceTypeText = device.typeString;
|
|
285
|
-
const deviceRefreshInterval = device.refreshInterval * 1000 || 5000;
|
|
286
|
-
const energyRecoveryVentilation = new DeviceErv(api, account, device, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, deviceRefreshInterval, useFahrenheit, restFul, mqtt)
|
|
287
|
-
energyRecoveryVentilation.on('publishAccessory', (accessory) => {
|
|
288
|
-
|
|
289
|
-
//publish device
|
|
121
|
+
//configured devices
|
|
122
|
+
const ataDevices = account.ataDevices ?? [];
|
|
123
|
+
const atwDevices = account.atwDevices ?? [];
|
|
124
|
+
const ervDevices = account.ervDevices ?? [];
|
|
125
|
+
const devices = [...ataDevices, ...atwDevices, ...ervDevices];
|
|
126
|
+
const emitLog = !enableDebugMode ? false : log.info(`Found configured devices ATA: ${ataDevices.length}, ATW: ${atwDevices.length}, ERV: ${ervDevices.length}.`);
|
|
127
|
+
for (const device of devices) {
|
|
128
|
+
//chack device from config exist on melcloud
|
|
129
|
+
const deviceId = device.id;
|
|
130
|
+
const displayMode = device.displayMode > 0;
|
|
131
|
+
const deviceExistInMelCloud = devicesInMelcloud.some(dev => dev.DeviceID === deviceId);
|
|
132
|
+
if (!deviceExistInMelCloud || !displayMode) {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const deviceName = device.name;
|
|
137
|
+
const deviceType = device.type;
|
|
138
|
+
const deviceTypeText = device.typeString;
|
|
139
|
+
const deviceRefreshInterval = device.refreshInterval * 1000 || 5000;
|
|
140
|
+
try {
|
|
141
|
+
let configuredDevice;
|
|
142
|
+
switch (deviceType) {
|
|
143
|
+
case 0: //ATA
|
|
144
|
+
configuredDevice = new DeviceAta(api, account, device, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, deviceRefreshInterval, useFahrenheit, restFul, mqtt);
|
|
145
|
+
break;
|
|
146
|
+
case 1: //ATW
|
|
147
|
+
configuredDevice = new DeviceAtw(api, account, device, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, deviceRefreshInterval, useFahrenheit, restFul, mqtt);
|
|
148
|
+
break;
|
|
149
|
+
case 2:
|
|
150
|
+
break;
|
|
151
|
+
case 3: //ERV
|
|
152
|
+
configuredDevice = new DeviceErv(api, account, device, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, deviceRefreshInterval, useFahrenheit, restFul, mqtt);
|
|
153
|
+
break;
|
|
154
|
+
default:
|
|
155
|
+
const emitLog = disableLogWarn ? false : log.warn(`${accountName}, ${deviceTypeText}, ${deviceName}, unknown device: ${deviceType}.`);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
configuredDevice.on('publishAccessory', (accessory) => {
|
|
290
160
|
api.publishExternalAccessories(PluginName, [accessory]);
|
|
291
|
-
const emitLog = disableLogSuccess ? false : log.success(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`);
|
|
161
|
+
const emitLog = disableLogSuccess ? false : log.success(`${accountName}, ${deviceTypeText}, ${deviceName}, published as external accessory.`);
|
|
292
162
|
})
|
|
293
163
|
.on('melCloud', async (key, value) => {
|
|
294
164
|
try {
|
|
@@ -296,7 +166,7 @@ class MelCloudPlatform {
|
|
|
296
166
|
await melCloud.send(accountInfo);
|
|
297
167
|
} catch (error) {
|
|
298
168
|
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error}.`);
|
|
299
|
-
}
|
|
169
|
+
}
|
|
300
170
|
})
|
|
301
171
|
.on('devInfo', (devInfo) => {
|
|
302
172
|
const emitLog = disableLogDeviceInfo ? false : log.info(devInfo);
|
|
@@ -321,36 +191,36 @@ class MelCloudPlatform {
|
|
|
321
191
|
const impulseGenerator = new ImpulseGenerator();
|
|
322
192
|
impulseGenerator.on('start', async () => {
|
|
323
193
|
try {
|
|
324
|
-
const startDone = await
|
|
194
|
+
const startDone = await configuredDevice.start();
|
|
325
195
|
const stopImpulseGenerator = startDone ? await impulseGenerator.stop() : false;
|
|
326
196
|
|
|
327
197
|
//start impulse generator
|
|
328
|
-
const startImpulseGenerator = stopImpulseGenerator ? await
|
|
198
|
+
const startImpulseGenerator = stopImpulseGenerator ? await configuredDevice.startImpulseGenerator() : false
|
|
329
199
|
} catch (error) {
|
|
330
200
|
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error}, trying again.`);
|
|
331
|
-
}
|
|
201
|
+
}
|
|
332
202
|
}).on('state', (state) => {
|
|
333
203
|
const emitLog = !enableDebugMode ? false : state ? log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, Start impulse generator started.`) : log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, Start impulse generator stopped.`);
|
|
334
204
|
});
|
|
335
205
|
|
|
336
206
|
//start impulse generator
|
|
337
207
|
await impulseGenerator.start([{ name: 'start', sampling: 45000 }]);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
|
|
208
|
+
} catch (error) {
|
|
209
|
+
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, did finish launching error: ${error}.`);
|
|
210
|
+
}
|
|
341
211
|
}
|
|
342
212
|
} catch (error) {
|
|
343
|
-
const emitLog = disableLogError ? false : log.error(`${accountName},
|
|
213
|
+
const emitLog = disableLogError ? false : log.error(`${accountName}, did finish launching error: ${error}.`);
|
|
344
214
|
}
|
|
345
|
-
}
|
|
215
|
+
}
|
|
346
216
|
});
|
|
347
|
-
}
|
|
217
|
+
}
|
|
348
218
|
|
|
349
219
|
configureAccessory(accessory) {
|
|
350
220
|
this.accessories.push(accessory);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
353
223
|
|
|
354
224
|
export default (api) => {
|
|
355
225
|
api.registerPlatform(PluginName, PlatformName, MelCloudPlatform);
|
|
356
|
-
}
|
|
226
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "3.8.
|
|
4
|
+
"version": "3.8.8",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|