homebridge-melcloud-control 3.8.7 → 3.8.8-beta.0
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 +55 -184
- 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,183 +110,54 @@ 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
118
|
//start 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
|
-
|
|
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: ${devices.length}.`);
|
|
127
|
+
for (const device of devices) {
|
|
128
|
+
|
|
129
|
+
//chack device from config exist on melcloud
|
|
130
|
+
const deviceId = device.id;
|
|
131
|
+
const displayMode = device.displayMode > 0;
|
|
132
|
+
const deviceExistInMelCloud = devicesInMelcloud.some(dev => dev.DeviceID === deviceId);
|
|
133
|
+
if (!deviceExistInMelCloud || !displayMode) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const deviceName = device.name;
|
|
138
|
+
const deviceType = device.type;
|
|
139
|
+
const deviceTypeText = device.typeString;
|
|
140
|
+
const deviceRefreshInterval = device.refreshInterval * 1000 || 5000;
|
|
141
|
+
try {
|
|
142
|
+
let configureddDevice;
|
|
143
|
+
switch (deviceType) {
|
|
144
|
+
case 0: //ATA
|
|
145
|
+
configureddDevice = new DeviceAta(api, account, device, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, deviceRefreshInterval, useFahrenheit, restFul, mqtt);
|
|
146
|
+
break;
|
|
147
|
+
case 1: //ATW
|
|
148
|
+
configureddDevice = new DeviceAtw(api, account, device, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, deviceRefreshInterval, useFahrenheit, restFul, mqtt);
|
|
149
|
+
break;
|
|
150
|
+
case 2:
|
|
151
|
+
break;
|
|
152
|
+
case 3: //ERV
|
|
153
|
+
configureddDevice = new DeviceErv(api, account, device, contextKey, accountName, deviceId, deviceName, deviceTypeText, devicesFile, deviceRefreshInterval, useFahrenheit, restFul, mqtt);
|
|
154
|
+
break;
|
|
155
|
+
default:
|
|
156
|
+
const emitLog = disableLogWarn ? false : log.warn(`${accountName}, ${deviceTypeText} ${deviceName}, unknown device: ${deviceType}.`);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
configureddDevice.on('publishAccessory', (accessory) => {
|
|
290
161
|
api.publishExternalAccessories(PluginName, [accessory]);
|
|
291
162
|
const emitLog = disableLogSuccess ? false : log.success(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`);
|
|
292
163
|
})
|
|
@@ -296,7 +167,7 @@ class MelCloudPlatform {
|
|
|
296
167
|
await melCloud.send(accountInfo);
|
|
297
168
|
} catch (error) {
|
|
298
169
|
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error}.`);
|
|
299
|
-
}
|
|
170
|
+
}
|
|
300
171
|
})
|
|
301
172
|
.on('devInfo', (devInfo) => {
|
|
302
173
|
const emitLog = disableLogDeviceInfo ? false : log.info(devInfo);
|
|
@@ -321,36 +192,36 @@ class MelCloudPlatform {
|
|
|
321
192
|
const impulseGenerator = new ImpulseGenerator();
|
|
322
193
|
impulseGenerator.on('start', async () => {
|
|
323
194
|
try {
|
|
324
|
-
const startDone = await
|
|
195
|
+
const startDone = await configureddDevice.start();
|
|
325
196
|
const stopImpulseGenerator = startDone ? await impulseGenerator.stop() : false;
|
|
326
197
|
|
|
327
198
|
//start impulse generator
|
|
328
|
-
const startImpulseGenerator = stopImpulseGenerator ? await
|
|
199
|
+
const startImpulseGenerator = stopImpulseGenerator ? await configureddDevice.startImpulseGenerator() : false
|
|
329
200
|
} catch (error) {
|
|
330
201
|
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error}, trying again.`);
|
|
331
|
-
}
|
|
202
|
+
}
|
|
332
203
|
}).on('state', (state) => {
|
|
333
204
|
const emitLog = !enableDebugMode ? false : state ? log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, Start impulse generator started.`) : log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, Start impulse generator stopped.`);
|
|
334
205
|
});
|
|
335
206
|
|
|
336
207
|
//start impulse generator
|
|
337
208
|
await impulseGenerator.start([{ name: 'start', sampling: 45000 }]);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
|
|
209
|
+
} catch (error) {
|
|
210
|
+
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, did finish launching error: ${error}.`);
|
|
211
|
+
}
|
|
341
212
|
}
|
|
342
213
|
} catch (error) {
|
|
343
214
|
const emitLog = disableLogError ? false : log.error(`${accountName}, Account did finish launching error: ${error}.`);
|
|
344
215
|
}
|
|
345
|
-
}
|
|
216
|
+
}
|
|
346
217
|
});
|
|
347
|
-
}
|
|
218
|
+
}
|
|
348
219
|
|
|
349
220
|
configureAccessory(accessory) {
|
|
350
221
|
this.accessories.push(accessory);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
353
224
|
|
|
354
225
|
export default (api) => {
|
|
355
226
|
api.registerPlatform(PluginName, PlatformName, MelCloudPlatform);
|
|
356
|
-
}
|
|
227
|
+
}
|
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-beta.0",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|