homebridge-melcloud-control 2.5.0-beta.75 → 2.5.0-beta.77
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 +123 -113
- package/package.json +1 -1
- package/src/deviceata.js +10 -10
- package/src/deviceatw.js +14 -14
- package/src/deviceerv.js +8 -8
- package/src/melcloud.js +4 -6
package/index.js
CHANGED
|
@@ -38,11 +38,6 @@ class MelCloudPlatform {
|
|
|
38
38
|
}
|
|
39
39
|
accountsName.push(accountName);
|
|
40
40
|
|
|
41
|
-
//hide devices
|
|
42
|
-
const ataHideDeviceById = account.ataHideDeviceById || [];
|
|
43
|
-
const atwHideDeviceById = account.atwHideDeviceById || [];
|
|
44
|
-
const ervHideDeviceById = account.ervHideDeviceById || [];
|
|
45
|
-
|
|
46
41
|
//debug config
|
|
47
42
|
const enableDebugMode = account.enableDebugMode || false;
|
|
48
43
|
const debug = enableDebugMode ? log.info(`Account: ${accountName}, did finish launching.`) : false;
|
|
@@ -62,7 +57,7 @@ class MelCloudPlatform {
|
|
|
62
57
|
const prefDir = path.join(api.user.storagePath(), 'melcloud');
|
|
63
58
|
const accountInfoFile = `${prefDir}/${accountName}_Account`;
|
|
64
59
|
const buildingsFile = `${prefDir}/${accountName}_Buildings`;
|
|
65
|
-
const
|
|
60
|
+
const deviceFile = `${prefDir}/${accountName}_Device_`;
|
|
66
61
|
|
|
67
62
|
//create directory if it doesn't exist
|
|
68
63
|
try {
|
|
@@ -78,116 +73,131 @@ class MelCloudPlatform {
|
|
|
78
73
|
const deviceRefreshInterval = account.deviceRefreshInterval * 1000 || 5000;
|
|
79
74
|
|
|
80
75
|
//melcloud account
|
|
81
|
-
const melCloud = new MelCloud(user, passwd, language, accountInfoFile, buildingsFile,
|
|
82
|
-
melCloud.on('checkDevicesListComplete', (accountInfo, contextKey
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
76
|
+
const melCloud = new MelCloud(user, passwd, language, accountInfoFile, buildingsFile, deviceFile, enableDebugMode, refreshInterval, false);
|
|
77
|
+
melCloud.on('checkDevicesListComplete', (accountInfo, contextKey) => {
|
|
78
|
+
|
|
79
|
+
//Air Conditioner
|
|
80
|
+
for (const device of account.ataDevices) {
|
|
81
|
+
const id = device.id ?? false;
|
|
82
|
+
|
|
83
|
+
//check id exist
|
|
84
|
+
if (!id) {
|
|
85
|
+
continue;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const deviceId = id.toString();
|
|
89
|
+
const deviceType = device.type;
|
|
90
|
+
const deviceName = device.name;
|
|
91
|
+
const deviceTypeText = CONSTANTS.DeviceType[deviceType];
|
|
92
|
+
const deviceInfoFile = `${prefDir}/${accountName}_Device_${deviceId}`;
|
|
93
|
+
const airConditioner = new DeviceAta(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, accountInfoFile, deviceInfoFile, deviceRefreshInterval)
|
|
94
|
+
airConditioner.on('publishAccessory', (accessory) => {
|
|
95
|
+
|
|
96
|
+
//publish device
|
|
97
|
+
api.publishExternalAccessories(CONSTANTS.PluginName, [accessory]);
|
|
98
|
+
log.success(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`);
|
|
99
|
+
})
|
|
100
|
+
.on('devInfo', (devInfo) => {
|
|
101
|
+
log.info(devInfo);
|
|
103
102
|
})
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
})
|
|
107
|
-
.on('success', (message) => {
|
|
108
|
-
log.success(`${deviceTypeText}, ${deviceName}, ${message}`);
|
|
109
|
-
})
|
|
110
|
-
.on('message', (message) => {
|
|
111
|
-
log.info(`${deviceTypeText}, ${deviceName}, ${message}`);
|
|
112
|
-
})
|
|
113
|
-
.on('debug', (debug) => {
|
|
114
|
-
log.info(`${deviceTypeText}, ${deviceName}, debug: ${debug}`);
|
|
115
|
-
})
|
|
116
|
-
.on('warn', (warn) => {
|
|
117
|
-
log.warn(`${deviceTypeText}, ${deviceName}, ${warn}`);
|
|
118
|
-
})
|
|
119
|
-
.on('error', (error) => {
|
|
120
|
-
log.error(`${deviceTypeText}, ${deviceName}, ${error}`);
|
|
121
|
-
});
|
|
122
|
-
break;
|
|
123
|
-
case 1: //Heat Pump
|
|
124
|
-
const atwHideDevice = atwHideDeviceById.some(device => device.id === deviceId) ?? false;
|
|
125
|
-
if (atwHideDevice) {
|
|
126
|
-
return;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const heatPump = new DeviceAtw(api, account, melCloud, accountInfo, accountName, contextKey, deviceId, deviceName, deviceTypeText, accountInfoFile, deviceInfoFile, deviceRefreshInterval)
|
|
130
|
-
heatPump.on('publishAccessory', (accessory) => {
|
|
131
|
-
|
|
132
|
-
//publish device
|
|
133
|
-
api.publishExternalAccessories(CONSTANTS.PluginName, [accessory]);
|
|
134
|
-
log.success(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`);
|
|
103
|
+
.on('success', (message) => {
|
|
104
|
+
log.success(`${deviceTypeText}, ${deviceName}, ${message}`);
|
|
135
105
|
})
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
})
|
|
139
|
-
.on('success', (message) => {
|
|
140
|
-
log.success(`${deviceTypeText}, ${deviceName}, ${message}`);
|
|
141
|
-
})
|
|
142
|
-
.on('message', (message) => {
|
|
143
|
-
log.info(`${deviceTypeText}, ${deviceName}, ${message}`);
|
|
144
|
-
})
|
|
145
|
-
.on('debug', (debug) => {
|
|
146
|
-
log.info(`${deviceTypeText}, ${deviceName}, debug: ${debug}`);
|
|
147
|
-
})
|
|
148
|
-
.on('warn', (warn) => {
|
|
149
|
-
log.warn(`${deviceTypeText}, ${deviceName}, ${warn}`);
|
|
150
|
-
})
|
|
151
|
-
.on('error', (error) => {
|
|
152
|
-
log.error(`${deviceTypeText}, ${deviceName}, ${error}`);
|
|
153
|
-
});
|
|
154
|
-
break;
|
|
155
|
-
case 3: //Energy Recovery Ventilation
|
|
156
|
-
const ervHideDevice = ervHideDeviceById.some(device => device.id === deviceId) ?? false;
|
|
157
|
-
if (ervHideDevice) {
|
|
158
|
-
return;
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
const energyRecoveryVentilation = new DeviceErv(api, account, melCloud, accountInfo, accountName, contextKey, deviceId, deviceName, deviceTypeText, accountInfoFile, deviceInfoFile, deviceRefreshInterval)
|
|
162
|
-
energyRecoveryVentilation.on('publishAccessory', (accessory) => {
|
|
163
|
-
|
|
164
|
-
//publish device
|
|
165
|
-
api.publishExternalAccessories(CONSTANTS.PluginName, [accessory]);
|
|
166
|
-
log.success(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`);
|
|
106
|
+
.on('message', (message) => {
|
|
107
|
+
log.info(`${deviceTypeText}, ${deviceName}, ${message}`);
|
|
167
108
|
})
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
109
|
+
.on('debug', (debug) => {
|
|
110
|
+
log.info(`${deviceTypeText}, ${deviceName}, debug: ${debug}`);
|
|
111
|
+
})
|
|
112
|
+
.on('warn', (warn) => {
|
|
113
|
+
log.warn(`${deviceTypeText}, ${deviceName}, ${warn}`);
|
|
114
|
+
})
|
|
115
|
+
.on('error', (error) => {
|
|
116
|
+
log.error(`${deviceTypeText}, ${deviceName}, ${error}`);
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
//Heat Pump
|
|
121
|
+
for (const device of account.atwDevices) {
|
|
122
|
+
const id = device.id ?? false;
|
|
123
|
+
|
|
124
|
+
//check id exist
|
|
125
|
+
if (!id) {
|
|
126
|
+
continue;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const deviceId = id.toString();
|
|
130
|
+
const deviceType = device.type;
|
|
131
|
+
const deviceName = device.name;
|
|
132
|
+
const deviceTypeText = CONSTANTS.DeviceType[deviceType];
|
|
133
|
+
const deviceInfoFile = `${prefDir}/${accountName}_Device_${deviceId}`;
|
|
134
|
+
const heatPump = new DeviceAtw(api, account, melCloud, device, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, accountInfoFile, deviceInfoFile, deviceRefreshInterval)
|
|
135
|
+
heatPump.on('publishAccessory', (accessory) => {
|
|
136
|
+
|
|
137
|
+
//publish device
|
|
138
|
+
api.publishExternalAccessories(CONSTANTS.PluginName, [accessory]);
|
|
139
|
+
log.success(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`);
|
|
140
|
+
})
|
|
141
|
+
.on('devInfo', (devInfo) => {
|
|
142
|
+
log.info(devInfo);
|
|
143
|
+
})
|
|
144
|
+
.on('success', (message) => {
|
|
145
|
+
log.success(`${deviceTypeText}, ${deviceName}, ${message}`);
|
|
146
|
+
})
|
|
147
|
+
.on('message', (message) => {
|
|
148
|
+
log.info(`${deviceTypeText}, ${deviceName}, ${message}`);
|
|
149
|
+
})
|
|
150
|
+
.on('debug', (debug) => {
|
|
151
|
+
log.info(`${deviceTypeText}, ${deviceName}, debug: ${debug}`);
|
|
152
|
+
})
|
|
153
|
+
.on('warn', (warn) => {
|
|
154
|
+
log.warn(`${deviceTypeText}, ${deviceName}, ${warn}`);
|
|
155
|
+
})
|
|
156
|
+
.on('error', (error) => {
|
|
157
|
+
log.error(`${deviceTypeText}, ${deviceName}, ${error}`);
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
//Energy Recovery Ventilation
|
|
162
|
+
for (const device of account.ervDevices) {
|
|
163
|
+
const id = device.id ?? false;
|
|
164
|
+
|
|
165
|
+
//check id exist
|
|
166
|
+
if (!id) {
|
|
167
|
+
continue;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const deviceId = id.toString();
|
|
171
|
+
const deviceType = device.type;
|
|
172
|
+
const deviceName = device.name;
|
|
173
|
+
const deviceTypeText = CONSTANTS.DeviceType[deviceType];
|
|
174
|
+
const deviceInfoFile = `${prefDir}/${accountName}_Device_${deviceId}`;
|
|
175
|
+
const energyRecoveryVentilation = new DeviceErv(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, accountInfoFile, deviceInfoFile, deviceRefreshInterval)
|
|
176
|
+
energyRecoveryVentilation.on('publishAccessory', (accessory) => {
|
|
177
|
+
|
|
178
|
+
//publish device
|
|
179
|
+
api.publishExternalAccessories(CONSTANTS.PluginName, [accessory]);
|
|
180
|
+
log.success(`${accountName}, ${deviceTypeText} ${deviceName}, published as external accessory.`);
|
|
181
|
+
})
|
|
182
|
+
.on('devInfo', (devInfo) => {
|
|
183
|
+
log.info(devInfo);
|
|
184
|
+
})
|
|
185
|
+
.on('success', (message) => {
|
|
186
|
+
log.success(`${deviceTypeText}, ${deviceName}, ${message}`);
|
|
187
|
+
})
|
|
188
|
+
.on('message', (message) => {
|
|
189
|
+
log.info(`${deviceTypeText}, ${deviceName}, ${message}`);
|
|
190
|
+
})
|
|
191
|
+
.on('debug', (debug) => {
|
|
192
|
+
log.info(`${deviceTypeText}, ${deviceName}, debug: ${debug}`);
|
|
193
|
+
})
|
|
194
|
+
.on('warn', (warn) => {
|
|
195
|
+
log.warn(`${deviceTypeText}, ${deviceName}, ${warn}`);
|
|
196
|
+
})
|
|
197
|
+
.on('error', (error) => {
|
|
198
|
+
log.error(`${deviceTypeText}, ${deviceName}, ${error}`);
|
|
199
|
+
});
|
|
200
|
+
};
|
|
191
201
|
})
|
|
192
202
|
.on('success', (message) => {
|
|
193
203
|
log.success(`Account ${accountName}, ${message}`);
|
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.77",
|
|
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
|
@@ -7,7 +7,7 @@ const CONSTANTS = require('./constants.json');
|
|
|
7
7
|
let Accessory, Characteristic, Service, Categories, AccessoryUUID;
|
|
8
8
|
|
|
9
9
|
class DeviceAta extends EventEmitter {
|
|
10
|
-
constructor(api, account, melCloud, accountInfo,
|
|
10
|
+
constructor(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, accountInfoFile, deviceInfoFile, refreshInterval) {
|
|
11
11
|
super();
|
|
12
12
|
|
|
13
13
|
Accessory = api.platformAccessory;
|
|
@@ -17,14 +17,14 @@ class DeviceAta extends EventEmitter {
|
|
|
17
17
|
AccessoryUUID = api.hap.uuid;
|
|
18
18
|
|
|
19
19
|
//account config
|
|
20
|
-
this.displayMode =
|
|
21
|
-
this.temperatureSensor =
|
|
22
|
-
this.temperatureSensorOutdoor =
|
|
23
|
-
this.presetsEnabled =
|
|
24
|
-
this.heatDryFanMode =
|
|
25
|
-
this.coolDryFanMode =
|
|
26
|
-
this.autoDryFanMode =
|
|
27
|
-
this.buttons =
|
|
20
|
+
this.displayMode = device.displayMode || 0;
|
|
21
|
+
this.temperatureSensor = device.temperatureSensor || false;
|
|
22
|
+
this.temperatureSensorOutdoor = device.temperatureSensorOutdoor || false;
|
|
23
|
+
this.presetsEnabled = device.presets || false;
|
|
24
|
+
this.heatDryFanMode = device.heatDryFanMode || 1; //NONE, HEAT, DRY, FAN
|
|
25
|
+
this.coolDryFanMode = device.coolDryFanMode || 1; //NONE, COOL, DRY, FAN
|
|
26
|
+
this.autoDryFanMode = device.autoDryFanMode || 1; //NONE, AUTO, DRY, FAN
|
|
27
|
+
this.buttons = device.buttons || [];
|
|
28
28
|
this.disableLogInfo = account.disableLogInfo || false;
|
|
29
29
|
this.disableLogDeviceInfo = account.disableLogDeviceInfo || false;
|
|
30
30
|
this.enableDebugMode = account.enableDebugMode || false;
|
|
@@ -69,7 +69,7 @@ class DeviceAta extends EventEmitter {
|
|
|
69
69
|
accountInfoFile: accountInfoFile,
|
|
70
70
|
deviceInfoFile: deviceInfoFile,
|
|
71
71
|
debugLog: account.enableDebugMode,
|
|
72
|
-
refreshInterval:
|
|
72
|
+
refreshInterval: refreshInterval
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
this.melCloudAta.on('externalIntegrations', (deviceData, deviceState) => {
|
package/src/deviceatw.js
CHANGED
|
@@ -7,7 +7,7 @@ const CONSTANTS = require('./constants.json');
|
|
|
7
7
|
let Accessory, Characteristic, Service, Categories, AccessoryUUID;
|
|
8
8
|
|
|
9
9
|
class DeviceAtw extends EventEmitter {
|
|
10
|
-
constructor(api, account, melCloud, accountInfo,
|
|
10
|
+
constructor(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, accountInfoFile, deviceInfoFile, refreshInterval) {
|
|
11
11
|
super();
|
|
12
12
|
|
|
13
13
|
Accessory = api.platformAccessory;
|
|
@@ -17,18 +17,18 @@ class DeviceAtw extends EventEmitter {
|
|
|
17
17
|
AccessoryUUID = api.hap.uuid;
|
|
18
18
|
|
|
19
19
|
//account config
|
|
20
|
-
this.displayMode =
|
|
21
|
-
this.temperatureSensor =
|
|
22
|
-
this.temperatureSensorFlow =
|
|
23
|
-
this.temperatureSensorReturn =
|
|
24
|
-
this.temperatureSensorFlowZone1 =
|
|
25
|
-
this.temperatureSensorReturnZone1 =
|
|
26
|
-
this.temperatureSensorFlowWaterTank =
|
|
27
|
-
this.temperatureSensorReturnWaterTank =
|
|
28
|
-
this.temperatureSensorFlowZone2 =
|
|
29
|
-
this.temperatureSensorReturnZone2 =
|
|
30
|
-
this.presetsEnabled =
|
|
31
|
-
this.buttons =
|
|
20
|
+
this.displayMode = device.displayMode || 0;
|
|
21
|
+
this.temperatureSensor = device.temperatureSensor || false;
|
|
22
|
+
this.temperatureSensorFlow = device.temperatureSensorFlow || false;
|
|
23
|
+
this.temperatureSensorReturn = device.temperatureSensorReturn || false;
|
|
24
|
+
this.temperatureSensorFlowZone1 = device.temperatureSensorFlowZone1 || false;
|
|
25
|
+
this.temperatureSensorReturnZone1 = device.temperatureSensorFlowWaterTank || false;
|
|
26
|
+
this.temperatureSensorFlowWaterTank = device.temperatureSensorFlowZone1 || false;
|
|
27
|
+
this.temperatureSensorReturnWaterTank = device.temperatureSensorReturnWaterTank || false;
|
|
28
|
+
this.temperatureSensorFlowZone2 = device.temperatureSensorFlowZone2 || false;
|
|
29
|
+
this.temperatureSensorReturnZone2 = device.temperatureSensorReturnZone2 || false;
|
|
30
|
+
this.presetsEnabled = device.presets || false;
|
|
31
|
+
this.buttons = device.buttons || [];
|
|
32
32
|
this.disableLogInfo = account.disableLogInfo || false;
|
|
33
33
|
this.disableLogDeviceInfo = account.disableLogDeviceInfo || false;
|
|
34
34
|
this.enableDebugMode = account.enableDebugMode || false;
|
|
@@ -73,7 +73,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
73
73
|
accountInfoFile: accountInfoFile,
|
|
74
74
|
deviceInfoFile: deviceInfoFile,
|
|
75
75
|
debugLog: account.enableDebugMode,
|
|
76
|
-
refreshInterval:
|
|
76
|
+
refreshInterval: refreshInterval
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
this.melCloudAtw.on('externalIntegrations', (deviceData, deviceState) => {
|
package/src/deviceerv.js
CHANGED
|
@@ -7,7 +7,7 @@ const CONSTANTS = require('./constants.json');
|
|
|
7
7
|
let Accessory, Characteristic, Service, Categories, AccessoryUUID;
|
|
8
8
|
|
|
9
9
|
class DeviceErv extends EventEmitter {
|
|
10
|
-
constructor(api, account, melCloud, accountInfo,
|
|
10
|
+
constructor(api, account, device, melCloud, accountInfo, contextKey, accountName, deviceId, deviceName, deviceTypeText, accountInfoFile, deviceInfoFile, refreshInterval) {
|
|
11
11
|
super();
|
|
12
12
|
|
|
13
13
|
Accessory = api.platformAccessory;
|
|
@@ -17,12 +17,12 @@ class DeviceErv extends EventEmitter {
|
|
|
17
17
|
AccessoryUUID = api.hap.uuid;
|
|
18
18
|
|
|
19
19
|
//account config
|
|
20
|
-
this.displayMode =
|
|
21
|
-
this.temperatureSensor =
|
|
22
|
-
this.temperatureSensorOutdoor =
|
|
23
|
-
this.temperatureSensorSupply =
|
|
24
|
-
this.presetsEnabled =
|
|
25
|
-
this.buttons =
|
|
20
|
+
this.displayMode = device.displayMode || 0;
|
|
21
|
+
this.temperatureSensor = device.temperatureSensor || false;
|
|
22
|
+
this.temperatureSensorOutdoor = device.temperatureSensorOutdoor || false;
|
|
23
|
+
this.temperatureSensorSupply = device.temperatureSensorSupply || false;
|
|
24
|
+
this.presetsEnabled = device.presets || false;
|
|
25
|
+
this.buttons = device.buttons || [];
|
|
26
26
|
this.disableLogInfo = account.disableLogInfo || false;
|
|
27
27
|
this.disableLogDeviceInfo = account.disableLogDeviceInfo || false;
|
|
28
28
|
this.enableDebugMode = account.enableDebugMode || false;
|
|
@@ -67,7 +67,7 @@ class DeviceErv extends EventEmitter {
|
|
|
67
67
|
accountInfoFile: accountInfoFile,
|
|
68
68
|
deviceInfoFile: deviceInfoFile,
|
|
69
69
|
debugLog: account.enableDebugMode,
|
|
70
|
-
refreshInterval:
|
|
70
|
+
refreshInterval: refreshInterval
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
this.melCloudErv.on('externalIntegrations', (deviceData, deviceState) => {
|
package/src/melcloud.js
CHANGED
|
@@ -16,6 +16,7 @@ class MelCloud extends EventEmitter {
|
|
|
16
16
|
this.enableDebugMode = enableDebugMode;
|
|
17
17
|
this.refreshInterval = refreshInterval;
|
|
18
18
|
this.connectForConfig = connectForConfig;
|
|
19
|
+
this.emitReady = true;
|
|
19
20
|
this.contextKey = '';
|
|
20
21
|
this.devicesId = [];
|
|
21
22
|
|
|
@@ -179,14 +180,11 @@ class MelCloud extends EventEmitter {
|
|
|
179
180
|
const deviceInfoFile = `${this.deviceInfoFile}${deviceId}`;
|
|
180
181
|
await this.saveData(deviceInfoFile, deviceInfo);
|
|
181
182
|
const debug = this.enableDebugMode ? this.emit('debug', `Device: ${deviceName} info saved.`) : false;
|
|
182
|
-
|
|
183
|
-
//prepare device if not in devices array
|
|
184
|
-
if (!this.devicesId.includes(deviceId)) {
|
|
185
|
-
this.devicesId.push(deviceId);
|
|
186
|
-
this.emit('checkDevicesListComplete', this.accountInfo, contextKey, deviceInfo);
|
|
187
|
-
}
|
|
188
183
|
};
|
|
189
184
|
|
|
185
|
+
//emit check devices list complete
|
|
186
|
+
const emit = this.emitReady ? this.emit('checkDevicesListComplete', this.accountInfo, contextKey) : false;
|
|
187
|
+
|
|
190
188
|
return true;
|
|
191
189
|
} catch (error) {
|
|
192
190
|
const stop = connectForConfig ? false : this.impulseGenerator.stop();
|