homebridge-melcloud-control 3.6.1-beta.1 → 3.6.1
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/CHANGELOG.md +9 -0
- package/index.js +19 -19
- package/package.json +1 -1
- package/src/deviceata.js +5 -5
- package/src/deviceatw.js +8 -8
- package/src/deviceerv.js +4 -4
- package/src/melcloud.js +13 -13
- package/src/melcloudata.js +4 -4
- package/src/melcloudatw.js +4 -4
- package/src/melclouderv.js +4 -4
- package/src/mqtt.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -16,6 +16,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
16
16
|
- do not configure it manually, always using Config UI X
|
|
17
17
|
- required Homebridge v2.0.0 and above
|
|
18
18
|
|
|
19
|
+
## [3.6.1] - (29.01.2025)
|
|
20
|
+
|
|
21
|
+
## Changes
|
|
22
|
+
|
|
23
|
+
- refactor cnnect and reconnect code
|
|
24
|
+
- refactor external integrations MQTT and RESTFul
|
|
25
|
+
- update logging
|
|
26
|
+
- cleanup
|
|
27
|
+
|
|
19
28
|
## [3.6.0] - (29.01.2025)
|
|
20
29
|
|
|
21
30
|
## Changes
|
package/index.js
CHANGED
|
@@ -80,16 +80,16 @@ class MelCloudPlatform {
|
|
|
80
80
|
//melcloud account
|
|
81
81
|
const melCloud = new MelCloud(user, passwd, language, accountFile, buildingsFile, devicesFile, enableDebugMode, false);
|
|
82
82
|
melCloud.on('success', (success) => {
|
|
83
|
-
const emitLog = disableLogSuccess ? false : log.success(`${accountName}, ${success}
|
|
83
|
+
const emitLog = disableLogSuccess ? false : log.success(`${accountName}, ${success}.`);
|
|
84
84
|
})
|
|
85
85
|
.on('info', (info) => {
|
|
86
|
-
const emitLog = disableLogInfo ? false : log.info(`${accountName}, ${info}
|
|
86
|
+
const emitLog = disableLogInfo ? false : log.info(`${accountName}, ${info}.`);
|
|
87
87
|
})
|
|
88
88
|
.on('debug', (debug) => {
|
|
89
|
-
const emitLog = !enableDebugMode ? false : log.info(`${accountName}, debug: ${debug}
|
|
89
|
+
const emitLog = !enableDebugMode ? false : log.info(`${accountName}, debug: ${debug}.`);
|
|
90
90
|
})
|
|
91
91
|
.on('warn', (warn) => {
|
|
92
|
-
const emitLog = disableLogWarn ? false : log.warn(`${accountName}, ${warn}
|
|
92
|
+
const emitLog = disableLogWarn ? false : log.warn(`${accountName}, ${warn}.`);
|
|
93
93
|
})
|
|
94
94
|
.on('error', (error) => {
|
|
95
95
|
const emitLog = disableLogError ? false : log.error(`${accountName}, ${error}.`);
|
|
@@ -140,19 +140,19 @@ class MelCloudPlatform {
|
|
|
140
140
|
const emitLog = disableLogDeviceInfo ? false : log.info(devInfo);
|
|
141
141
|
})
|
|
142
142
|
.on('success', (success) => {
|
|
143
|
-
const emitLog = disableLogSuccess ? false : log.success(`${accountName}, ${deviceTypeText}, ${deviceName}, ${success}
|
|
143
|
+
const emitLog = disableLogSuccess ? false : log.success(`${accountName}, ${deviceTypeText}, ${deviceName}, ${success}.`);
|
|
144
144
|
})
|
|
145
145
|
.on('info', (info) => {
|
|
146
|
-
const emitLog = disableLogInfo ? false : log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, ${info}
|
|
146
|
+
const emitLog = disableLogInfo ? false : log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, ${info}.`);
|
|
147
147
|
})
|
|
148
148
|
.on('debug', (debug) => {
|
|
149
|
-
const emitLog = !enableDebugMode ? false : log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, debug: ${debug}
|
|
149
|
+
const emitLog = !enableDebugMode ? false : log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, debug: ${debug}.`);
|
|
150
150
|
})
|
|
151
151
|
.on('warn', (warn) => {
|
|
152
|
-
const emitLog = disableLogWarn ? false : log.warn(`${accountName}, ${deviceTypeText}, ${deviceName}, ${warn}
|
|
152
|
+
const emitLog = disableLogWarn ? false : log.warn(`${accountName}, ${deviceTypeText}, ${deviceName}, ${warn}.`);
|
|
153
153
|
})
|
|
154
154
|
.on('error', (error) => {
|
|
155
|
-
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error}
|
|
155
|
+
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error}.`);
|
|
156
156
|
});
|
|
157
157
|
|
|
158
158
|
//create impulse generator
|
|
@@ -200,19 +200,19 @@ class MelCloudPlatform {
|
|
|
200
200
|
const emitLog = disableLogDeviceInfo ? false : log.info(devInfo);
|
|
201
201
|
})
|
|
202
202
|
.on('success', (success) => {
|
|
203
|
-
const emitLog = disableLogSuccess ? false : log.success(`${accountName}, ${deviceTypeText}, ${deviceName}, ${success}
|
|
203
|
+
const emitLog = disableLogSuccess ? false : log.success(`${accountName}, ${deviceTypeText}, ${deviceName}, ${success}.`);
|
|
204
204
|
})
|
|
205
205
|
.on('info', (info) => {
|
|
206
|
-
const emitLog = disableLogInfo ? false : log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, ${info}
|
|
206
|
+
const emitLog = disableLogInfo ? false : log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, ${info}.`);
|
|
207
207
|
})
|
|
208
208
|
.on('debug', (debug) => {
|
|
209
|
-
const emitLog = !enableDebugMode ? false : log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, debug: ${debug}
|
|
209
|
+
const emitLog = !enableDebugMode ? false : log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, debug: ${debug}.`);
|
|
210
210
|
})
|
|
211
211
|
.on('warn', (warn) => {
|
|
212
|
-
const emitLog = disableLogWarn ? false : log.warn(`${accountName}, ${deviceTypeText}, ${deviceName}, ${warn}
|
|
212
|
+
const emitLog = disableLogWarn ? false : log.warn(`${accountName}, ${deviceTypeText}, ${deviceName}, ${warn}.`);
|
|
213
213
|
})
|
|
214
214
|
.on('error', (error) => {
|
|
215
|
-
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error}
|
|
215
|
+
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error}.`);
|
|
216
216
|
});
|
|
217
217
|
|
|
218
218
|
//create impulse generator
|
|
@@ -260,19 +260,19 @@ class MelCloudPlatform {
|
|
|
260
260
|
const emitLog = disableLogDeviceInfo ? false : log.info(devInfo);
|
|
261
261
|
})
|
|
262
262
|
.on('success', (success) => {
|
|
263
|
-
const emitLog = disableLogSuccess ? false : log.success(`${accountName}, ${deviceTypeText}, ${deviceName}, ${success}
|
|
263
|
+
const emitLog = disableLogSuccess ? false : log.success(`${accountName}, ${deviceTypeText}, ${deviceName}, ${success}.`);
|
|
264
264
|
})
|
|
265
265
|
.on('info', (info) => {
|
|
266
|
-
const emitLog = disableLogInfo ? false : log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, ${info}
|
|
266
|
+
const emitLog = disableLogInfo ? false : log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, ${info}.`);
|
|
267
267
|
})
|
|
268
268
|
.on('debug', (debug) => {
|
|
269
|
-
const emitLog = !enableDebugMode ? false : log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, debug: ${debug}
|
|
269
|
+
const emitLog = !enableDebugMode ? false : log.info(`${accountName}, ${deviceTypeText}, ${deviceName}, debug: ${debug}.`);
|
|
270
270
|
})
|
|
271
271
|
.on('warn', (warn) => {
|
|
272
|
-
const emitLog = disableLogWarn ? false : log.warn(`${accountName}, ${deviceTypeText}, ${deviceName}, ${warn}
|
|
272
|
+
const emitLog = disableLogWarn ? false : log.warn(`${accountName}, ${deviceTypeText}, ${deviceName}, ${warn}.`);
|
|
273
273
|
})
|
|
274
274
|
.on('error', (error) => {
|
|
275
|
-
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error}
|
|
275
|
+
const emitLog = disableLogError ? false : log.error(`${accountName}, ${deviceTypeText}, ${deviceName}, ${error}.`);
|
|
276
276
|
});
|
|
277
277
|
|
|
278
278
|
//create impulse generator
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "3.6.1
|
|
4
|
+
"version": "3.6.1",
|
|
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
|
@@ -63,7 +63,7 @@ class DeviceAta extends EventEmitter {
|
|
|
63
63
|
preset.previousSettings = {};
|
|
64
64
|
this.presetsConfigured.push(preset);
|
|
65
65
|
} else {
|
|
66
|
-
const log = presetDisplayType === 0 ? false : this.emit('warn', `Preset Name: ${preset ? preset : 'Missing'}
|
|
66
|
+
const log = presetDisplayType === 0 ? false : this.emit('warn', `Preset Name: ${preset ? preset : 'Missing'}`);
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
this.presetsConfiguredCount = this.presetsConfigured.length || 0;
|
|
@@ -85,7 +85,7 @@ class DeviceAta extends EventEmitter {
|
|
|
85
85
|
button.previousValue = null;
|
|
86
86
|
this.buttonsConfigured.push(button);
|
|
87
87
|
} else {
|
|
88
|
-
const log = buttonDisplayType === 0 ? false : this.emit('warn', `Button Name: ${buttonName ? buttonName : 'Missing'}, Mode: ${buttonMode ? buttonMode : 'Missing'}
|
|
88
|
+
const log = buttonDisplayType === 0 ? false : this.emit('warn', `Button Name: ${buttonName ? buttonName : 'Missing'}, Mode: ${buttonMode ? buttonMode : 'Missing'}`);
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
this.buttonsConfiguredCount = this.buttonsConfigured.length || 0;
|
|
@@ -246,7 +246,7 @@ class DeviceAta extends EventEmitter {
|
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
248
|
} catch (error) {
|
|
249
|
-
this.emit('warn', `External integration start error: ${error}
|
|
249
|
+
this.emit('warn', `External integration start error: ${error}`);
|
|
250
250
|
};
|
|
251
251
|
}
|
|
252
252
|
|
|
@@ -963,7 +963,7 @@ class DeviceAta extends EventEmitter {
|
|
|
963
963
|
this.firmwareRevision = firmwareAppVersion;
|
|
964
964
|
this.displayDeviceInfo = false;
|
|
965
965
|
})
|
|
966
|
-
.on('deviceState',
|
|
966
|
+
.on('deviceState', (deviceData) => {
|
|
967
967
|
this.deviceData = deviceData;
|
|
968
968
|
|
|
969
969
|
//presets
|
|
@@ -1332,7 +1332,7 @@ class DeviceAta extends EventEmitter {
|
|
|
1332
1332
|
button.state = (prohibitSetTemperature === true);
|
|
1333
1333
|
break;
|
|
1334
1334
|
default: //Unknown button
|
|
1335
|
-
this.emit('message', `Unknown button mode: ${mode} detected
|
|
1335
|
+
this.emit('message', `Unknown button mode: ${mode} detected`);
|
|
1336
1336
|
break;
|
|
1337
1337
|
};
|
|
1338
1338
|
|
package/src/deviceatw.js
CHANGED
|
@@ -67,7 +67,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
67
67
|
preset.previousSettings = {};
|
|
68
68
|
this.presetsConfigured.push(preset);
|
|
69
69
|
} else {
|
|
70
|
-
const log = presetDisplayType === 0 ? false : this.emit('warn', `Preset Name: ${preset ? preset : 'Missing'}
|
|
70
|
+
const log = presetDisplayType === 0 ? false : this.emit('warn', `Preset Name: ${preset ? preset : 'Missing'}`);
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
73
|
this.presetsConfiguredCount = this.presetsConfigured.length || 0;
|
|
@@ -89,13 +89,13 @@ class DeviceAtw extends EventEmitter {
|
|
|
89
89
|
button.previousValue = null;
|
|
90
90
|
this.buttonsConfigured.push(button);
|
|
91
91
|
} else {
|
|
92
|
-
const log = buttonDisplayType === 0 ? false : this.emit('warn', `Button Name: ${buttonName ? buttonName : 'Missing'}, Mode: ${buttonMode ? buttonMode : 'Missing'}
|
|
92
|
+
const log = buttonDisplayType === 0 ? false : this.emit('warn', `Button Name: ${buttonName ? buttonName : 'Missing'}, Mode: ${buttonMode ? buttonMode : 'Missing'}`);
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
95
|
this.buttonsConfiguredCount = this.buttonsConfigured.length || 0;
|
|
96
96
|
|
|
97
97
|
//device data
|
|
98
|
-
this.deviceData
|
|
98
|
+
this.deviceData = {};
|
|
99
99
|
|
|
100
100
|
//accessory
|
|
101
101
|
this.accessory = { zones: [{}, {}, {}, {}] };
|
|
@@ -270,7 +270,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
272
|
} catch (error) {
|
|
273
|
-
this.emit('warn', `External integration start error: ${error}
|
|
273
|
+
this.emit('warn', `External integration start error: ${error}`);
|
|
274
274
|
};
|
|
275
275
|
}
|
|
276
276
|
|
|
@@ -1320,7 +1320,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1320
1320
|
this.firmwareRevision = firmwareAppVersion;
|
|
1321
1321
|
this.displayDeviceInfo = false;
|
|
1322
1322
|
})
|
|
1323
|
-
.on('deviceState',
|
|
1323
|
+
.on('deviceState', (deviceData) => {
|
|
1324
1324
|
this.deviceData = deviceData;
|
|
1325
1325
|
|
|
1326
1326
|
//presets
|
|
@@ -1527,7 +1527,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1527
1527
|
operationModeSetPropsValidValues = [[0, 1, 2], [0, 1, 2], [1, 2], [0]][heatCoolModes];
|
|
1528
1528
|
break;
|
|
1529
1529
|
default: //unknown zone detected
|
|
1530
|
-
this.emit('message', `Unknown zone: ${i} detected
|
|
1530
|
+
this.emit('message', `Unknown zone: ${i} detected`);
|
|
1531
1531
|
break;
|
|
1532
1532
|
};
|
|
1533
1533
|
|
|
@@ -1637,7 +1637,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1637
1637
|
operationModeSetPropsValidValues = [[1, 2, 3], [1, 2, 3], [1, 2], [0]][heatCoolModes];
|
|
1638
1638
|
break;
|
|
1639
1639
|
default: //unknown zone detected
|
|
1640
|
-
this.emit('message', `Unknown zone: ${i} detected
|
|
1640
|
+
this.emit('message', `Unknown zone: ${i} detected`);
|
|
1641
1641
|
break;
|
|
1642
1642
|
};
|
|
1643
1643
|
|
|
@@ -1891,7 +1891,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1891
1891
|
button.state = (prohibitZone2 === true);
|
|
1892
1892
|
break;
|
|
1893
1893
|
default: //Unknown button
|
|
1894
|
-
this.emit('warn', `Unknown button mode: ${mode} detected
|
|
1894
|
+
this.emit('warn', `Unknown button mode: ${mode} detected`);
|
|
1895
1895
|
break;
|
|
1896
1896
|
};
|
|
1897
1897
|
|
package/src/deviceerv.js
CHANGED
|
@@ -61,7 +61,7 @@ class DeviceErv extends EventEmitter {
|
|
|
61
61
|
preset.previousSettings = {};
|
|
62
62
|
this.presetsConfigured.push(preset);
|
|
63
63
|
} else {
|
|
64
|
-
const log = presetDisplayType === 0 ? false : this.emit('warn', `Preset Name: ${preset ? preset : 'Missing'}
|
|
64
|
+
const log = presetDisplayType === 0 ? false : this.emit('warn', `Preset Name: ${preset ? preset : 'Missing'}`);
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
this.presetsConfiguredCount = this.presetsConfigured.length || 0;
|
|
@@ -83,7 +83,7 @@ class DeviceErv extends EventEmitter {
|
|
|
83
83
|
button.previousValue = null;
|
|
84
84
|
this.buttonsConfigured.push(button);
|
|
85
85
|
} else {
|
|
86
|
-
const log = buttonDisplayType === 0 ? false : this.emit('warn', `Button Name: ${buttonName ? buttonName : 'Missing'}, Mode: ${buttonMode ? buttonMode : 'Missing'}
|
|
86
|
+
const log = buttonDisplayType === 0 ? false : this.emit('warn', `Button Name: ${buttonName ? buttonName : 'Missing'}, Mode: ${buttonMode ? buttonMode : 'Missing'}`);
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
this.buttonsConfiguredCount = this.buttonsConfigured.length || 0;
|
|
@@ -809,7 +809,7 @@ class DeviceErv extends EventEmitter {
|
|
|
809
809
|
this.firmwareRevision = firmwareAppVersion;
|
|
810
810
|
this.displayDeviceInfo = false;
|
|
811
811
|
})
|
|
812
|
-
.on('deviceState',
|
|
812
|
+
.on('deviceState', (deviceData) => {
|
|
813
813
|
this.deviceData = deviceData;
|
|
814
814
|
|
|
815
815
|
//presets
|
|
@@ -1123,7 +1123,7 @@ class DeviceErv extends EventEmitter {
|
|
|
1123
1123
|
button.state = (hideOutdoorTemperature === true);
|
|
1124
1124
|
break;
|
|
1125
1125
|
default: //Unknown button
|
|
1126
|
-
this.emit('warn', `Unknown button mode: ${mode} detected
|
|
1126
|
+
this.emit('warn', `Unknown button mode: ${mode} detected`);
|
|
1127
1127
|
break;
|
|
1128
1128
|
};
|
|
1129
1129
|
|
package/src/melcloud.js
CHANGED
|
@@ -34,16 +34,16 @@ class MelCloud extends EventEmitter {
|
|
|
34
34
|
try {
|
|
35
35
|
await this.chackDevicesList(this.contextKey);
|
|
36
36
|
} catch (error) {
|
|
37
|
-
this.emit('error', `Impulse generator error: ${error}
|
|
37
|
+
this.emit('error', `Impulse generator error: ${error}`);
|
|
38
38
|
};
|
|
39
39
|
}).on('state', (state) => {
|
|
40
|
-
const emitState = state ? this.emit('success', `Impulse generator started
|
|
40
|
+
const emitState = state ? this.emit('success', `Impulse generator started`) : this.emit('warn', `Impulse generator stopped`);
|
|
41
41
|
});
|
|
42
42
|
};
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
async connect() {
|
|
46
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Connecting to MELCloud
|
|
46
|
+
const debug = this.enableDebugMode ? this.emit('debug', `Connecting to MELCloud`) : false;
|
|
47
47
|
|
|
48
48
|
try {
|
|
49
49
|
const axiosInstanceLogin = axios.create({
|
|
@@ -78,7 +78,7 @@ class MelCloud extends EventEmitter {
|
|
|
78
78
|
const debug1 = this.enableDebugMode ? this.emit('debug', `MELCloud Info: ${JSON.stringify(debugData, null, 2)}`) : false;
|
|
79
79
|
|
|
80
80
|
if (contextKey === undefined || contextKey === null) {
|
|
81
|
-
this.emit('warn', `Context key: ${contextKey}, missing
|
|
81
|
+
this.emit('warn', `Context key: ${contextKey}, missing`)
|
|
82
82
|
return false;
|
|
83
83
|
};
|
|
84
84
|
|
|
@@ -104,7 +104,7 @@ class MelCloud extends EventEmitter {
|
|
|
104
104
|
await this.saveData(this.accountFile, accountInfo);
|
|
105
105
|
|
|
106
106
|
//emit connect success
|
|
107
|
-
this.emit('success', `Connect to MELCloud Success
|
|
107
|
+
this.emit('success', `Connect to MELCloud Success`)
|
|
108
108
|
|
|
109
109
|
const obj = {
|
|
110
110
|
accountInfo: accountInfo,
|
|
@@ -114,7 +114,7 @@ class MelCloud extends EventEmitter {
|
|
|
114
114
|
|
|
115
115
|
return obj;
|
|
116
116
|
} catch (error) {
|
|
117
|
-
throw new Error(`Connect to MELCloud error: ${error.message || error}
|
|
117
|
+
throw new Error(`Connect to MELCloud error: ${error.message || error}`);
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
120
|
|
|
@@ -137,19 +137,19 @@ class MelCloud extends EventEmitter {
|
|
|
137
137
|
})
|
|
138
138
|
});
|
|
139
139
|
|
|
140
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Scanning for devices
|
|
140
|
+
const debug = this.enableDebugMode ? this.emit('debug', `Scanning for devices`) : false;
|
|
141
141
|
const listDevicesData = await axiosInstanceGet(ApiUrls.ListDevices);
|
|
142
142
|
const buildingsList = listDevicesData.data;
|
|
143
143
|
const debug1 = this.enableDebugMode ? this.emit('debug', `Buildings: ${JSON.stringify(buildingsList, null, 2)}`) : false;
|
|
144
144
|
|
|
145
145
|
if (!buildingsList) {
|
|
146
|
-
this.emit('warn', `No building found
|
|
146
|
+
this.emit('warn', `No building found`);
|
|
147
147
|
return false;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
//save buildings to the file
|
|
151
151
|
await this.saveData(this.buildingsFile, buildingsList);
|
|
152
|
-
const debug2 = this.enableDebugMode ? this.emit('debug', `Buildings list saved
|
|
152
|
+
const debug2 = this.enableDebugMode ? this.emit('debug', `Buildings list saved`) : false;
|
|
153
153
|
|
|
154
154
|
//read buildings structure and get the devices
|
|
155
155
|
const devices = [];
|
|
@@ -169,24 +169,24 @@ class MelCloud extends EventEmitter {
|
|
|
169
169
|
|
|
170
170
|
const devicesCount = devices.length;
|
|
171
171
|
if (devicesCount === 0) {
|
|
172
|
-
this.emit('warn', `No devices found
|
|
172
|
+
this.emit('warn', `No devices found`);
|
|
173
173
|
return false;
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
//save buildings to the file
|
|
177
177
|
await this.saveData(this.devicesFile, devices);
|
|
178
|
-
const debug3 = this.enableDebugMode ? this.emit('debug', `${devicesCount} devices saved
|
|
178
|
+
const debug3 = this.enableDebugMode ? this.emit('debug', `${devicesCount} devices saved`) : false;
|
|
179
179
|
|
|
180
180
|
return devices;
|
|
181
181
|
} catch (error) {
|
|
182
|
-
throw new Error(`Check devices list error: ${error.message || error}
|
|
182
|
+
throw new Error(`Check devices list error: ${error.message || error}`);
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
async saveData(path, data) {
|
|
187
187
|
try {
|
|
188
188
|
await fsPromises.writeFile(path, JSON.stringify(data, null, 2));
|
|
189
|
-
const debug3 = this.enableDebugMode ? this.emit('debug', `Data saved to: ${path}
|
|
189
|
+
const debug3 = this.enableDebugMode ? this.emit('debug', `Data saved to: ${path}`) : false;
|
|
190
190
|
return true;
|
|
191
191
|
} catch (error) {
|
|
192
192
|
throw new Error(`Save data error: ${error.message || error}`);
|
package/src/melcloudata.js
CHANGED
|
@@ -35,10 +35,10 @@ class MelCloudAta extends EventEmitter {
|
|
|
35
35
|
try {
|
|
36
36
|
await this.checkState();
|
|
37
37
|
} catch (error) {
|
|
38
|
-
this.emit('error', `Impulse generator error: ${error}
|
|
38
|
+
this.emit('error', `Impulse generator error: ${error}`);
|
|
39
39
|
};
|
|
40
40
|
}).on('state', (state) => {
|
|
41
|
-
const emitState = state ? this.emit('success', `Impulse generator started
|
|
41
|
+
const emitState = state ? this.emit('success', `Impulse generator started`) : this.emit('warn', `Impulse generator stopped`);
|
|
42
42
|
});
|
|
43
43
|
};
|
|
44
44
|
|
|
@@ -48,7 +48,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
48
48
|
const devicesData = await this.readData(this.devicesFile);
|
|
49
49
|
|
|
50
50
|
if (!Array.isArray(devicesData)) {
|
|
51
|
-
this.emit('warn', `Device data not found
|
|
51
|
+
this.emit('warn', `Device data not found`);
|
|
52
52
|
return false;
|
|
53
53
|
}
|
|
54
54
|
const deviceData = devicesData.find(device => device.DeviceID === this.deviceId);
|
|
@@ -307,7 +307,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
307
307
|
|
|
308
308
|
//display info if units are not configured in MELCloud service
|
|
309
309
|
if (unitsCount === 0) {
|
|
310
|
-
this.emit('warn', `Units are not configured in MELCloud service
|
|
310
|
+
this.emit('warn', `Units are not configured in MELCloud service`);
|
|
311
311
|
};
|
|
312
312
|
|
|
313
313
|
const deviceState = {
|
package/src/melcloudatw.js
CHANGED
|
@@ -35,10 +35,10 @@ class MelCloudAtw extends EventEmitter {
|
|
|
35
35
|
try {
|
|
36
36
|
await this.checkState();
|
|
37
37
|
} catch (error) {
|
|
38
|
-
this.emit('error', `Impulse generator error: ${error}
|
|
38
|
+
this.emit('error', `Impulse generator error: ${error}`);
|
|
39
39
|
};
|
|
40
40
|
}).on('state', (state) => {
|
|
41
|
-
const emitState = state ? this.emit('success', `Impulse generator started
|
|
41
|
+
const emitState = state ? this.emit('success', `Impulse generator started`) : this.emit('warn', `Impulse generator stopped`);
|
|
42
42
|
});
|
|
43
43
|
};
|
|
44
44
|
|
|
@@ -48,7 +48,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
48
48
|
const devicesData = await this.readData(this.devicesFile);
|
|
49
49
|
|
|
50
50
|
if (!Array.isArray(devicesData)) {
|
|
51
|
-
this.emit('warn', `Device data not found
|
|
51
|
+
this.emit('warn', `Device data not found`);
|
|
52
52
|
return false;
|
|
53
53
|
}
|
|
54
54
|
const deviceData = devicesData.find(device => device.DeviceID === this.deviceId);
|
|
@@ -366,7 +366,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
366
366
|
|
|
367
367
|
//display info if units are not configured in MELCloud service
|
|
368
368
|
if (unitsCount === 0) {
|
|
369
|
-
this.emit('message', `Units are not configured in MELCloud service
|
|
369
|
+
this.emit('message', `Units are not configured in MELCloud service`);
|
|
370
370
|
};
|
|
371
371
|
|
|
372
372
|
const deviceState = {
|
package/src/melclouderv.js
CHANGED
|
@@ -35,10 +35,10 @@ class MelCloudErv extends EventEmitter {
|
|
|
35
35
|
try {
|
|
36
36
|
await this.checkState();
|
|
37
37
|
} catch (error) {
|
|
38
|
-
this.emit('error', `Impulse generator error: ${error}
|
|
38
|
+
this.emit('error', `Impulse generator error: ${error}`);
|
|
39
39
|
};
|
|
40
40
|
}).on('state', (state) => {
|
|
41
|
-
const emitState = state ? this.emit('success', `Impulse generator started
|
|
41
|
+
const emitState = state ? this.emit('success', `Impulse generator started`) : this.emit('warn', `Impulse generator stopped`);
|
|
42
42
|
});
|
|
43
43
|
};
|
|
44
44
|
|
|
@@ -48,7 +48,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
48
48
|
const devicesData = await this.readData(this.devicesFile);
|
|
49
49
|
|
|
50
50
|
if (!Array.isArray(devicesData)) {
|
|
51
|
-
this.emit('warn', `Device data not found
|
|
51
|
+
this.emit('warn', `Device data not found`);
|
|
52
52
|
return false;
|
|
53
53
|
}
|
|
54
54
|
const deviceData = devicesData.find(device => device.DeviceID === this.deviceId);
|
|
@@ -293,7 +293,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
293
293
|
|
|
294
294
|
//display info if units are not configured in MELCloud service
|
|
295
295
|
if (unitsCount === 0) {
|
|
296
|
-
this.emit('message', `Units are not configured in MELCloud service
|
|
296
|
+
this.emit('message', `Units are not configured in MELCloud service`);
|
|
297
297
|
};
|
|
298
298
|
|
|
299
299
|
const deviceState = {
|
package/src/mqtt.js
CHANGED
|
@@ -21,7 +21,7 @@ class Mqtt extends EventEmitter {
|
|
|
21
21
|
|
|
22
22
|
//subscribe
|
|
23
23
|
await this.mqttClient.subscribe(subscribeTopic);
|
|
24
|
-
this.emit('subscribed', `MQTT Subscribe topic: ${subscribeTopic}
|
|
24
|
+
this.emit('subscribed', `MQTT Subscribe topic: ${subscribeTopic}`);
|
|
25
25
|
|
|
26
26
|
//subscribed message
|
|
27
27
|
this.mqttClient.on('message', (topic, message) => {
|