homebridge-melcloud-control 3.9.0-beta.8 → 3.9.0
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 +11 -1
- package/homebridge-ui/public/index.html +99 -197
- package/package.json +1 -1
- package/src/deviceata.js +21 -21
- package/src/deviceatw.js +26 -26
- package/src/deviceerv.js +22 -22
- package/src/melcloud.js +7 -7
- package/src/melcloudata.js +2 -2
- package/src/melcloudatw.js +2 -2
- package/src/melclouderv.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -16,6 +16,16 @@ 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.9.0] - (18.08.2025)
|
|
20
|
+
|
|
21
|
+
## Changes
|
|
22
|
+
|
|
23
|
+
- Config UI CONECT TO MELCLOUD updated
|
|
24
|
+
- automayically remove devices not existed in melcloud
|
|
25
|
+
- show/hide password
|
|
26
|
+
|
|
27
|
+
- cleanup
|
|
28
|
+
|
|
19
29
|
## [3.8.14] - (26.06.2025)
|
|
20
30
|
|
|
21
31
|
## Changes
|
|
@@ -24,7 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
24
34
|
- fix [#205](https://github.com/grzegorz914/homebridge-melcloud-control/issues/205)
|
|
25
35
|
- RESTFul code refactor
|
|
26
36
|
|
|
27
|
-
|
|
37
|
+
## [3.8.13] - (26.06.2025)
|
|
28
38
|
|
|
29
39
|
## Changes
|
|
30
40
|
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
<form id="configForm">
|
|
21
21
|
<div class="text-center">
|
|
22
22
|
<label id="accountName" class="fw-bold" style="font-size: 23px;">Account</label><br>
|
|
23
|
-
<label id="info" class="d-block" style="font-size:
|
|
24
|
-
<label id="info1" class="d-block" style="font-size:
|
|
25
|
-
<label id="info2" class="d-block" style="font-size:
|
|
23
|
+
<label id="info" class="d-block" style="font-size: 14px;"></label>
|
|
24
|
+
<label id="info1" class="d-block" style="font-size: 12px;"></label>
|
|
25
|
+
<label id="info2" class="d-block" style="font-size: 12px;"></label>
|
|
26
26
|
</div>
|
|
27
27
|
|
|
28
28
|
<div class="mb-3">
|
|
@@ -35,7 +35,6 @@
|
|
|
35
35
|
<input id="user" type="text" class="form-control" required>
|
|
36
36
|
</div>
|
|
37
37
|
|
|
38
|
-
<!-- Password field with toggle -->
|
|
39
38
|
<div class="mb-3 position-relative">
|
|
40
39
|
<label for="passwd" class="form-label">Password</label>
|
|
41
40
|
<div class="input-group">
|
|
@@ -96,67 +95,78 @@
|
|
|
96
95
|
homebridge.showSchemaForm();
|
|
97
96
|
return;
|
|
98
97
|
}
|
|
99
|
-
this.configButtonState = false;
|
|
100
98
|
|
|
101
|
-
const accountsCount = pluginConfig[0].accounts.length;
|
|
102
99
|
this.deviceIndex = 0;
|
|
100
|
+
|
|
101
|
+
const accountsCount = pluginConfig[0].accounts.length;
|
|
103
102
|
for (let i = 0; i < accountsCount; i++) {
|
|
104
103
|
const button = document.createElement("button");
|
|
105
|
-
button.
|
|
106
|
-
button.
|
|
107
|
-
button.
|
|
104
|
+
button.type = "button";
|
|
105
|
+
button.id = `button${i}`;
|
|
106
|
+
button.className = "btn btn-primary";
|
|
108
107
|
button.style.textTransform = 'none';
|
|
109
108
|
button.innerText = pluginConfig[0].accounts[i].name;
|
|
110
109
|
document.getElementById("accountButton").appendChild(button);
|
|
111
110
|
|
|
112
|
-
|
|
111
|
+
button.addEventListener('click', async () => {
|
|
113
112
|
for (let j = 0; j < accountsCount; j++) {
|
|
114
|
-
j === i
|
|
115
|
-
? document.getElementById(`button${j}`).setAttribute("class", "btn btn-secondary")
|
|
116
|
-
: document.getElementById(`button${j}`).setAttribute("class", "btn btn-primary");
|
|
113
|
+
document.getElementById(`button${j}`).className = (j === i ? 'btn btn-secondary' : 'btn btn-primary');
|
|
117
114
|
}
|
|
118
115
|
|
|
119
|
-
|
|
120
|
-
document.getElementById('
|
|
121
|
-
document.getElementById('
|
|
122
|
-
document.getElementById('
|
|
123
|
-
document.getElementById('
|
|
116
|
+
const acc = pluginConfig[0].accounts[i];
|
|
117
|
+
document.getElementById('accountName').innerText = acc.name || '';
|
|
118
|
+
document.getElementById('name').value = acc.name || '';
|
|
119
|
+
document.getElementById('user').value = acc.user || '';
|
|
120
|
+
document.getElementById('passwd').value = acc.passwd || '';
|
|
121
|
+
document.getElementById('language').value = acc.language || '';
|
|
124
122
|
|
|
125
|
-
|
|
126
|
-
document.getElementById('logIn').disabled = !accountConfigured;
|
|
123
|
+
document.getElementById('logIn').disabled = !(acc.name && acc.user && acc.passwd && acc.language);
|
|
127
124
|
|
|
128
|
-
await homebridge.updatePluginConfig(pluginConfig);
|
|
129
125
|
this.deviceIndex = i;
|
|
130
|
-
});
|
|
131
|
-
if (i === accountsCount - 1) {
|
|
132
|
-
document.getElementById(`button0`).click();
|
|
133
126
|
await homebridge.updatePluginConfig(pluginConfig);
|
|
134
|
-
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
if (i === accountsCount - 1) document.getElementById(`button0`).click();
|
|
135
130
|
}
|
|
136
131
|
|
|
137
132
|
document.getElementById('melCloudAccount').style.display = 'block';
|
|
138
133
|
|
|
139
134
|
document.getElementById('configForm').addEventListener('input', async () => {
|
|
140
|
-
pluginConfig[0].accounts[this.deviceIndex]
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
135
|
+
const acc = pluginConfig[0].accounts[this.deviceIndex];
|
|
136
|
+
acc.name = document.querySelector('#name').value;
|
|
137
|
+
acc.user = document.querySelector('#user').value;
|
|
138
|
+
acc.passwd = document.querySelector('#passwd').value;
|
|
139
|
+
acc.language = document.querySelector('#language').value;
|
|
144
140
|
|
|
145
|
-
|
|
146
|
-
document.getElementById('logIn').disabled = !accountConfigured;
|
|
141
|
+
document.getElementById('logIn').disabled = !(acc.name && acc.user && acc.passwd && acc.language);
|
|
147
142
|
|
|
148
143
|
await homebridge.updatePluginConfig(pluginConfig);
|
|
149
144
|
await homebridge.savePluginConfig(pluginConfig);
|
|
150
145
|
});
|
|
151
146
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
147
|
+
// --- Config Button Toggle ---
|
|
148
|
+
const configButton = document.getElementById('configButton');
|
|
149
|
+
let configButtonState = false;
|
|
150
|
+
configButton.addEventListener('click', () => {
|
|
151
|
+
configButtonState = !configButtonState;
|
|
152
|
+
homebridge[configButtonState ? 'showSchemaForm' : 'hideSchemaForm']();
|
|
153
|
+
configButton.className = configButtonState ? 'btn btn-primary' : 'btn btn-secondary';
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// Password toggle
|
|
157
|
+
document.getElementById('togglePasswd').addEventListener('click', () => {
|
|
158
|
+
const passwdInput = document.getElementById('passwd');
|
|
159
|
+
const icon = document.querySelector('#togglePasswd i');
|
|
160
|
+
if (passwdInput.type === 'password') {
|
|
161
|
+
passwdInput.type = 'text';
|
|
162
|
+
icon.classList.replace('fa-eye', 'fa-eye-slash');
|
|
163
|
+
} else {
|
|
164
|
+
passwdInput.type = 'password';
|
|
165
|
+
icon.classList.replace('fa-eye-slash', 'fa-eye');
|
|
166
|
+
}
|
|
158
167
|
});
|
|
159
168
|
|
|
169
|
+
// --- Device Handling & Login Logic ---
|
|
160
170
|
function removeStaleDevices(configDevices, melcloudDevices) {
|
|
161
171
|
const melcloudIds = melcloudDevices.map(d => d.DeviceID);
|
|
162
172
|
const removedDevices = [];
|
|
@@ -173,200 +183,92 @@
|
|
|
173
183
|
function updateInfo(id, text, color) {
|
|
174
184
|
const el = document.getElementById(id);
|
|
175
185
|
if (el) {
|
|
176
|
-
el.
|
|
186
|
+
el.innerText = text;
|
|
177
187
|
el.style.color = color;
|
|
178
188
|
}
|
|
179
189
|
}
|
|
180
190
|
|
|
181
|
-
// === Password toggle ===
|
|
182
|
-
document.getElementById('togglePasswd').addEventListener('click', () => {
|
|
183
|
-
const passwdInput = document.getElementById('passwd');
|
|
184
|
-
const icon = document.querySelector('#togglePasswd i');
|
|
185
|
-
if (passwdInput.type === 'password') {
|
|
186
|
-
passwdInput.type = 'text';
|
|
187
|
-
icon.classList.replace('fa-eye', 'fa-eye-slash');
|
|
188
|
-
} else {
|
|
189
|
-
passwdInput.type = 'password';
|
|
190
|
-
icon.classList.replace('fa-eye-slash', 'fa-eye');
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
|
|
194
191
|
document.getElementById('logIn').addEventListener('click', async () => {
|
|
195
192
|
homebridge.showSpinner();
|
|
196
|
-
document.getElementById(`logIn`).
|
|
197
|
-
|
|
198
|
-
// Reset feedback before each login attempt
|
|
199
|
-
updateInfo('info', '', '');
|
|
200
|
-
updateInfo('info1', '', '');
|
|
201
|
-
updateInfo('info2', '', '');
|
|
202
|
-
|
|
193
|
+
document.getElementById(`logIn`).className = "btn btn-primary";
|
|
203
194
|
updateInfo('info', 'Connecting...', 'yellow');
|
|
204
195
|
|
|
205
196
|
try {
|
|
206
|
-
const
|
|
207
|
-
const {
|
|
208
|
-
const payload = { accountName, user, passwd, language };
|
|
197
|
+
const acc = pluginConfig[0].accounts[this.deviceIndex];
|
|
198
|
+
const payload = { accountName: acc.name, user: acc.user, passwd: acc.passwd, language: acc.language };
|
|
209
199
|
const devicesInMelCloud = await homebridge.request('/connect', payload);
|
|
210
200
|
|
|
201
|
+
// Initialize devices arrays
|
|
211
202
|
const newDevices = { ata: [], ataPresets: [], atw: [], atwPresets: [], erv: [], ervPresets: [] };
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
for (const deviceInMelcloud of devicesInMelCloud) {
|
|
215
|
-
switch (deviceInMelcloud.Type) {
|
|
216
|
-
case 0: devicesByTypeInMelCloud.ata.push(deviceInMelcloud); break;
|
|
217
|
-
case 1: devicesByTypeInMelCloud.atw.push(deviceInMelcloud); break;
|
|
218
|
-
case 3: devicesByTypeInMelCloud.erv.push(deviceInMelcloud); break;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
203
|
+
const devicesByType = { ata: [], atw: [], erv: [] };
|
|
221
204
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
const removedAta = removeStaleDevices(ataDevicesInConfig, devicesByTypeInMelCloud.ata);
|
|
227
|
-
const removedAtw = removeStaleDevices(atwDevicesInConfig, devicesByTypeInMelCloud.atw);
|
|
228
|
-
const removedErv = removeStaleDevices(ervDevicesInConfig, devicesByTypeInMelCloud.erv);
|
|
229
|
-
|
|
230
|
-
// === Handle ATA devices ===
|
|
231
|
-
devicesByTypeInMelCloud.ata.forEach(device => {
|
|
232
|
-
const { DeviceID: deviceId, Type: deviceType, DeviceName: deviceName, Presets: devicePresets = [] } = device;
|
|
233
|
-
const deviceAta = {
|
|
234
|
-
id: deviceId,
|
|
235
|
-
type: deviceType,
|
|
236
|
-
typeString: "Air Conditioner",
|
|
237
|
-
name: deviceName,
|
|
238
|
-
displayMode: 1,
|
|
239
|
-
heatDryFanMode: 1,
|
|
240
|
-
coolDryFanMode: 1,
|
|
241
|
-
autoDryFanMode: 1,
|
|
242
|
-
temperatureSensor: false,
|
|
243
|
-
temperatureSensorOutdoor: false,
|
|
244
|
-
presets: [],
|
|
245
|
-
buttonsSensors: []
|
|
246
|
-
};
|
|
247
|
-
if (!ataDevicesInConfig.some(d => d.id === deviceId)) {
|
|
248
|
-
ataDevicesInConfig.push(deviceAta);
|
|
249
|
-
newDevices.ata.push(deviceAta);
|
|
250
|
-
}
|
|
251
|
-
devicePresets.forEach(preset => {
|
|
252
|
-
const { ID: presetId, NumberDescription: presetName } = preset;
|
|
253
|
-
preset.id = presetId;
|
|
254
|
-
preset.name = presetName;
|
|
255
|
-
preset.displayType = 0;
|
|
256
|
-
preset.namePrefix = false;
|
|
257
|
-
const ataDevice = ataDevicesInConfig.find(d => d.id === deviceId);
|
|
258
|
-
if (ataDevice && !ataDevice.presets.some(p => p.id === presetId)) {
|
|
259
|
-
ataDevice.presets.push(preset);
|
|
260
|
-
newDevices.ataPresets.push(preset);
|
|
261
|
-
}
|
|
262
|
-
});
|
|
205
|
+
devicesInMelCloud.forEach(d => {
|
|
206
|
+
if (d.Type === 0) devicesByType.ata.push(d);
|
|
207
|
+
if (d.Type === 1) devicesByType.atw.push(d);
|
|
208
|
+
if (d.Type === 3) devicesByType.erv.push(d);
|
|
263
209
|
});
|
|
264
210
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
buttonsSensors: []
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
newDevices.atw.push(deviceAtw);
|
|
282
|
-
}
|
|
283
|
-
devicePresets.forEach(preset => {
|
|
284
|
-
const { ID: presetId, NumberDescription: presetName } = preset;
|
|
285
|
-
preset.id = presetId;
|
|
286
|
-
preset.name = presetName;
|
|
287
|
-
preset.displayType = 0;
|
|
288
|
-
preset.namePrefix = false;
|
|
289
|
-
const atwDevice = atwDevicesInConfig.find(d => d.id === deviceId);
|
|
290
|
-
if (atwDevice && !atwDevice.presets.some(p => p.id === presetId)) {
|
|
291
|
-
atwDevice.presets.push(preset);
|
|
292
|
-
newDevices.atwPresets.push(preset);
|
|
211
|
+
acc.ataDevices ??= [];
|
|
212
|
+
acc.atwDevices ??= [];
|
|
213
|
+
acc.ervDevices ??= [];
|
|
214
|
+
|
|
215
|
+
const removedAta = removeStaleDevices(acc.ataDevices, devicesByType.ata);
|
|
216
|
+
const removedAtw = removeStaleDevices(acc.atwDevices, devicesByType.atw);
|
|
217
|
+
const removedErv = removeStaleDevices(acc.ervDevices, devicesByType.erv);
|
|
218
|
+
|
|
219
|
+
// Function to handle device & presets
|
|
220
|
+
const handleDevices = (devicesInCloud, devicesInConfig, typeString, newArr, newPresets) => {
|
|
221
|
+
devicesInCloud.forEach(device => {
|
|
222
|
+
const { DeviceID: id, Type: type, DeviceName: name, Presets: presets = [] } = device;
|
|
223
|
+
const devObj = { id, type, typeString, name, displayMode: 1, presets: [], buttonsSensors: [] };
|
|
224
|
+
if (!devicesInConfig.some(d => d.id === id)) {
|
|
225
|
+
devicesInConfig.push(devObj);
|
|
226
|
+
newArr.push(devObj);
|
|
293
227
|
}
|
|
228
|
+
presets.forEach(p => {
|
|
229
|
+
p.id = p.ID;
|
|
230
|
+
p.name = p.NumberDescription;
|
|
231
|
+
p.displayType = 0;
|
|
232
|
+
p.namePrefix = false;
|
|
233
|
+
const devConfig = devicesInConfig.find(d => d.id === id);
|
|
234
|
+
if (devConfig && !devConfig.presets.some(x => x.id === p.ID)) {
|
|
235
|
+
devConfig.presets.push(p);
|
|
236
|
+
newPresets.push(p);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
294
239
|
});
|
|
295
|
-
}
|
|
240
|
+
};
|
|
296
241
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
const deviceErv = {
|
|
301
|
-
id: deviceId,
|
|
302
|
-
type: deviceType,
|
|
303
|
-
typeString: "ERV",
|
|
304
|
-
name: deviceName,
|
|
305
|
-
displayMode: 1,
|
|
306
|
-
temperatureSensor: false,
|
|
307
|
-
presets: [],
|
|
308
|
-
buttonsSensors: []
|
|
309
|
-
};
|
|
310
|
-
if (!ervDevicesInConfig.some(d => d.id === deviceId)) {
|
|
311
|
-
ervDevicesInConfig.push(deviceErv);
|
|
312
|
-
newDevices.erv.push(deviceErv);
|
|
313
|
-
}
|
|
314
|
-
devicePresets.forEach(preset => {
|
|
315
|
-
const { ID: presetId, NumberDescription: presetName } = preset;
|
|
316
|
-
preset.id = presetId;
|
|
317
|
-
preset.name = presetName;
|
|
318
|
-
preset.displayType = 0;
|
|
319
|
-
preset.namePrefix = false;
|
|
320
|
-
const ervDevice = ervDevicesInConfig.find(d => d.id === deviceId);
|
|
321
|
-
if (ervDevice && !ervDevice.presets.some(p => p.id === presetId)) {
|
|
322
|
-
ervDevice.presets.push(preset);
|
|
323
|
-
newDevices.ervPresets.push(preset);
|
|
324
|
-
}
|
|
325
|
-
});
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
// --- Display Info Section ---
|
|
329
|
-
const textAta = `ATA: ${newDevices.ata.length}`;
|
|
330
|
-
const textAtw = `ATW: ${newDevices.atw.length}`;
|
|
331
|
-
const textErv = `ERV: ${newDevices.erv.length}`;
|
|
332
|
-
const textAtaPresets = `ATA Presets: ${newDevices.ataPresets.length}`;
|
|
333
|
-
const textAtwPresets = `ATW Presets: ${newDevices.atwPresets.length}`;
|
|
334
|
-
const textErvPresets = `ERV Presets: ${newDevices.ervPresets.length}`;
|
|
335
|
-
const textRemovedAta = `ATA: ${removedAta.length}`;
|
|
336
|
-
const textRemovedAtw = `ATW: ${removedAtw.length}`;
|
|
337
|
-
const textRemovedErv = `ERV: ${removedErv.length}`;
|
|
242
|
+
handleDevices(devicesByType.ata, acc.ataDevices, "Air Conditioner", newDevices.ata, newDevices.ataPresets);
|
|
243
|
+
handleDevices(devicesByType.atw, acc.atwDevices, "Heat Pump", newDevices.atw, newDevices.atwPresets);
|
|
244
|
+
handleDevices(devicesByType.erv, acc.ervDevices, "ERV", newDevices.erv, newDevices.ervPresets);
|
|
338
245
|
|
|
246
|
+
// Display summary
|
|
339
247
|
const newDevicesCount = newDevices.ata.length + newDevices.atw.length + newDevices.erv.length;
|
|
340
248
|
const newPresetsCount = newDevices.ataPresets.length + newDevices.atwPresets.length + newDevices.ervPresets.length;
|
|
341
|
-
const
|
|
249
|
+
const removedDevicesCount = removedAta.length + removedAtw.length + removedErv.length;
|
|
342
250
|
|
|
343
|
-
if (newDevicesCount
|
|
251
|
+
if (!newDevicesCount && !newPresetsCount && !removedDevicesCount) {
|
|
344
252
|
updateInfo('info', 'No changes detected.', 'white');
|
|
345
253
|
} else {
|
|
346
|
-
if (newDevicesCount
|
|
347
|
-
|
|
348
|
-
}
|
|
349
|
-
if (newPresetsCount > 0) {
|
|
350
|
-
updateInfo('info1', `Found new presets: ${textAtaPresets}, ${textAtwPresets}, ${textErvPresets}.`, 'green');
|
|
351
|
-
}
|
|
352
|
-
if (removedCount > 0) {
|
|
353
|
-
updateInfo('info2', `Removed devices: ${textRemovedAta}, ${textRemovedAtw}, ${textRemovedErv}.`, 'orange');
|
|
354
|
-
}
|
|
254
|
+
if (newDevicesCount) updateInfo('info', `Found new devices: ATA: ${newDevices.ata.length}, ATW: ${newDevices.atw.length}, ERV: ${newDevices.erv.length}.`, 'green');
|
|
255
|
+
if (newPresetsCount) updateInfo('info1', `Found new presets: ATA: ${newDevices.ataPresets.length}, ATW: ${newDevices.atwPresets.length}, ERV: ${newDevices.ervPresets.length}.`, 'green');
|
|
256
|
+
if (removedDevicesCount) updateInfo('info2', `Removed devices: ATA: ${removedAta.length}, ATW: ${removedAtw.length}, ERV: ${removedErv.length}.`, 'orange');
|
|
355
257
|
}
|
|
356
258
|
|
|
357
259
|
await homebridge.updatePluginConfig(pluginConfig);
|
|
358
260
|
await homebridge.savePluginConfig(pluginConfig);
|
|
359
|
-
document.getElementById('logIn').
|
|
360
|
-
homebridge.hideSpinner();
|
|
261
|
+
document.getElementById('logIn').className = "btn btn-secondary";
|
|
361
262
|
|
|
362
263
|
} catch (error) {
|
|
363
|
-
updateInfo('info', 'Check
|
|
364
|
-
updateInfo('info1', `Error: ${error
|
|
365
|
-
document.getElementById('logIn').
|
|
264
|
+
updateInfo('info', 'Check Your credentials data and try again.', 'yellow');
|
|
265
|
+
updateInfo('info1', `Error: ${error}`, 'red');
|
|
266
|
+
document.getElementById('logIn').className = "btn btn-secondary";
|
|
366
267
|
} finally {
|
|
367
268
|
homebridge.hideSpinner();
|
|
368
269
|
}
|
|
369
270
|
});
|
|
271
|
+
|
|
370
272
|
})();
|
|
371
273
|
</script>
|
|
372
274
|
</body>
|
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.0
|
|
4
|
+
"version": "3.9.0",
|
|
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
|
@@ -279,14 +279,14 @@ class DeviceAta extends EventEmitter {
|
|
|
279
279
|
const coolDryFanMode = [this.accessory.operationMode, 3, modelSupportsDry ? 2 : 3, 7][this.coolDryFanMode]; //NONE, COOL - 3, DRY - 2, FAN - 7
|
|
280
280
|
|
|
281
281
|
//accessory
|
|
282
|
-
|
|
282
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare accessory`);
|
|
283
283
|
const accessoryName = deviceName;
|
|
284
284
|
const accessoryUUID = AccessoryUUID.generate(accountName + deviceId.toString());
|
|
285
285
|
const accessoryCategory = [Categories.OTHER, Categories.AIR_HEATER, Categories.THERMOSTAT][this.displayType];
|
|
286
286
|
const accessory = new Accessory(accessoryName, accessoryUUID, accessoryCategory);
|
|
287
287
|
|
|
288
288
|
//information service
|
|
289
|
-
|
|
289
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare information service`);
|
|
290
290
|
accessory.getService(Service.AccessoryInformation)
|
|
291
291
|
.setCharacteristic(Characteristic.Manufacturer, this.manufacturer)
|
|
292
292
|
.setCharacteristic(Characteristic.Model, this.model)
|
|
@@ -298,7 +298,7 @@ class DeviceAta extends EventEmitter {
|
|
|
298
298
|
const serviceName = `${deviceTypeText} ${accessoryName}`;
|
|
299
299
|
switch (this.displayMode) {
|
|
300
300
|
case 1: //Heater Cooler
|
|
301
|
-
|
|
301
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare heater/cooler service`);
|
|
302
302
|
this.melCloudService = new Service.HeaterCooler(serviceName, `HeaterCooler ${deviceId}`);
|
|
303
303
|
this.melCloudService.setPrimaryService(true);
|
|
304
304
|
this.melCloudService.getCharacteristic(Characteristic.Active)
|
|
@@ -311,7 +311,7 @@ class DeviceAta extends EventEmitter {
|
|
|
311
311
|
deviceData.Device.Power = [false, true][state];
|
|
312
312
|
deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.Power;
|
|
313
313
|
await this.melCloudAta.send(deviceData, this.displayMode);
|
|
314
|
-
|
|
314
|
+
if (!this.disableLogInfo) this.emit('info', `Set power: ${state ? 'ON' : 'OFF'}`);
|
|
315
315
|
} catch (error) {
|
|
316
316
|
this.emit('warn', `Set power error: ${error}`);
|
|
317
317
|
};
|
|
@@ -348,7 +348,7 @@ class DeviceAta extends EventEmitter {
|
|
|
348
348
|
deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.OperationModeSetTemperature;
|
|
349
349
|
await this.melCloudAta.send(deviceData, this.displayMode);
|
|
350
350
|
const operationModeText = AirConditioner.DriveMode[deviceData.Device.OperationMode];
|
|
351
|
-
|
|
351
|
+
if (!this.disableLogInfo) this.emit('info', `Set operation mode: ${operationModeText}`);
|
|
352
352
|
} catch (error) {
|
|
353
353
|
this.emit('warn', `Set operation mode error: ${error}`);
|
|
354
354
|
};
|
|
@@ -396,7 +396,7 @@ class DeviceAta extends EventEmitter {
|
|
|
396
396
|
};
|
|
397
397
|
deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.SetFanSpeed;
|
|
398
398
|
await this.melCloudAta.send(deviceData, this.displayMode);
|
|
399
|
-
|
|
399
|
+
if (!this.disableLogInfo) this.emit('info', `Set fan speed mode: ${AirConditioner.FanSpeed[fanSpeedModeText]}`);
|
|
400
400
|
} catch (error) {
|
|
401
401
|
this.emit('warn', `Set fan speed mode error: ${error}`);
|
|
402
402
|
};
|
|
@@ -415,7 +415,7 @@ class DeviceAta extends EventEmitter {
|
|
|
415
415
|
deviceData.Device.VaneVertical = value ? 7 : 0;
|
|
416
416
|
deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.VaneVerticalVaneHorizontal;
|
|
417
417
|
await this.melCloudAta.send(deviceData, this.displayMode);
|
|
418
|
-
|
|
418
|
+
if (!this.disableLogInfo) this.emit('info', `Set air direction mode: ${AirConditioner.AirDirection[value]}`);
|
|
419
419
|
} catch (error) {
|
|
420
420
|
this.emit('warn', `Set vane swing mode error: ${error}`);
|
|
421
421
|
};
|
|
@@ -436,7 +436,7 @@ class DeviceAta extends EventEmitter {
|
|
|
436
436
|
deviceData.Device.DefaultCoolingSetTemperature = value;
|
|
437
437
|
deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.SetTemperature;
|
|
438
438
|
await this.melCloudAta.send(deviceData, this.displayMode);
|
|
439
|
-
|
|
439
|
+
if (!this.disableLogInfo) this.emit('info', `Set cooling threshold temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
440
440
|
} catch (error) {
|
|
441
441
|
this.emit('warn', `Set cooling threshold temperature error: ${error}`);
|
|
442
442
|
};
|
|
@@ -457,7 +457,7 @@ class DeviceAta extends EventEmitter {
|
|
|
457
457
|
deviceData.Device.DefaultHeatingSetTemperature = value;
|
|
458
458
|
deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.SetTemperature;
|
|
459
459
|
await this.melCloudAta.send(deviceData, this.displayMode);
|
|
460
|
-
|
|
460
|
+
if (!this.disableLogInfo) this.emit('info', `Set heating threshold temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
461
461
|
} catch (error) {
|
|
462
462
|
this.emit('warn', `Set heating threshold temperature error: ${error}`);
|
|
463
463
|
};
|
|
@@ -476,7 +476,7 @@ class DeviceAta extends EventEmitter {
|
|
|
476
476
|
deviceData.Device.ProhibitPower = value;
|
|
477
477
|
deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.Prohibit;
|
|
478
478
|
await this.melCloudAta.send(deviceData, this.displayMode);
|
|
479
|
-
|
|
479
|
+
if (!this.disableLogInfo) this.emit('info', `Set local physical controls: ${value ? 'LOCK' : 'UNLOCK'}`);
|
|
480
480
|
} catch (error) {
|
|
481
481
|
this.emit('warn', `Set lock physical controls error: ${error}`);
|
|
482
482
|
};
|
|
@@ -491,7 +491,7 @@ class DeviceAta extends EventEmitter {
|
|
|
491
491
|
value = [false, true][value];
|
|
492
492
|
this.accessory.useFahrenheit = value;
|
|
493
493
|
this.emit('melCloud', 'UseFahrenheit', value);
|
|
494
|
-
|
|
494
|
+
if (!this.disableLogInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
495
495
|
} catch (error) {
|
|
496
496
|
this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
497
497
|
};
|
|
@@ -499,7 +499,7 @@ class DeviceAta extends EventEmitter {
|
|
|
499
499
|
accessory.addService(this.melCloudService);
|
|
500
500
|
break;
|
|
501
501
|
case 2: //Thermostat
|
|
502
|
-
|
|
502
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare thermostat service`);
|
|
503
503
|
this.melCloudService = new Service.Thermostat(serviceName, `Thermostat ${deviceId}`);
|
|
504
504
|
this.melCloudService.setPrimaryService(true);
|
|
505
505
|
this.melCloudService.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
|
|
@@ -543,7 +543,7 @@ class DeviceAta extends EventEmitter {
|
|
|
543
543
|
|
|
544
544
|
await this.melCloudAta.send(deviceData, this.displayMode);
|
|
545
545
|
const operationModeText = AirConditioner.DriveMode[deviceData.Device.OperationMode];
|
|
546
|
-
|
|
546
|
+
if (!this.disableLogInfo) this.emit('info', `Set operation mode: ${operationModeText}`);
|
|
547
547
|
} catch (error) {
|
|
548
548
|
this.emit('warn', `Set operation mode error: ${error}`);
|
|
549
549
|
};
|
|
@@ -568,7 +568,7 @@ class DeviceAta extends EventEmitter {
|
|
|
568
568
|
deviceData.Device.SetTemperature = value;
|
|
569
569
|
deviceData.Device.EffectiveFlags = AirConditioner.EffectiveFlags.SetTemperature;
|
|
570
570
|
await this.melCloudAta.send(deviceData, this.displayMode);
|
|
571
|
-
|
|
571
|
+
if (!this.disableLogInfo) this.emit('info', `Set temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
572
572
|
} catch (error) {
|
|
573
573
|
this.emit('warn', `Set temperature error: ${error}`);
|
|
574
574
|
};
|
|
@@ -583,7 +583,7 @@ class DeviceAta extends EventEmitter {
|
|
|
583
583
|
value = [false, true][value];
|
|
584
584
|
this.accessory.useFahrenheit = value;
|
|
585
585
|
this.emit('melCloud', 'UseFahrenheit', value);
|
|
586
|
-
|
|
586
|
+
if (!this.disableLogInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
587
587
|
} catch (error) {
|
|
588
588
|
this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
589
589
|
};
|
|
@@ -594,7 +594,7 @@ class DeviceAta extends EventEmitter {
|
|
|
594
594
|
|
|
595
595
|
//temperature sensor services
|
|
596
596
|
if (this.temperatureSensor && this.accessory.roomTemperature !== null) {
|
|
597
|
-
|
|
597
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare room temperature sensor service`);
|
|
598
598
|
this.roomTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Room`, `Room Temperature Sensor ${deviceId}`);
|
|
599
599
|
this.roomTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
600
600
|
this.roomTemperatureSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Room`);
|
|
@@ -612,7 +612,7 @@ class DeviceAta extends EventEmitter {
|
|
|
612
612
|
};
|
|
613
613
|
|
|
614
614
|
if (this.temperatureSensorOutdoor && hasOutdoorTemperature && this.accessory.outdoorTemperature !== null) {
|
|
615
|
-
|
|
615
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare outdoor temperature sensor service`);
|
|
616
616
|
this.outdoorTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Outdoor`, `Outdoor Temperature Sensor ${deviceId}`);
|
|
617
617
|
this.outdoorTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
618
618
|
this.outdoorTemperatureSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Outdoor`);
|
|
@@ -631,7 +631,7 @@ class DeviceAta extends EventEmitter {
|
|
|
631
631
|
|
|
632
632
|
//presets services
|
|
633
633
|
if (this.presetsConfiguredCount > 0) {
|
|
634
|
-
|
|
634
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare presets services`);
|
|
635
635
|
this.presetsServices = [];
|
|
636
636
|
this.presetsConfigured.forEach((preset, i) => {
|
|
637
637
|
const presetData = presetsOnServer.find(p => p.ID === preset.Id);
|
|
@@ -678,7 +678,7 @@ class DeviceAta extends EventEmitter {
|
|
|
678
678
|
};
|
|
679
679
|
|
|
680
680
|
await this.melCloudAta.send(deviceData, this.displayMode);
|
|
681
|
-
|
|
681
|
+
if (!this.disableLogInfo) this.emit('info', `${state ? 'Set:' : 'Unset:'} ${name}`);
|
|
682
682
|
} catch (error) {
|
|
683
683
|
this.emit('warn', `Set preset error: ${error}`);
|
|
684
684
|
};
|
|
@@ -690,7 +690,7 @@ class DeviceAta extends EventEmitter {
|
|
|
690
690
|
|
|
691
691
|
//buttons services
|
|
692
692
|
if (this.buttonsConfiguredCount > 0) {
|
|
693
|
-
|
|
693
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare buttons/sensors services`);
|
|
694
694
|
this.buttonsServices = [];
|
|
695
695
|
this.buttonsConfigured.forEach((button, i) => {
|
|
696
696
|
//get button mode
|
|
@@ -918,7 +918,7 @@ class DeviceAta extends EventEmitter {
|
|
|
918
918
|
};
|
|
919
919
|
|
|
920
920
|
await this.melCloudAta.send(deviceData, this.displayMode);
|
|
921
|
-
|
|
921
|
+
if (!this.disableLogInfo) this.emit('info', `${state ? `Set: ${name}` : `Unset: ${name}, Set: ${button.previousValue}`}`);
|
|
922
922
|
} catch (error) {
|
|
923
923
|
this.emit('warn', `Set button error: ${error}`);
|
|
924
924
|
};
|
package/src/deviceatw.js
CHANGED
|
@@ -305,14 +305,14 @@ class DeviceAtw extends EventEmitter {
|
|
|
305
305
|
const caseZone2Sensor = this.accessory.caseZone2Sensor;
|
|
306
306
|
|
|
307
307
|
//accessory
|
|
308
|
-
|
|
308
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare accessory`);
|
|
309
309
|
const accessoryName = deviceName;
|
|
310
310
|
const accessoryUUID = AccessoryUUID.generate(accountName + deviceId.toString());
|
|
311
311
|
const accessoryCategory = [Categories.OTHER, Categories.AIR_HEATER, Categories.THERMOSTAT][this.displayType];
|
|
312
312
|
const accessory = new Accessory(accessoryName, accessoryUUID, accessoryCategory);
|
|
313
313
|
|
|
314
314
|
//information service
|
|
315
|
-
|
|
315
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare information service`);
|
|
316
316
|
accessory.getService(Service.AccessoryInformation)
|
|
317
317
|
.setCharacteristic(Characteristic.Manufacturer, this.manufacturer)
|
|
318
318
|
.setCharacteristic(Characteristic.Model, this.model)
|
|
@@ -328,7 +328,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
328
328
|
const serviceName = `${deviceTypeText} ${accessoryName}: ${zoneName}`;
|
|
329
329
|
switch (this.displayMode) {
|
|
330
330
|
case 1: //Heater Cooler
|
|
331
|
-
|
|
331
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare heather/cooler ${zoneName} service`);
|
|
332
332
|
const melCloudService = new Service.HeaterCooler(serviceName, `HeaterCooler ${deviceId} ${i}`);
|
|
333
333
|
melCloudService.setPrimaryService(true);
|
|
334
334
|
melCloudService.getCharacteristic(Characteristic.Active)
|
|
@@ -343,7 +343,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
343
343
|
deviceData.Device.Power = [false, true][state];
|
|
344
344
|
deviceData.Device.EffectiveFlags = HeatPump.EffectiveFlags.Power;
|
|
345
345
|
await this.melCloudAtw.send(deviceData);
|
|
346
|
-
|
|
346
|
+
if (!this.disableLogInfo) this.emit('info', `${zoneName}, Set power: ${state ? 'ON' : 'OFF'}`);
|
|
347
347
|
break;
|
|
348
348
|
};
|
|
349
349
|
} catch (error) {
|
|
@@ -442,7 +442,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
442
442
|
};
|
|
443
443
|
|
|
444
444
|
await this.melCloudAtw.send(deviceData);
|
|
445
|
-
|
|
445
|
+
if (!this.disableLogInfo) this.emit('info', `${zoneName}, Set operation mode: ${operationModeText}`);
|
|
446
446
|
} catch (error) {
|
|
447
447
|
this.emit('warn', `${zoneName}, Set operation mode error: ${error}`);
|
|
448
448
|
};
|
|
@@ -615,7 +615,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
615
615
|
};
|
|
616
616
|
|
|
617
617
|
await this.melCloudAtw.send(deviceData);
|
|
618
|
-
|
|
618
|
+
if (!this.disableLogInfo) this.emit('info', `${zoneName}, Set lock physical controls: ${value ? 'LOCK' : 'UNLOCK'}`);
|
|
619
619
|
} catch (error) {
|
|
620
620
|
this.emit('warn', `${zoneName}, Set lock physical controls error: ${error}`);
|
|
621
621
|
};
|
|
@@ -630,7 +630,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
630
630
|
value = [false, true][value];
|
|
631
631
|
this.accessory.useFahrenheit = value;
|
|
632
632
|
this.emit('melCloud', 'UseFahrenheit', value);
|
|
633
|
-
|
|
633
|
+
if (!this.disableLogInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
634
634
|
} catch (error) {
|
|
635
635
|
this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
636
636
|
};
|
|
@@ -639,7 +639,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
639
639
|
accessory.addService(melCloudService);
|
|
640
640
|
break;
|
|
641
641
|
case 2: //Thermostat
|
|
642
|
-
|
|
642
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare thermostat ${zoneName} service`);
|
|
643
643
|
const melCloudServiceT = new Service.Thermostat(serviceName, `Thermostat ${deviceId} ${i}`);
|
|
644
644
|
melCloudServiceT.setPrimaryService(true);
|
|
645
645
|
melCloudServiceT.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
|
|
@@ -750,7 +750,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
750
750
|
};
|
|
751
751
|
|
|
752
752
|
await this.melCloudAtw.send(deviceData);
|
|
753
|
-
|
|
753
|
+
if (!this.disableLogInfo) this.emit('info', `${zoneName}, Set operation mode: ${operationModeText}`);
|
|
754
754
|
} catch (error) {
|
|
755
755
|
this.emit('warn', `${zoneName}, Set operation mode error: ${error}`);
|
|
756
756
|
};
|
|
@@ -812,7 +812,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
812
812
|
value = [false, true][value];
|
|
813
813
|
this.accessory.useFahrenheit = value;
|
|
814
814
|
this.emit('melCloud', 'UseFahrenheit', value);
|
|
815
|
-
|
|
815
|
+
if (!this.disableLogInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
816
816
|
} catch (error) {
|
|
817
817
|
this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
818
818
|
};
|
|
@@ -832,7 +832,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
832
832
|
switch (i) {
|
|
833
833
|
case caseHeatPumpSensor: //Heat Pump
|
|
834
834
|
if (zone.roomTemperature !== null) {
|
|
835
|
-
|
|
835
|
+
if (this.enableDebugMode) this.emit('debug', `${zoneName}, Prepare temperature sensor service`);
|
|
836
836
|
this.roomTemperatureSensorService = new Service.TemperatureSensor(`${serviceName}`, `${zoneName} Temperature Sensor ${deviceId} ${i}`);
|
|
837
837
|
this.roomTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
838
838
|
this.roomTemperatureSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${zoneName}`);
|
|
@@ -850,7 +850,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
850
850
|
};
|
|
851
851
|
|
|
852
852
|
if (zone.flowTemperature !== null) {
|
|
853
|
-
|
|
853
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare flow temperature sensor service`);
|
|
854
854
|
this.flowTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Flow`, `${zoneName} Temperature Sensor Flow ${deviceId} ${i}`);
|
|
855
855
|
this.flowTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
856
856
|
this.flowTemperatureSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${zoneName} Flow`);
|
|
@@ -869,7 +869,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
869
869
|
};
|
|
870
870
|
|
|
871
871
|
if (zone.returnTemperature !== null) {
|
|
872
|
-
|
|
872
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare return temperature sensor service`);
|
|
873
873
|
this.returnTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Return`, `${zoneName} Temperature Sensor Return ${deviceId} ${i}`);
|
|
874
874
|
this.returnTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
875
875
|
this.returnTemperatureSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${zoneName} Return`);
|
|
@@ -888,7 +888,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
888
888
|
break;
|
|
889
889
|
case caseZone1Sensor: //Zone 1
|
|
890
890
|
if (zone.roomTemperature !== null) {
|
|
891
|
-
|
|
891
|
+
if (this.enableDebugMode) this.emit('debug', `${zoneName}, Prepare temperature sensor service`);
|
|
892
892
|
this.roomTemperatureZone1SensorService = new Service.TemperatureSensor(`${serviceName}`, `${zoneName} Temperature Sensor ${deviceId} ${i}`);
|
|
893
893
|
this.roomTemperatureZone1SensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
894
894
|
this.roomTemperatureZone1SensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${zoneName}`);
|
|
@@ -906,7 +906,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
906
906
|
};
|
|
907
907
|
|
|
908
908
|
if (zone.flowTemperature !== null) {
|
|
909
|
-
|
|
909
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare flow temperature zone 1 sensor service`);
|
|
910
910
|
this.flowTemperatureZone1SensorService = new Service.TemperatureSensor(`${serviceName} Flow`, `${zoneName} Temperature Sensor Flow ${deviceId} ${i}`);
|
|
911
911
|
this.flowTemperatureZone1SensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
912
912
|
this.flowTemperatureZone1SensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${zoneName} Flow`);
|
|
@@ -924,7 +924,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
924
924
|
};
|
|
925
925
|
|
|
926
926
|
if (zone.returnTemperature !== null) {
|
|
927
|
-
|
|
927
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare return temperature zone 1 sensor service`);
|
|
928
928
|
this.returnTemperatureZone1SensorService = new Service.TemperatureSensor(`${serviceName} Return`, `${zoneName} Temperature Sensor Return ${deviceId} ${i}`);
|
|
929
929
|
this.returnTemperatureZone1SensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
930
930
|
this.returnTemperatureZone1SensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${zoneName} Return`);
|
|
@@ -943,7 +943,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
943
943
|
break;
|
|
944
944
|
case caseHotWaterSensor: //Hot Water
|
|
945
945
|
if (zone.roomTemperature !== null) {
|
|
946
|
-
|
|
946
|
+
if (this.enableDebugMode) this.emit('debug', `${zoneName}, Prepare temperature sensor service`);
|
|
947
947
|
this.roomTemperatureWaterTankSensorService = new Service.TemperatureSensor(`${serviceName}`, `${zoneName} Temperature Sensor ${deviceId} ${i}`);
|
|
948
948
|
this.roomTemperatureWaterTankSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
949
949
|
this.roomTemperatureWaterTankSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${zoneName}`);
|
|
@@ -961,7 +961,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
961
961
|
};
|
|
962
962
|
|
|
963
963
|
if (zone.flowTemperature !== null) {
|
|
964
|
-
|
|
964
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare flow temperature water tank sensor service`);
|
|
965
965
|
this.flowTemperatureWaterTankSensorService = new Service.TemperatureSensor(`${serviceName} Flow`, `${zoneName} Temperature Sensor Flow ${deviceId} ${i}`);
|
|
966
966
|
this.flowTemperatureWaterTankSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
967
967
|
this.flowTemperatureWaterTankSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${zoneName} Flow`);
|
|
@@ -979,7 +979,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
979
979
|
};
|
|
980
980
|
|
|
981
981
|
if (zone.returnTemperature !== null) {
|
|
982
|
-
|
|
982
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare return temperature water tank sensor service`);
|
|
983
983
|
this.returnTemperatureWaterTankSensorService = new Service.TemperatureSensor(`${serviceName} Return`, `${zoneName} Temperature Sensor Return ${deviceId} ${i}`);
|
|
984
984
|
this.returnTemperatureWaterTankSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
985
985
|
this.returnTemperatureWaterTankSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${zoneName} Return`);
|
|
@@ -998,7 +998,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
998
998
|
break;
|
|
999
999
|
case caseZone2Sensor: //Zone 2
|
|
1000
1000
|
if (zone.roomTemperature !== null) {
|
|
1001
|
-
|
|
1001
|
+
if (this.enableDebugMode) this.emit('debug', `${zoneName}, Prepare temperature sensor service`);
|
|
1002
1002
|
this.roomTemperatureZone2SensorService = new Service.TemperatureSensor(`${serviceName}`, `${zoneName} Temperature Sensor ${deviceId} ${i}`);
|
|
1003
1003
|
this.roomTemperatureZone2SensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
1004
1004
|
this.roomTemperatureZone2SensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${zoneName}`);
|
|
@@ -1016,7 +1016,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1016
1016
|
};
|
|
1017
1017
|
|
|
1018
1018
|
if (zone.flowTemperature !== null) {
|
|
1019
|
-
|
|
1019
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare flow temperature zone 2 sensor service`);
|
|
1020
1020
|
this.flowTemperatureZone2SensorService = new Service.TemperatureSensor(`${serviceName} Flow`, `${zoneName} Temperature Sensor Flow${deviceId} ${i}`);
|
|
1021
1021
|
this.flowTemperatureZone2SensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
1022
1022
|
this.flowTemperatureZone2SensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${zoneName} Flow`);
|
|
@@ -1034,7 +1034,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1034
1034
|
};
|
|
1035
1035
|
|
|
1036
1036
|
if (zone.returnTemperature !== null) {
|
|
1037
|
-
|
|
1037
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare return temperature zone 2 sensor service`);
|
|
1038
1038
|
this.returnTemperatureZone2SensorService = new Service.TemperatureSensor(`${serviceName} Return`, `${zoneName} Temperature Sensor Return${deviceId} ${i}`);
|
|
1039
1039
|
this.returnTemperatureZone2SensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
1040
1040
|
this.returnTemperatureZone2SensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} ${zoneName} Return`);
|
|
@@ -1057,7 +1057,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1057
1057
|
|
|
1058
1058
|
//presets services
|
|
1059
1059
|
if (this.presetsConfiguredCount > 0) {
|
|
1060
|
-
|
|
1060
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare presets services`);
|
|
1061
1061
|
this.presetsServices = [];
|
|
1062
1062
|
this.presetsConfigured.forEach((preset, i) => {
|
|
1063
1063
|
const presetData = presetsOnServer.find(p => p.ID === preset.Id);
|
|
@@ -1116,7 +1116,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1116
1116
|
};
|
|
1117
1117
|
|
|
1118
1118
|
await this.melCloudAtw.send(deviceData);
|
|
1119
|
-
|
|
1119
|
+
if (!this.disableLogInfo) this.emit('info', `${state ? 'Set:' : 'Unset:'} ${name}`);
|
|
1120
1120
|
} catch (error) {
|
|
1121
1121
|
this.emit('warn', `Set preset error: ${error}`);
|
|
1122
1122
|
};
|
|
@@ -1128,7 +1128,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1128
1128
|
|
|
1129
1129
|
//buttons services
|
|
1130
1130
|
if (this.buttonsConfiguredCount > 0) {
|
|
1131
|
-
|
|
1131
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare buttons services`);
|
|
1132
1132
|
this.buttonsServices = [];
|
|
1133
1133
|
this.buttonsConfigured.forEach((button, i) => {
|
|
1134
1134
|
//get button mode
|
|
@@ -1284,7 +1284,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1284
1284
|
};
|
|
1285
1285
|
|
|
1286
1286
|
await this.melCloudAtw.send(deviceData);
|
|
1287
|
-
|
|
1287
|
+
if (!this.disableLogInfo) this.emit('info', `${state ? `Set: ${name}` : `Unset: ${name}, Set: ${button.previousValue}`}`);
|
|
1288
1288
|
} catch (error) {
|
|
1289
1289
|
this.emit('warn', `Set button error: ${error}`);
|
|
1290
1290
|
};
|
package/src/deviceerv.js
CHANGED
|
@@ -266,14 +266,14 @@ class DeviceErv extends EventEmitter {
|
|
|
266
266
|
const numberOfFanSpeeds = this.accessory.numberOfFanSpeeds;
|
|
267
267
|
|
|
268
268
|
//accessory
|
|
269
|
-
|
|
269
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare accessory`);
|
|
270
270
|
const accessoryName = deviceName;
|
|
271
271
|
const accessoryUUID = AccessoryUUID.generate(accountName + deviceId.toString());
|
|
272
272
|
const accessoryCategory = [Categories.OTHER, Categories.AIR_PURIFIER, Categories.THERMOSTAT][this.displayType];
|
|
273
273
|
const accessory = new Accessory(accessoryName, accessoryUUID, accessoryCategory);
|
|
274
274
|
|
|
275
275
|
//information service
|
|
276
|
-
|
|
276
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare information service`);
|
|
277
277
|
accessory.getService(Service.AccessoryInformation)
|
|
278
278
|
.setCharacteristic(Characteristic.Manufacturer, this.manufacturer)
|
|
279
279
|
.setCharacteristic(Characteristic.Model, this.model)
|
|
@@ -285,7 +285,7 @@ class DeviceErv extends EventEmitter {
|
|
|
285
285
|
const serviceName = `${deviceTypeText} ${accessoryName}`;
|
|
286
286
|
switch (this.displayMode) {
|
|
287
287
|
case 1: //Heater Cooler
|
|
288
|
-
|
|
288
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare heather/cooler service`);
|
|
289
289
|
this.melCloudService = new Service.HeaterCooler(serviceName, `HeaterCooler ${deviceId}`);
|
|
290
290
|
this.melCloudService.setPrimaryService(true);
|
|
291
291
|
this.melCloudService.getCharacteristic(Characteristic.Active)
|
|
@@ -298,7 +298,7 @@ class DeviceErv extends EventEmitter {
|
|
|
298
298
|
deviceData.Device.Power = [false, true][state];
|
|
299
299
|
deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.Power;
|
|
300
300
|
await this.melCloudErv.send(deviceData, this.displayMode);
|
|
301
|
-
|
|
301
|
+
if (!this.disableLogInfo) this.emit('info', `Set power: ${state ? 'ON' : 'OFF'}`);
|
|
302
302
|
} catch (error) {
|
|
303
303
|
this.emit('warn', `Set power error: ${error}`);
|
|
304
304
|
};
|
|
@@ -335,7 +335,7 @@ class DeviceErv extends EventEmitter {
|
|
|
335
335
|
deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.VentilationMode;
|
|
336
336
|
await this.melCloudErv.send(deviceData, this.displayMode);
|
|
337
337
|
const operationModeText = Ventilation.VentilationMode[deviceData.Device.VentilationMode];
|
|
338
|
-
|
|
338
|
+
if (!this.disableLogInfo) this.emit('info', `Set operation mode: ${operationModeText}`);
|
|
339
339
|
} catch (error) {
|
|
340
340
|
this.emit('warn', `Set operation mode error: ${error}`);
|
|
341
341
|
};
|
|
@@ -378,7 +378,7 @@ class DeviceErv extends EventEmitter {
|
|
|
378
378
|
};
|
|
379
379
|
deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.SetFanSpeed;
|
|
380
380
|
await this.melCloudErv.send(deviceData, this.displayMode);
|
|
381
|
-
|
|
381
|
+
if (!this.disableLogInfo) this.emit('info', `Set fan speed mode: ${Ventilation.FanSpeed[fanSpeedModeText]}`);
|
|
382
382
|
} catch (error) {
|
|
383
383
|
this.emit('warn', `Set fan speed mode error: ${error}`);
|
|
384
384
|
};
|
|
@@ -400,7 +400,7 @@ class DeviceErv extends EventEmitter {
|
|
|
400
400
|
deviceData.Device.DefaultCoolingSetTemperature = value;
|
|
401
401
|
deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.SetTemperature;
|
|
402
402
|
await this.melCloudErv.send(deviceData, this.displayMode);
|
|
403
|
-
|
|
403
|
+
if (!this.disableLogInfo) this.emit('info', `Set cooling threshold temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
404
404
|
} catch (error) {
|
|
405
405
|
this.emit('warn', `Set cooling threshold temperature error: ${error}`);
|
|
406
406
|
};
|
|
@@ -423,7 +423,7 @@ class DeviceErv extends EventEmitter {
|
|
|
423
423
|
deviceData.Device.DefaultHeatingSetTemperature = value;
|
|
424
424
|
deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.SetTemperature;
|
|
425
425
|
await this.melCloudErv.send(deviceData, this.displayMode);
|
|
426
|
-
|
|
426
|
+
if (!this.disableLogInfo) this.emit('info', `Set heating threshold temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
427
427
|
} catch (error) {
|
|
428
428
|
this.emit('warn', `Set heating threshold temperature error: ${error}`);
|
|
429
429
|
};
|
|
@@ -432,7 +432,7 @@ class DeviceErv extends EventEmitter {
|
|
|
432
432
|
//this.melCloudService.getCharacteristic(Characteristic.LockPhysicalControls)
|
|
433
433
|
// .onGet(async () => {
|
|
434
434
|
// const value = this.accessory.lockPhysicalControl;
|
|
435
|
-
//
|
|
435
|
+
// if (!this.disableLogInfo) this.emit('info', `Lock physical controls: ${value ? 'LOCKED' : 'UNLOCKED'}`);
|
|
436
436
|
// return value;
|
|
437
437
|
// })
|
|
438
438
|
// .onSet(async (value) => {
|
|
@@ -441,7 +441,7 @@ class DeviceErv extends EventEmitter {
|
|
|
441
441
|
// deviceData.Device = deviceData.Device;
|
|
442
442
|
// deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Prohibit;
|
|
443
443
|
// await this.melCloudErv.send(deviceData, this.displayMode);
|
|
444
|
-
//
|
|
444
|
+
// if (!this.disableLogInfo) this.emit('info', `Set local physical controls: ${value ? 'LOCK' : 'UNLOCK'}`);
|
|
445
445
|
// } catch (error) {
|
|
446
446
|
// this.emit('warn', `Set lock physical controls error: ${error}`);
|
|
447
447
|
// };
|
|
@@ -456,7 +456,7 @@ class DeviceErv extends EventEmitter {
|
|
|
456
456
|
value = [false, true][value];
|
|
457
457
|
this.accessory.useFahrenheit = value;
|
|
458
458
|
this.emit('melCloud', 'UseFahrenheit', value);
|
|
459
|
-
|
|
459
|
+
if (!this.disableLogInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
460
460
|
} catch (error) {
|
|
461
461
|
this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
462
462
|
};
|
|
@@ -464,7 +464,7 @@ class DeviceErv extends EventEmitter {
|
|
|
464
464
|
accessory.addService(this.melCloudService);
|
|
465
465
|
break;
|
|
466
466
|
case 2: //Thermostat
|
|
467
|
-
|
|
467
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare thermostat service`);
|
|
468
468
|
this.melCloudService = new Service.Thermostat(serviceName, `Thermostat ${deviceId}`);
|
|
469
469
|
this.melCloudService.setPrimaryService(true);
|
|
470
470
|
this.melCloudService.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
|
|
@@ -508,7 +508,7 @@ class DeviceErv extends EventEmitter {
|
|
|
508
508
|
|
|
509
509
|
await this.melCloudErv.send(deviceData, this.displayMode);
|
|
510
510
|
const operationModeText = Ventilation.VentilationMode[deviceData.Device.VentilationMode];
|
|
511
|
-
|
|
511
|
+
if (!this.disableLogInfo) this.emit('info', `Set operation mode: ${operationModeText}`);
|
|
512
512
|
} catch (error) {
|
|
513
513
|
this.emit('warn', `Set operation mode error: ${error}`);
|
|
514
514
|
};
|
|
@@ -533,7 +533,7 @@ class DeviceErv extends EventEmitter {
|
|
|
533
533
|
deviceData.Device.SetTemperature = value;
|
|
534
534
|
deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.SetTemperature;
|
|
535
535
|
await this.melCloudErv.send(deviceData, this.displayMode);
|
|
536
|
-
|
|
536
|
+
if (!this.disableLogInfo) this.emit('info', `Set temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
537
537
|
} catch (error) {
|
|
538
538
|
this.emit('warn', `Set temperature error: ${error}`);
|
|
539
539
|
};
|
|
@@ -548,7 +548,7 @@ class DeviceErv extends EventEmitter {
|
|
|
548
548
|
value = [false, true][value];
|
|
549
549
|
this.accessory.useFahrenheit = value;
|
|
550
550
|
this.emit('melCloud', 'UseFahrenheit', value);
|
|
551
|
-
|
|
551
|
+
if (!this.disableLogInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
552
552
|
} catch (error) {
|
|
553
553
|
this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
554
554
|
};
|
|
@@ -559,7 +559,7 @@ class DeviceErv extends EventEmitter {
|
|
|
559
559
|
|
|
560
560
|
//temperature sensor service room
|
|
561
561
|
if (this.temperatureSensor && hasRoomTemperature && this.accessory.roomTemperature !== null) {
|
|
562
|
-
|
|
562
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare room temperature sensor service`);
|
|
563
563
|
this.roomTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Room`, `Room Temperature Sensor ${deviceId}`);
|
|
564
564
|
this.roomTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
565
565
|
this.roomTemperatureSensorService.setCharacteristic(Characteristic.ConfiguredName, `${serviceName} Room`);
|
|
@@ -578,7 +578,7 @@ class DeviceErv extends EventEmitter {
|
|
|
578
578
|
|
|
579
579
|
//temperature sensor service supply
|
|
580
580
|
if (this.temperatureSensorSupply && hasSupplyTemperature && this.accessory.supplyTemperature !== null) {
|
|
581
|
-
|
|
581
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare supply temperature sensor service`);
|
|
582
582
|
this.supplyTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Supply`, `Supply Temperature Sensor ${deviceId}`);
|
|
583
583
|
this.supplyTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
584
584
|
this.supplyTemperatureSensorService.setCharacteristic(Characteristic.ConfiguredName, `${serviceName} Supply`);
|
|
@@ -597,7 +597,7 @@ class DeviceErv extends EventEmitter {
|
|
|
597
597
|
|
|
598
598
|
//temperature sensor service outdoor
|
|
599
599
|
if (this.temperatureSensorOutdoor && hasOutdoorTemperature && this.accessory.outdoorTemperature !== null) {
|
|
600
|
-
|
|
600
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare outdoor temperature sensor service`);
|
|
601
601
|
this.outdoorTemperatureSensorService = new Service.TemperatureSensor(`${serviceName} Outdoor`, `Outdoor Temperature Sensor ${deviceId}`);
|
|
602
602
|
this.outdoorTemperatureSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
603
603
|
this.outdoorTemperatureSensorService.setCharacteristic(Characteristic.ConfiguredName, `${serviceName} Outdoor`);
|
|
@@ -680,7 +680,7 @@ class DeviceErv extends EventEmitter {
|
|
|
680
680
|
|
|
681
681
|
//presets services
|
|
682
682
|
if (this.presetsConfiguredCount > 0) {
|
|
683
|
-
|
|
683
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare presets services`);
|
|
684
684
|
this.presetsServices = [];
|
|
685
685
|
this.presetsConfigured.forEach((preset, i) => {
|
|
686
686
|
const presetData = presetsOnServer.find(p => p.ID === preset.Id);
|
|
@@ -725,7 +725,7 @@ class DeviceErv extends EventEmitter {
|
|
|
725
725
|
};
|
|
726
726
|
|
|
727
727
|
await this.melCloudErv.send(deviceData, this.displayMode);
|
|
728
|
-
|
|
728
|
+
if (!this.disableLogInfo) this.emit('info', `${state ? 'Set:' : 'Unset:'} ${name}`);
|
|
729
729
|
} catch (error) {
|
|
730
730
|
this.emit('warn', `Set preset error: ${error}`);
|
|
731
731
|
};
|
|
@@ -737,7 +737,7 @@ class DeviceErv extends EventEmitter {
|
|
|
737
737
|
|
|
738
738
|
//buttons services
|
|
739
739
|
if (this.buttonsConfiguredCount > 0) {
|
|
740
|
-
|
|
740
|
+
if (this.enableDebugMode) this.emit('debug', `Prepare buttons services`);
|
|
741
741
|
this.buttonsServices = [];
|
|
742
742
|
this.buttonsConfigured.forEach((button, i) => {
|
|
743
743
|
//get button mode
|
|
@@ -839,7 +839,7 @@ class DeviceErv extends EventEmitter {
|
|
|
839
839
|
};
|
|
840
840
|
|
|
841
841
|
await this.melCloudErv.send(deviceData, this.displayMode);
|
|
842
|
-
|
|
842
|
+
if (!this.disableLogInfo) this.emit('info', `${state ? `Set: ${buttonName}` : `Unset: ${buttonName}, Set: ${button.previousValue}`}`);
|
|
843
843
|
} catch (error) {
|
|
844
844
|
this.emit('warn', `Set button error: ${error}`);
|
|
845
845
|
};
|
package/src/melcloud.js
CHANGED
|
@@ -43,7 +43,7 @@ class MelCloud extends EventEmitter {
|
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
async connect() {
|
|
46
|
-
|
|
46
|
+
if (this.enableDebugMode) this.emit('debug', `Connecting to MELCloud`);
|
|
47
47
|
|
|
48
48
|
try {
|
|
49
49
|
const axiosInstanceLogin = axios.create({
|
|
@@ -75,7 +75,7 @@ class MelCloud extends EventEmitter {
|
|
|
75
75
|
MapLongitude: 'removed',
|
|
76
76
|
MapLatitude: 'removed'
|
|
77
77
|
};
|
|
78
|
-
|
|
78
|
+
if (this.enableDebugMode) this.emit('debug', `MELCloud Info: ${JSON.stringify(debugData, null, 2)}`);
|
|
79
79
|
|
|
80
80
|
if (contextKey === undefined || contextKey === null) {
|
|
81
81
|
this.emit('warn', `Context key: ${contextKey}, missing`)
|
|
@@ -137,10 +137,10 @@ class MelCloud extends EventEmitter {
|
|
|
137
137
|
})
|
|
138
138
|
});
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
if (this.enableDebugMode) this.emit('debug', `Scanning for devices`);
|
|
141
141
|
const listDevicesData = await axiosInstanceGet(ApiUrls.ListDevices);
|
|
142
142
|
const buildingsList = listDevicesData.data;
|
|
143
|
-
|
|
143
|
+
if (this.enableDebugMode) this.emit('debug', `Buildings: ${JSON.stringify(buildingsList, null, 2)}`);
|
|
144
144
|
|
|
145
145
|
if (!buildingsList) {
|
|
146
146
|
this.emit('warn', `No building found`);
|
|
@@ -149,7 +149,7 @@ class MelCloud extends EventEmitter {
|
|
|
149
149
|
|
|
150
150
|
//save buildings to the file
|
|
151
151
|
await this.saveData(this.buildingsFile, buildingsList);
|
|
152
|
-
|
|
152
|
+
if (this.enableDebugMode) this.emit('debug', `Buildings list saved`);
|
|
153
153
|
|
|
154
154
|
//read buildings structure and get the devices
|
|
155
155
|
const devices = [];
|
|
@@ -175,7 +175,7 @@ class MelCloud extends EventEmitter {
|
|
|
175
175
|
|
|
176
176
|
//save buildings to the file
|
|
177
177
|
await this.saveData(this.devicesFile, devices);
|
|
178
|
-
|
|
178
|
+
if (this.enableDebugMode) this.emit('debug', `${devicesCount} devices saved`);
|
|
179
179
|
|
|
180
180
|
return devices;
|
|
181
181
|
} catch (error) {
|
|
@@ -186,7 +186,7 @@ class MelCloud extends EventEmitter {
|
|
|
186
186
|
async saveData(path, data) {
|
|
187
187
|
try {
|
|
188
188
|
await fsPromises.writeFile(path, JSON.stringify(data, null, 2));
|
|
189
|
-
|
|
189
|
+
if (this.enableDebugMode) this.emit('debug', `Data saved to: ${path}`);
|
|
190
190
|
return true;
|
|
191
191
|
} catch (error) {
|
|
192
192
|
throw new Error(`Save data error: ${error}`);
|
package/src/melcloudata.js
CHANGED
|
@@ -52,7 +52,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
52
52
|
return null;
|
|
53
53
|
}
|
|
54
54
|
const deviceData = devicesData.find(device => device.DeviceID === this.deviceId);
|
|
55
|
-
|
|
55
|
+
if (this.enableDebugMode) this.emit('debug', `Device Data: ${JSON.stringify(deviceData, null, 2)}`);
|
|
56
56
|
|
|
57
57
|
//device info
|
|
58
58
|
const deviceId = deviceData.DeviceID;
|
|
@@ -344,7 +344,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
344
344
|
//check state changes
|
|
345
345
|
const deviceDataHasNotChanged = JSON.stringify(deviceState) === JSON.stringify(this.deviceState);
|
|
346
346
|
if (deviceDataHasNotChanged) {
|
|
347
|
-
|
|
347
|
+
if (this.enableDebugMode) this.emit('debug', `Device state not changed`);
|
|
348
348
|
return;
|
|
349
349
|
}
|
|
350
350
|
this.deviceState = deviceState;
|
package/src/melcloudatw.js
CHANGED
|
@@ -52,7 +52,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
52
52
|
return null;
|
|
53
53
|
}
|
|
54
54
|
const deviceData = devicesData.find(device => device.DeviceID === this.deviceId);
|
|
55
|
-
|
|
55
|
+
if (this.enableDebugMode) this.emit('debug', `Device Data: ${JSON.stringify(deviceData, null, 2)}`);
|
|
56
56
|
|
|
57
57
|
//device info
|
|
58
58
|
const deviceId = deviceData.DeviceID;
|
|
@@ -408,7 +408,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
408
408
|
//check state changes
|
|
409
409
|
const deviceDataHasNotChanged = JSON.stringify(deviceState) === JSON.stringify(this.deviceState);
|
|
410
410
|
if (deviceDataHasNotChanged) {
|
|
411
|
-
|
|
411
|
+
if (this.enableDebugMode) this.emit('debug', `Device state not changed`);
|
|
412
412
|
return;
|
|
413
413
|
}
|
|
414
414
|
this.deviceState = deviceState;
|
package/src/melclouderv.js
CHANGED
|
@@ -52,7 +52,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
52
52
|
return null;
|
|
53
53
|
}
|
|
54
54
|
const deviceData = devicesData.find(device => device.DeviceID === this.deviceId);
|
|
55
|
-
|
|
55
|
+
if (this.enableDebugMode) this.emit('debug', `Device Data: ${JSON.stringify(deviceData, null, 2)}`);
|
|
56
56
|
|
|
57
57
|
//deviceData
|
|
58
58
|
const deviceId = deviceData.DeviceID;
|
|
@@ -332,7 +332,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
332
332
|
//check state changes
|
|
333
333
|
const deviceDataHasNotChanged = JSON.stringify(deviceState) === JSON.stringify(this.deviceState);
|
|
334
334
|
if (deviceDataHasNotChanged) {
|
|
335
|
-
|
|
335
|
+
if (this.enableDebugMode) this.emit('debug', `Device state not changed`);
|
|
336
336
|
return;
|
|
337
337
|
}
|
|
338
338
|
this.deviceState = deviceState;
|