homebridge-melcloud-control 4.3.4-beta.1 → 4.3.4-beta.3
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 +32 -18
- package/package.json +1 -1
- package/src/melcloud.js +0 -1
package/index.js
CHANGED
|
@@ -85,8 +85,22 @@ class MelCloudPlatform {
|
|
|
85
85
|
.on('start', async () => {
|
|
86
86
|
try {
|
|
87
87
|
//melcloud account
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
let configureAccount;
|
|
89
|
+
let timmers = []
|
|
90
|
+
switch (account.type) {
|
|
91
|
+
case 'melcloud':
|
|
92
|
+
timmers = [{ name: 'checkDevicesList', sampling: refreshInterval }];
|
|
93
|
+
configureAccount = new MelCloud(account, accountFile, buildingsFile, devicesFile, true);
|
|
94
|
+
break;
|
|
95
|
+
case 'melcloudhome':
|
|
96
|
+
timmers = [{ name: 'connect', sampling: 3300000 }, { name: 'checkDevicesList', sampling: 3000 }];
|
|
97
|
+
configureAccount = new MelCloudHome(account, accountFile, buildingsFile, devicesFile, true);
|
|
98
|
+
break;
|
|
99
|
+
default:
|
|
100
|
+
if (logLevel.warn) log.warn(`Unknown account type: ${account.type}.`);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
configureAccount.on('success', (msg) => log.success(`${accountName}, ${msg}`))
|
|
90
104
|
.on('info', (msg) => log.info(`${accountName}, ${msg}`))
|
|
91
105
|
.on('debug', (msg) => log.info(`${accountName}, debug: ${msg}`))
|
|
92
106
|
.on('warn', (msg) => log.warn(`${accountName}, ${msg}`))
|
|
@@ -95,30 +109,30 @@ class MelCloudPlatform {
|
|
|
95
109
|
//connect
|
|
96
110
|
let accountInfo;
|
|
97
111
|
try {
|
|
98
|
-
accountInfo = await
|
|
112
|
+
accountInfo = await configureAccount.connect();
|
|
113
|
+
if (!accountInfo.State) {
|
|
114
|
+
if (logLevel.warn) log.warn(`${accountName}, ${accountInfo.Info}`);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
99
117
|
} catch (error) {
|
|
100
118
|
if (logLevel.error) log.error(`${accountName}, Connect error: ${error.message ?? error}`);
|
|
101
119
|
return;
|
|
102
120
|
}
|
|
103
|
-
|
|
104
|
-
if (!accountInfo.State) {
|
|
105
|
-
if (logLevel.warn) log.warn(`${accountName}, ${accountInfo.Info}`);
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
121
|
if (logLevel.success) log.success(accountInfo.Info);
|
|
109
122
|
|
|
110
123
|
//check devices list
|
|
111
124
|
let devicesList;
|
|
112
125
|
try {
|
|
113
|
-
devicesList = await
|
|
126
|
+
devicesList = await configureAccount.checkDevicesList();
|
|
127
|
+
if (!devicesList.State) {
|
|
128
|
+
if (logLevel.warn) log.warn(`${accountName}, ${devicesList.Info}`);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
114
131
|
} catch (error) {
|
|
115
132
|
if (logLevel.error) log.error(`${accountName}, Check devices list error: ${error.message ?? error}`);
|
|
116
133
|
return;
|
|
117
134
|
}
|
|
118
|
-
if (
|
|
119
|
-
if (logLevel.warn) log.warn(`${accountName}, ${devicesList.Info}`);
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
135
|
+
if (logLevel.debug) log.info(devicesList.Info);
|
|
122
136
|
|
|
123
137
|
//configured devices
|
|
124
138
|
const ataDevices = (account.ataDevices || []).filter(device => device.id != null && String(device.id) !== '0');
|
|
@@ -157,7 +171,7 @@ class MelCloudPlatform {
|
|
|
157
171
|
if (logLevel.debug) log.debug(`Default temperature file created: ${defaultTempsFile}`);
|
|
158
172
|
}
|
|
159
173
|
} catch (error) {
|
|
160
|
-
if (logLevel.error) log.error(
|
|
174
|
+
if (logLevel.error) log.error(`${accountName}, ${deviceTypeString}, ${deviceName}, File init error: ${error.message}`);
|
|
161
175
|
continue;
|
|
162
176
|
}
|
|
163
177
|
}
|
|
@@ -192,15 +206,15 @@ class MelCloudPlatform {
|
|
|
192
206
|
api.publishExternalAccessories(PluginName, [accessory]);
|
|
193
207
|
if (logLevel.success) log.success(`${accountName}, ${deviceTypeString}, ${deviceName}, Published as external accessory.`);
|
|
194
208
|
|
|
195
|
-
//start impulse generators
|
|
209
|
+
//start impulse generators for device
|
|
196
210
|
await configuredDevice.startStopImpulseGenerator(true, [{ name: 'checkState', sampling: deviceRefreshInterval }]);
|
|
197
211
|
}
|
|
198
212
|
}
|
|
199
213
|
|
|
200
|
-
|
|
201
|
-
await
|
|
214
|
+
//start account impulse generator
|
|
215
|
+
await configureAccount.impulseGenerator.state(true, timmers, false);
|
|
202
216
|
|
|
203
|
-
//stop impulse generator
|
|
217
|
+
//stop start impulse generator
|
|
204
218
|
await impulseGenerator.state(false);
|
|
205
219
|
} catch (error) {
|
|
206
220
|
if (logLevel.error) log.error(`${accountName}, Start impulse generator error, ${error.message ?? error}, trying again.`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.3.4-beta.
|
|
4
|
+
"version": "4.3.4-beta.3",
|
|
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/melcloud.js
CHANGED
|
@@ -97,7 +97,6 @@ class MelCloud extends EventEmitter {
|
|
|
97
97
|
device.DeviceID = String(device.DeviceID);
|
|
98
98
|
});
|
|
99
99
|
|
|
100
|
-
if (this.logDebug) this.emit('debug', `Found ${allDevices.length} devices in building: ${building.Name || 'Unnamed'}`);
|
|
101
100
|
devices.push(...allDevices);
|
|
102
101
|
}
|
|
103
102
|
|