homebridge-melcloud-control 3.9.8-beta.4 → 3.9.9
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 +27 -16
- package/package.json +3 -3
- package/src/functions.js +0 -5
- package/src/melcloud.js +1 -1
package/index.js
CHANGED
|
@@ -23,7 +23,7 @@ class MelCloudPlatform {
|
|
|
23
23
|
//create directory if it doesn't exist
|
|
24
24
|
mkdirSync(prefDir, { recursive: true });
|
|
25
25
|
} catch (error) {
|
|
26
|
-
log.error(`Prepare directory error: ${error}`);
|
|
26
|
+
log.error(`Prepare directory error: ${error.message ?? error}`);
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -38,13 +38,13 @@ class MelCloudPlatform {
|
|
|
38
38
|
//check mandatory properties
|
|
39
39
|
if (!accountName || !user || !passwd || !language) {
|
|
40
40
|
log.warn(`Name: ${accountName ? 'OK' : accountName}, user: ${user ? 'OK' : user}, password: ${passwd ? 'OK' : passwd}, language: ${language ? 'OK' : language} in config missing.`);
|
|
41
|
-
|
|
41
|
+
continue;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
//check duplicate account name
|
|
45
45
|
if (accountsName.includes(accountName)) {
|
|
46
46
|
log.warn(`Account name: ${accountName}, must be unique.`);
|
|
47
|
-
|
|
47
|
+
continue;
|
|
48
48
|
}
|
|
49
49
|
accountsName.push(accountName);
|
|
50
50
|
|
|
@@ -66,7 +66,7 @@ class MelCloudPlatform {
|
|
|
66
66
|
if (logLevel.debug) log.info(`${accountName}, debug: Did finish launching.`);
|
|
67
67
|
|
|
68
68
|
//remove sensitive data
|
|
69
|
-
const
|
|
69
|
+
const safeConfig = {
|
|
70
70
|
...account,
|
|
71
71
|
passwd: 'removed',
|
|
72
72
|
mqtt: {
|
|
@@ -74,7 +74,7 @@ class MelCloudPlatform {
|
|
|
74
74
|
passwd: 'removed'
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
|
-
if (logLevel.debug) log.info(`${accountName}, Config: ${JSON.stringify(
|
|
77
|
+
if (logLevel.debug) log.info(`${accountName}, Config: ${JSON.stringify(safeConfig, null, 2)}`);
|
|
78
78
|
|
|
79
79
|
//define directory and file paths
|
|
80
80
|
const accountFile = `${prefDir}/${accountName}_Account`;
|
|
@@ -82,7 +82,7 @@ class MelCloudPlatform {
|
|
|
82
82
|
const devicesFile = `${prefDir}/${accountName}_Devices`;
|
|
83
83
|
|
|
84
84
|
//set account refresh interval
|
|
85
|
-
const refreshInterval = account.refreshInterval * 1000
|
|
85
|
+
const refreshInterval = (account.refreshInterval ?? 120) * 1000;
|
|
86
86
|
|
|
87
87
|
try {
|
|
88
88
|
//melcloud account
|
|
@@ -95,20 +95,31 @@ class MelCloudPlatform {
|
|
|
95
95
|
|
|
96
96
|
|
|
97
97
|
//connect
|
|
98
|
-
|
|
98
|
+
let response;
|
|
99
|
+
try {
|
|
100
|
+
response = await melCloud.connect();
|
|
101
|
+
} catch (error) {
|
|
102
|
+
if (logLevel.error) log.error(`${accountName}, Connect error: ${error.message ?? error}`);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
|
|
99
106
|
const accountInfo = response.accountInfo ?? false;
|
|
100
107
|
const contextKey = response.contextKey ?? false;
|
|
101
108
|
const useFahrenheit = response.useFahrenheit ?? false;
|
|
102
109
|
|
|
103
110
|
if (contextKey === false) {
|
|
104
|
-
|
|
111
|
+
continue;
|
|
105
112
|
}
|
|
106
113
|
|
|
107
114
|
//check devices list
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
115
|
+
let devicesInMelcloud;
|
|
116
|
+
try {
|
|
117
|
+
devicesInMelcloud = await melCloud.checkDevicesList(contextKey);
|
|
118
|
+
} catch (error) {
|
|
119
|
+
if (logLevel.error) log.error(`${accountName}, Check devices list error: ${error.message ?? error}`);
|
|
120
|
+
continue;
|
|
111
121
|
}
|
|
122
|
+
if (!devicesInMelcloud || !Array.isArray(devicesInMelcloud)) continue;
|
|
112
123
|
|
|
113
124
|
//start account impulse generator
|
|
114
125
|
await melCloud.impulseGenerator.start([{ name: 'checkDevicesList', sampling: refreshInterval }]);
|
|
@@ -131,7 +142,7 @@ class MelCloudPlatform {
|
|
|
131
142
|
const deviceName = device.name;
|
|
132
143
|
const deviceType = device.type;
|
|
133
144
|
const deviceTypeText = device.typeString;
|
|
134
|
-
const deviceRefreshInterval = device.refreshInterval * 1000
|
|
145
|
+
const deviceRefreshInterval = (device.refreshInterval ?? 5) * 1000;
|
|
135
146
|
try {
|
|
136
147
|
let configuredDevice;
|
|
137
148
|
switch (deviceType) {
|
|
@@ -148,7 +159,7 @@ class MelCloudPlatform {
|
|
|
148
159
|
break;
|
|
149
160
|
default:
|
|
150
161
|
if (logLevel.warn) log.warn(`${accountName}, ${deviceTypeText}, ${deviceName}, unknown device: ${deviceType}.`);
|
|
151
|
-
|
|
162
|
+
continue;
|
|
152
163
|
}
|
|
153
164
|
|
|
154
165
|
configuredDevice.on('melCloud', async (key, value) => {
|
|
@@ -179,7 +190,7 @@ class MelCloudPlatform {
|
|
|
179
190
|
await configuredDevice.startImpulseGenerator();
|
|
180
191
|
}
|
|
181
192
|
} catch (error) {
|
|
182
|
-
if (logLevel.error) log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error}, trying again.`);
|
|
193
|
+
if (logLevel.error) log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error.message ?? error}, trying again.`);
|
|
183
194
|
}
|
|
184
195
|
}).on('state', (state) => {
|
|
185
196
|
if (logLevel.debug) log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, Start impulse generator ${state ? 'started' : 'stopped'}.`);
|
|
@@ -188,11 +199,11 @@ class MelCloudPlatform {
|
|
|
188
199
|
//start impulse generator
|
|
189
200
|
await impulseGenerator.start([{ name: 'start', sampling: 45000 }]);
|
|
190
201
|
} catch (error) {
|
|
191
|
-
if (logLevel.error) log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, did finish launching error: ${error}.`);
|
|
202
|
+
if (logLevel.error) log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, did finish launching error: ${error.message ?? error}.`);
|
|
192
203
|
}
|
|
193
204
|
}
|
|
194
205
|
} catch (error) {
|
|
195
|
-
if (logLevel.error) log.error(`${accountName}, did finish launching error: ${error}.`);
|
|
206
|
+
if (logLevel.error) log.error(`${accountName}, did finish launching error: ${error.message ?? error}.`);
|
|
196
207
|
}
|
|
197
208
|
}
|
|
198
209
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "3.9.
|
|
4
|
+
"version": "3.9.9",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"LICENSE"
|
|
32
32
|
],
|
|
33
33
|
"engines": {
|
|
34
|
-
"homebridge": "^1.9.0 || ^2.0.0 || ^2.0.0-beta.29",
|
|
34
|
+
"homebridge": "^1.9.0 || ^2.0.0 || ^2.0.0-beta.29 || ^2.0.0-alpha.6",
|
|
35
35
|
"node": "^20 || ^22 || ^24"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@homebridge/plugin-ui-utils": "^2.1.0",
|
|
39
39
|
"async-mqtt": "^2.6.3",
|
|
40
|
-
"axios": "^1.
|
|
40
|
+
"axios": "^1.12.1",
|
|
41
41
|
"express": "^5.1.0"
|
|
42
42
|
},
|
|
43
43
|
"keywords": [
|
package/src/functions.js
CHANGED
|
@@ -22,10 +22,5 @@ class Functions {
|
|
|
22
22
|
throw new Error(`Read data error: ${error}`);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
async scaleValue(value, inMin, inMax, outMin, outMax) {
|
|
27
|
-
const scaledValue = parseFloat((((Math.max(inMin, Math.min(inMax, value)) - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin).toFixed(0));
|
|
28
|
-
return scaledValue;
|
|
29
|
-
}
|
|
30
25
|
}
|
|
31
26
|
export default Functions
|