homebridge-melcloud-control 2.5.0-beta.94 → 2.5.0-beta.96
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/server.js +3 -1
- package/index.js +24 -19
- package/package.json +1 -1
- package/src/deviceata.js +6 -6
- package/src/deviceatw.js +4 -4
- package/src/deviceerv.js +4 -4
- package/src/melcloud.js +15 -29
package/homebridge-ui/server.js
CHANGED
|
@@ -26,7 +26,9 @@ class PluginUiServer extends HomebridgePluginUiServer {
|
|
|
26
26
|
try {
|
|
27
27
|
let data = {};
|
|
28
28
|
const melCloud = new MelCloud(user, passwd, language, accountInfoFile, deviceInfoFile, buildingsFile, false, 0, true);
|
|
29
|
-
const
|
|
29
|
+
const response = await melCloud.connect();
|
|
30
|
+
const accountInfo = response.accountInfo;
|
|
31
|
+
const contextKey = response.contextKey;
|
|
30
32
|
const devices = await melCloud.chackDevicesList(contextKey);
|
|
31
33
|
return data = {
|
|
32
34
|
info: '',
|
package/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const MelCloud = require('./src/melcloud.js')
|
|
5
|
+
const MelCloudDevices = require('./src/melclouddevices.js')
|
|
5
6
|
const DeviceAta = require('./src/deviceata.js')
|
|
6
7
|
const DeviceAtw = require('./src/deviceatw.js')
|
|
7
8
|
const DeviceErv = require('./src/deviceerv.js')
|
|
@@ -17,7 +18,7 @@ class MelCloudPlatform {
|
|
|
17
18
|
this.accessories = [];
|
|
18
19
|
const accountsName = [];
|
|
19
20
|
|
|
20
|
-
api.on('didFinishLaunching', () => {
|
|
21
|
+
api.on('didFinishLaunching', async () => {
|
|
21
22
|
//loop through accounts
|
|
22
23
|
for (const account of config.accounts) {
|
|
23
24
|
const accountName = account.name;
|
|
@@ -73,8 +74,12 @@ class MelCloudPlatform {
|
|
|
73
74
|
const deviceRefreshInterval = account.deviceRefreshInterval * 1000 || 5000;
|
|
74
75
|
|
|
75
76
|
//melcloud account
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
try {
|
|
78
|
+
const melCloud = new MelCloud(user, passwd, language, accountInfoFile, buildingsFile, deviceFile, enableDebugMode, refreshInterval, false);
|
|
79
|
+
const response = await melCloud.connect();
|
|
80
|
+
const accountInfo = response.accountInfo;
|
|
81
|
+
const contextKey = response.contextKey;
|
|
82
|
+
const devices = await melCloud.chackDevicesList(contextKey);
|
|
78
83
|
|
|
79
84
|
//Air Conditioner
|
|
80
85
|
for (const device of account.ataDevices) {
|
|
@@ -189,24 +194,24 @@ class MelCloudPlatform {
|
|
|
189
194
|
log.error(`${deviceTypeText}, ${deviceName}, ${error}`);
|
|
190
195
|
});
|
|
191
196
|
};
|
|
192
|
-
|
|
193
|
-
.on('success', (message) => {
|
|
197
|
+
melCloud.on('success', (message) => {
|
|
194
198
|
log.success(`Account ${accountName}, ${message}`);
|
|
195
199
|
})
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
});
|
|
200
|
+
.on('message', (message) => {
|
|
201
|
+
log.info(`Account ${accountName}, ${message}`);
|
|
202
|
+
})
|
|
203
|
+
.on('debug', (debug) => {
|
|
204
|
+
log.info(`Account ${accountName}, debug: ${debug}`);
|
|
205
|
+
})
|
|
206
|
+
.on('warn', (warn) => {
|
|
207
|
+
log.warn(`Account ${accountName}, ${warn}`);
|
|
208
|
+
})
|
|
209
|
+
.on('error', async (error) => {
|
|
210
|
+
log.error(`Account ${accountName}, ${error}.`);
|
|
211
|
+
});
|
|
212
|
+
} catch (error) {
|
|
213
|
+
log.error(`Account: ${accountName}, MELCloud error: ${error.message ?? error}`);
|
|
214
|
+
}
|
|
210
215
|
};
|
|
211
216
|
});
|
|
212
217
|
};
|
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.96",
|
|
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/deviceata.js
CHANGED
|
@@ -207,8 +207,8 @@ class DeviceAta extends EventEmitter {
|
|
|
207
207
|
this.accessory.setTemperature = setTemperature;
|
|
208
208
|
this.accessory.fanSpeed = 0;
|
|
209
209
|
this.accessory.setFanSpeed = setFanSpeed;
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
this.accessory.currentOperationMode = 0;
|
|
211
|
+
this.accessory.targetOperationMode = 0;
|
|
212
212
|
this.accessory.vaneHorizontal = vaneHorizontal;
|
|
213
213
|
this.accessory.vaneVertical = vaneVertical;
|
|
214
214
|
this.accessory.swingMode = swingFunction && vaneHorizontal === 12 && vaneVertical === 7 ? 1 : 0;
|
|
@@ -230,7 +230,7 @@ class DeviceAta extends EventEmitter {
|
|
|
230
230
|
|
|
231
231
|
//operating mode
|
|
232
232
|
switch (displayMode) {
|
|
233
|
-
case
|
|
233
|
+
case 1: //Heater Cooler
|
|
234
234
|
//operating mode 0, HEAT, DRY, COOL, 4, 5, 6, FAN, AUTO, ISEE HEAT, ISEE DRY, ISEE COOL
|
|
235
235
|
switch (power) {
|
|
236
236
|
case true:
|
|
@@ -328,7 +328,7 @@ class DeviceAta extends EventEmitter {
|
|
|
328
328
|
const updateSM = swingFunction ? this.melCloudService.updateCharacteristic(Characteristic.SwingMode, this.accessory.swingMode) : false;
|
|
329
329
|
};
|
|
330
330
|
break;
|
|
331
|
-
case
|
|
331
|
+
case 2: //Thermostat
|
|
332
332
|
switch (power) {
|
|
333
333
|
case true:
|
|
334
334
|
switch (!inStandbyMode) {
|
|
@@ -710,7 +710,7 @@ class DeviceAta extends EventEmitter {
|
|
|
710
710
|
const serviceName = `${deviceTypeText} ${accessoryName}`;
|
|
711
711
|
|
|
712
712
|
switch (displayMode) {
|
|
713
|
-
case
|
|
713
|
+
case 1: //Heater Cooler
|
|
714
714
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare heater/cooler service`) : false;
|
|
715
715
|
this.melCloudService = new Service.HeaterCooler(serviceName, `HeaterCooler ${deviceId}`);
|
|
716
716
|
this.melCloudService.getCharacteristic(Characteristic.Active)
|
|
@@ -922,7 +922,7 @@ class DeviceAta extends EventEmitter {
|
|
|
922
922
|
});
|
|
923
923
|
accessory.addService(this.melCloudService);
|
|
924
924
|
break;
|
|
925
|
-
case
|
|
925
|
+
case 2: //Thermostat
|
|
926
926
|
const debug1 = this.enableDebugMode ? this.emit('debug', `Prepare thermostat service`) : false;
|
|
927
927
|
this.melCloudService = accessory.addService(Service.Thermostat, serviceName, `Thermostat ${deviceId}`);
|
|
928
928
|
this.melCloudService.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
|
package/src/deviceatw.js
CHANGED
|
@@ -266,7 +266,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
266
266
|
|
|
267
267
|
for (let i = 0; i < zonesCount; i++) {
|
|
268
268
|
switch (displayMode) {
|
|
269
|
-
case
|
|
269
|
+
case 1: //Heater Cooler
|
|
270
270
|
switch (i) {
|
|
271
271
|
case 0: //Heat Pump Operation Mode - IDLE, HOT WATER, HEATING ZONES, COOLING, HOT WATER STORAGE, FREEZE STAT, LEGIONELLA, HEATING ECO, MODE 1, MODE 2, MODE 3, HEATING UP /// Unit Status - HEAT, COOL
|
|
272
272
|
name = heatPumpName;
|
|
@@ -350,7 +350,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
350
350
|
const updateCT = heatCoolModes === 0 || heatCoolModes === 2 ? this.melCloudServices[i].updateCharacteristic(Characteristic.CoolingThresholdTemperature, setTemperature) : false;
|
|
351
351
|
}
|
|
352
352
|
break;
|
|
353
|
-
case
|
|
353
|
+
case 2: //Thermostat
|
|
354
354
|
switch (i) {
|
|
355
355
|
case 0: //Heat Pump Operation Mode - IDLE, HOT WATER, HEATING ZONES, COOLING, HOT WATER STORAGE, FREEZE STAT, LEGIONELLA, HEATING ECO, MODE 1, MODE 2, MODE 3, HEATING UP /// Unit Status - HEAT, COOL
|
|
356
356
|
currentOperationMode = !power ? 0 : [0, 1, 1, 2, 1, 0, 0, 1, 0, 0, 0, 1][operationMode]; //OFF, HEAT, COOL
|
|
@@ -835,7 +835,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
835
835
|
const zoneName = this.accessory.zones[i].name
|
|
836
836
|
const serviceName = `${deviceTypeText} ${accessoryName}: ${zoneName}`;
|
|
837
837
|
switch (displayMode) {
|
|
838
|
-
case
|
|
838
|
+
case 1: //Heater Cooler
|
|
839
839
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare heather/cooler ${zoneName} service`) : false;
|
|
840
840
|
const melCloudService = new Service.HeaterCooler(serviceName, `HeaterCooler ${deviceId} ${i}`);
|
|
841
841
|
melCloudService.getCharacteristic(Characteristic.Active)
|
|
@@ -1098,7 +1098,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1098
1098
|
this.melCloudServices.push(melCloudService);
|
|
1099
1099
|
accessory.addService(melCloudService);
|
|
1100
1100
|
break;
|
|
1101
|
-
case
|
|
1101
|
+
case 2: //Thermostat
|
|
1102
1102
|
const debug3 = this.enableDebugMode ? this.emit('debug', `Prepare thermostat ${zoneName} service`) : false;
|
|
1103
1103
|
const melCloudServiceT = new Service.Thermostat(serviceName, `Thermostat ${deviceId} ${i}`);
|
|
1104
1104
|
melCloudServiceT.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
|
package/src/deviceerv.js
CHANGED
|
@@ -253,7 +253,7 @@ class DeviceErv extends EventEmitter {
|
|
|
253
253
|
|
|
254
254
|
//operation mode - 0, HEAT, 2, COOL, 4, 5, 6, FAN, AUTO
|
|
255
255
|
switch (displayMode) {
|
|
256
|
-
case
|
|
256
|
+
case 1: //Heater Cooler
|
|
257
257
|
switch (power) {
|
|
258
258
|
case true:
|
|
259
259
|
switch (ventilationMode) {
|
|
@@ -323,7 +323,7 @@ class DeviceErv extends EventEmitter {
|
|
|
323
323
|
const updateCOM = hasCoolOperationMode ? this.melCloudService.updateCharacteristic(Characteristic.CoolingThresholdTemperature, targetTemperature) : false;
|
|
324
324
|
};
|
|
325
325
|
break;
|
|
326
|
-
case
|
|
326
|
+
case 2: //Thermostat
|
|
327
327
|
//operation mode - 0, HEAT, 2, COOL, 4, 5, 6, FAN, AUTO
|
|
328
328
|
switch (power) {
|
|
329
329
|
case true:
|
|
@@ -650,7 +650,7 @@ class DeviceErv extends EventEmitter {
|
|
|
650
650
|
const serviceName = `${deviceTypeText} ${accessoryName}`;
|
|
651
651
|
|
|
652
652
|
switch (displayMode) {
|
|
653
|
-
case
|
|
653
|
+
case 1: //Heater Cooler
|
|
654
654
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare heather/cooler service`) : false;
|
|
655
655
|
this.melCloudService = accessory.addService(Service.HeaterCooler, serviceName, `HeaterCooler ${deviceId}`);
|
|
656
656
|
this.melCloudService.getCharacteristic(Characteristic.Active)
|
|
@@ -837,7 +837,7 @@ class DeviceErv extends EventEmitter {
|
|
|
837
837
|
};
|
|
838
838
|
});
|
|
839
839
|
break;
|
|
840
|
-
case
|
|
840
|
+
case 2: //Thermostat
|
|
841
841
|
const debug1 = this.enableDebugMode ? this.emit('debug', `Prepare thermostat service`) : false;
|
|
842
842
|
this.melCloudService = accessory.addService(Service.Thermostat, serviceName, `Thermostat ${deviceId}`);
|
|
843
843
|
this.melCloudService.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
|
package/src/melcloud.js
CHANGED
|
@@ -16,7 +16,6 @@ class MelCloud extends EventEmitter {
|
|
|
16
16
|
this.enableDebugMode = enableDebugMode;
|
|
17
17
|
this.refreshInterval = refreshInterval;
|
|
18
18
|
this.requestConfig = requestConfig;
|
|
19
|
-
this.emitData = true;
|
|
20
19
|
this.contextKey = '';
|
|
21
20
|
this.devicesId = [];
|
|
22
21
|
|
|
@@ -36,7 +35,7 @@ class MelCloud extends EventEmitter {
|
|
|
36
35
|
this.impulseGenerator = new ImpulseGenerator();
|
|
37
36
|
this.impulseGenerator.on('checkDevicesList', async () => {
|
|
38
37
|
try {
|
|
39
|
-
await this.chackDevicesList(this.contextKey);
|
|
38
|
+
const devices = await this.chackDevicesList(this.contextKey);
|
|
40
39
|
} catch (error) {
|
|
41
40
|
this.emit('error', `Check devices list: ${error}.`);
|
|
42
41
|
};
|
|
@@ -66,6 +65,7 @@ class MelCloud extends EventEmitter {
|
|
|
66
65
|
const account = accountData.data;
|
|
67
66
|
const accountInfo = account.LoginData;
|
|
68
67
|
const contextKey = accountInfo.ContextKey;
|
|
68
|
+
this.contextKey = contextKey;
|
|
69
69
|
|
|
70
70
|
//remove sensitive data
|
|
71
71
|
const debugData = {
|
|
@@ -83,30 +83,21 @@ class MelCloud extends EventEmitter {
|
|
|
83
83
|
this.emit('warn', `Context key: ${contextKey}, missing.`)
|
|
84
84
|
return;
|
|
85
85
|
};
|
|
86
|
-
this.accountInfo = accountInfo;
|
|
87
|
-
this.contextKey = contextKey;
|
|
88
86
|
|
|
89
87
|
//save melcloud info to the file
|
|
90
88
|
await this.saveData(this.accountInfoFile, accountInfo);
|
|
91
89
|
|
|
92
|
-
//return if connect for config
|
|
93
|
-
if (this.requestConfig) {
|
|
94
|
-
return contextKey;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
//check devices list
|
|
98
|
-
await this.chackDevicesList(contextKey);
|
|
99
|
-
|
|
100
90
|
//emit connect success
|
|
101
91
|
this.emit('success', `Connect to MELCloud Success.`)
|
|
102
92
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
93
|
+
const obj = {
|
|
94
|
+
accountInfo: accountInfo,
|
|
95
|
+
contextKey: contextKey
|
|
96
|
+
}
|
|
106
97
|
|
|
107
|
-
return
|
|
98
|
+
return obj;
|
|
108
99
|
} catch (error) {
|
|
109
|
-
|
|
100
|
+
throw new Error(`Connect to MELCloud error: ${error.message ?? error}.`);
|
|
110
101
|
};
|
|
111
102
|
}
|
|
112
103
|
|
|
@@ -177,20 +168,15 @@ class MelCloud extends EventEmitter {
|
|
|
177
168
|
const debug = this.enableDebugMode ? this.emit('debug', `Device: ${deviceName} info saved.`) : false;
|
|
178
169
|
};
|
|
179
170
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
//emit check devices list complete
|
|
186
|
-
if (!this.requestConfig && this.emitData) {
|
|
187
|
-
this.emit('checkDevicesListComplete', this.accountInfo, contextKey)
|
|
188
|
-
this.emitData = false;
|
|
189
|
-
};
|
|
171
|
+
if (!this.requestConfig) {
|
|
172
|
+
//start impulse generator
|
|
173
|
+
const timers = [{ name: 'checkDevicesList', sampling: this.refreshInterval }];
|
|
174
|
+
this.impulseGenerator.start(timers);
|
|
175
|
+
}
|
|
190
176
|
|
|
191
|
-
return
|
|
177
|
+
return devices;
|
|
192
178
|
} catch (error) {
|
|
193
|
-
const stop =
|
|
179
|
+
const stop = !this.requestConfig ? false : this.impulseGenerator.stop();
|
|
194
180
|
throw new Error(`Scanning for devices error: ${error.message ?? error}.`);
|
|
195
181
|
};
|
|
196
182
|
}
|