homebridge-melcloud-control 4.4.1-beta.36 → 4.4.1-beta.39
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/homebridge-ui/public/index.html +63 -61
- package/index.js +17 -5
- package/package.json +1 -1
- package/src/deviceata.js +4 -4
- package/src/deviceatw.js +4 -4
- package/src/deviceerv.js +4 -4
- package/src/melcloud.js +6 -4
- package/src/melcloudhome.js +6 -4
|
@@ -284,79 +284,81 @@
|
|
|
284
284
|
deviceTypeString,
|
|
285
285
|
displayType: 0,
|
|
286
286
|
name: device.DeviceName,
|
|
287
|
-
presets: [],
|
|
288
|
-
schedules: [],
|
|
289
|
-
scenes: []
|
|
290
287
|
};
|
|
291
288
|
devicesInConfig.push(deviceInConfig);
|
|
292
289
|
newDevices.push(deviceInConfig);
|
|
293
290
|
configDevicesMap.set(deviceId, deviceInConfig);
|
|
294
291
|
}
|
|
295
292
|
|
|
296
|
-
// PRESETS
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
293
|
+
//ONLY MELCLOUD - PRESETS
|
|
294
|
+
if (account.type === 'melcloud') {
|
|
295
|
+
deviceInConfig.presets = deviceInConfig.presets ?? [];
|
|
296
|
+
const presetsInMelCloud = device.Presets || [];
|
|
297
|
+
removedFromConfig.ataPresets.push(...removeStaleEntities(deviceInConfig.presets, presetsInMelCloud, p => p.id, p => p.ID));
|
|
298
|
+
const presetIds = new Set(deviceInConfig.presets.map(p => String(p.id)));
|
|
299
|
+
presetsInMelCloud.forEach((preset, index) => {
|
|
300
|
+
const presetId = String(preset.ID);
|
|
301
|
+
if (!presetIds.has(presetId)) {
|
|
302
|
+
const presetObj = {
|
|
303
|
+
id: presetId,
|
|
304
|
+
displayType: 0,
|
|
305
|
+
name: preset.NumberDescription || `Preset ${index}`,
|
|
306
|
+
namePrefix: false
|
|
307
|
+
};
|
|
308
|
+
deviceInConfig.presets.push(presetObj);
|
|
309
|
+
newPresets.push(presetObj);
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
//ONLY MELCLOUD HOME - SCHEDULES & SCENES
|
|
315
|
+
if (account.type === 'melcloudhome') {
|
|
316
|
+
// SCHEDULES
|
|
317
|
+
deviceInConfig.schedules = deviceInConfig.schedules ?? [];
|
|
318
|
+
const schedulesInMelCloud = device.Schedule || [];
|
|
319
|
+
removedFromConfig.ataSchedules.push(...removeStaleEntities(deviceInConfig.schedules, schedulesInMelCloud, s => s.id, s => s.Id));
|
|
320
|
+
const scheduleIds = new Set(deviceInConfig.schedules.map(s => String(s.id)));
|
|
321
|
+
schedulesInMelCloud.forEach((schedule, index) => {
|
|
322
|
+
const scheduleId = String(schedule.Id);
|
|
323
|
+
if (!scheduleIds.has(scheduleId)) {
|
|
324
|
+
const scheduleObj = {
|
|
325
|
+
id: scheduleId,
|
|
326
|
+
displayType: 0,
|
|
327
|
+
name: `Schedule ${index}`,
|
|
328
|
+
namePrefix: false
|
|
329
|
+
};
|
|
330
|
+
deviceInConfig.schedules.push(scheduleObj);
|
|
331
|
+
newSchedules.push(scheduleObj);
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
// SCENES
|
|
336
|
+
deviceInConfig.scenes = deviceInConfig.scenes ?? [];
|
|
337
|
+
removedFromConfig.scenes.push(...removeStaleEntities(deviceInConfig.scenes, scenesInMelCloud, s => s.id, s => s.Id));
|
|
338
|
+
const sceneIds = new Set(deviceInConfig.scenes.map(s => String(s.id)));
|
|
339
|
+
scenesInMelCloud.forEach((scene, index) => {
|
|
340
|
+
const sceneId = String(scene.Id);
|
|
341
|
+
if (!sceneIds.has(sceneId)) {
|
|
342
|
+
const sceneObj = {
|
|
343
|
+
id: sceneId,
|
|
344
|
+
displayType: 0,
|
|
345
|
+
name: scene.Name || `Scene ${index}`,
|
|
346
|
+
namePrefix: false
|
|
347
|
+
};
|
|
348
|
+
deviceInConfig.scenes.push(sceneObj);
|
|
349
|
+
if (index === 0) newScenes.push(sceneObj);
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
}
|
|
351
353
|
});
|
|
352
354
|
|
|
353
355
|
return devicesInConfig;
|
|
354
356
|
};
|
|
355
357
|
|
|
356
358
|
// Execute device handlers
|
|
357
|
-
account.ataDevices = handleDevices(devicesInMelCloudByType.ata, account.ataDevices, "Air Conditioner", newInMelCloud.ata, newInMelCloud.ataPresets, newInMelCloud.ataSchedules, newInMelCloud.
|
|
358
|
-
account.atwDevices = handleDevices(devicesInMelCloudByType.atw, account.atwDevices, "Heat Pump", newInMelCloud.atw, newInMelCloud.atwPresets, newInMelCloud.atwSchedules, newInMelCloud.
|
|
359
|
-
account.ervDevices = handleDevices(devicesInMelCloudByType.erv, account.ervDevices, "Energy Recovery Ventilation", newInMelCloud.erv, newInMelCloud.ervPresets, newInMelCloud.ervSchedules, newInMelCloud.
|
|
359
|
+
account.ataDevices = handleDevices(devicesInMelCloudByType.ata, account.ataDevices, "Air Conditioner", newInMelCloud.ata, newInMelCloud.ataPresets, newInMelCloud.ataSchedules, newInMelCloud.scenes);
|
|
360
|
+
account.atwDevices = handleDevices(devicesInMelCloudByType.atw, account.atwDevices, "Heat Pump", newInMelCloud.atw, newInMelCloud.atwPresets, newInMelCloud.atwSchedules, newInMelCloud.scenes);
|
|
361
|
+
account.ervDevices = handleDevices(devicesInMelCloudByType.erv, account.ervDevices, "Energy Recovery Ventilation", newInMelCloud.erv, newInMelCloud.ervPresets, newInMelCloud.ervSchedules, newInMelCloud.scenes);
|
|
360
362
|
|
|
361
363
|
// Summary
|
|
362
364
|
const newDevicesCount = newInMelCloud.ata.length + newInMelCloud.atw.length + newInMelCloud.erv.length;
|
package/index.js
CHANGED
|
@@ -137,12 +137,24 @@ class MelCloudPlatform {
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
//chack device from config exist on melcloud
|
|
140
|
-
const
|
|
141
|
-
if (!
|
|
140
|
+
const deviceInMelCloud = melcloudDevicesList.Devices.find(d => d.DeviceID === device.id);
|
|
141
|
+
if (!deviceInMelCloud) {
|
|
142
142
|
if (logLevel.warn) log.warn(`${name}, ${deviceTypeString}, ${deviceName}, not exist on server, please login to MELCLoud from plugin UI to fix this issue.`);
|
|
143
143
|
continue;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
+
//presets
|
|
147
|
+
const presetIds = (deviceInMelCloud.Presets ?? []).map(p => String(p.ID));
|
|
148
|
+
const presets = account.type === 'melcloud' ? (device.presets || []).filter(p => (p.displayType ?? 0) > 0 && p.id !== '0' && presetIds.includes(p.id)) : [];
|
|
149
|
+
|
|
150
|
+
//schedules
|
|
151
|
+
const schedulesIds = (deviceInMelCloud.Schedule ?? []).map(s => String(s.Id));
|
|
152
|
+
const schedules = account.type === 'melcloudhome' ? (device.schedules || []).filter(s => (s.displayType ?? 0) > 0 && s.id !== '0' && schedulesIds.includes(s.id)) : [];
|
|
153
|
+
|
|
154
|
+
//scenes
|
|
155
|
+
const scenesIds = (melcloudDevicesList.Scenes ?? []).map(s => String(s.Id));
|
|
156
|
+
const scenes = account.type === 'melcloudhome' ? (device.scenes || []).filter(s => (s.displayType ?? 0) > 0 && s.id !== '0' && scenesIds.includes(s.id)) : [];
|
|
157
|
+
|
|
146
158
|
// set rest ful port
|
|
147
159
|
account.restFul.port = (device.id).slice(-4).replace(/^0/, '9');
|
|
148
160
|
|
|
@@ -168,15 +180,15 @@ class MelCloudPlatform {
|
|
|
168
180
|
let configuredDevice;
|
|
169
181
|
switch (deviceType) {
|
|
170
182
|
case 0: //ATA
|
|
171
|
-
configuredDevice = new DeviceAta(api, account, device, defaultTempsFile, accountInfo, accountFile, melcloud, melcloudDevicesList);
|
|
183
|
+
configuredDevice = new DeviceAta(api, account, device, presets, schedules, scenes, defaultTempsFile, accountInfo, accountFile, melcloud, melcloudDevicesList);
|
|
172
184
|
break;
|
|
173
185
|
case 1: //ATW
|
|
174
|
-
configuredDevice = new DeviceAtw(api, account, device, defaultTempsFile, accountInfo, accountFile, melcloud, melcloudDevicesList);
|
|
186
|
+
configuredDevice = new DeviceAtw(api, account, device, presets, schedules, scenes, defaultTempsFile, accountInfo, accountFile, melcloud, melcloudDevicesList);
|
|
175
187
|
break;
|
|
176
188
|
case 2:
|
|
177
189
|
break;
|
|
178
190
|
case 3: //ERV
|
|
179
|
-
configuredDevice = new DeviceErv(api, account, device, defaultTempsFile, accountInfo, accountFile, melcloud, melcloudDevicesList);
|
|
191
|
+
configuredDevice = new DeviceErv(api, account, device, presets, schedules, scenes, defaultTempsFile, accountInfo, accountFile, melcloud, melcloudDevicesList);
|
|
180
192
|
break;
|
|
181
193
|
default:
|
|
182
194
|
if (logLevel.warn) log.warn(`${name}, ${deviceTypeString}, ${deviceName}, unknown device: ${deviceType}.`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.4.1-beta.
|
|
4
|
+
"version": "4.4.1-beta.39",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|
package/src/deviceata.js
CHANGED
|
@@ -7,7 +7,7 @@ import { TemperatureDisplayUnits, AirConditioner } from './constants.js';
|
|
|
7
7
|
let Accessory, Characteristic, Service, Categories, AccessoryUUID;
|
|
8
8
|
|
|
9
9
|
class DeviceAta extends EventEmitter {
|
|
10
|
-
constructor(api, account, device, defaultTempsFile, accountInfo, accountFile, melcloud, melcloudDevicesList) {
|
|
10
|
+
constructor(api, account, device, presets, schedules, scenes, defaultTempsFile, accountInfo, accountFile, melcloud, melcloudDevicesList) {
|
|
11
11
|
super();
|
|
12
12
|
|
|
13
13
|
Accessory = api.platformAccessory;
|
|
@@ -44,9 +44,9 @@ class DeviceAta extends EventEmitter {
|
|
|
44
44
|
this.frostProtectionSupport = device.frostProtectionSupport || false;
|
|
45
45
|
this.overheatProtectionSupport = device.overheatProtectionSupport || false;
|
|
46
46
|
this.holidayModeSupport = device.holidayModeSupport || false;
|
|
47
|
-
this.presets =
|
|
48
|
-
this.schedules =
|
|
49
|
-
this.scenes =
|
|
47
|
+
this.presets = presets;
|
|
48
|
+
this.schedules = schedules;
|
|
49
|
+
this.scenes = scenes;
|
|
50
50
|
this.buttons = (device.buttonsSensors || []).filter(button => (button.displayType ?? 0) > 0);
|
|
51
51
|
|
|
52
52
|
//files
|
package/src/deviceatw.js
CHANGED
|
@@ -7,7 +7,7 @@ import { TemperatureDisplayUnits, HeatPump } from './constants.js';
|
|
|
7
7
|
let Accessory, Characteristic, Service, Categories, AccessoryUUID;
|
|
8
8
|
|
|
9
9
|
class DeviceAtw extends EventEmitter {
|
|
10
|
-
constructor(api, account, device, defaultTempsFile, accountInfo, accountFile, melcloud, melcloudDevicesList) {
|
|
10
|
+
constructor(api, account, device, presets, schedules, scenes, defaultTempsFile, accountInfo, accountFile, melcloud, melcloudDevicesList) {
|
|
11
11
|
super();
|
|
12
12
|
|
|
13
13
|
Accessory = api.platformAccessory;
|
|
@@ -48,9 +48,9 @@ class DeviceAtw extends EventEmitter {
|
|
|
48
48
|
this.errorSensor = device.errorSensor || false;
|
|
49
49
|
this.frostProtectionSupport = device.frostProtectionSupport || false;
|
|
50
50
|
this.holidayModeSupport = device.holidayModeSupport || false;
|
|
51
|
-
|
|
52
|
-
this.schedules =
|
|
53
|
-
this.scenes =
|
|
51
|
+
this.presets = presets;
|
|
52
|
+
this.schedules = schedules;
|
|
53
|
+
this.scenes = scenes;
|
|
54
54
|
this.buttons = (device.buttonsSensors || []).filter(button => (button.displayType ?? 0) > 0);
|
|
55
55
|
|
|
56
56
|
//files
|
package/src/deviceerv.js
CHANGED
|
@@ -7,7 +7,7 @@ import { TemperatureDisplayUnits, Ventilation } from './constants.js';
|
|
|
7
7
|
let Accessory, Characteristic, Service, Categories, AccessoryUUID;
|
|
8
8
|
|
|
9
9
|
class DeviceErv extends EventEmitter {
|
|
10
|
-
constructor(api, account, device, defaultTempsFile, accountInfo, accountFile, melcloud, melcloudDevicesList) {
|
|
10
|
+
constructor(api, account, device, presets, schedules, scenes, defaultTempsFile, accountInfo, accountFile, melcloud, melcloudDevicesList) {
|
|
11
11
|
super();
|
|
12
12
|
|
|
13
13
|
Accessory = api.platformAccessory;
|
|
@@ -40,9 +40,9 @@ class DeviceErv extends EventEmitter {
|
|
|
40
40
|
this.connectSensor = device.connectSensor || false;
|
|
41
41
|
this.errorSensor = device.errorSensor || false;
|
|
42
42
|
this.holidayModeSupport = device.holidayModeSupport || false;
|
|
43
|
-
this.presets =
|
|
44
|
-
this.schedules =
|
|
45
|
-
this.scenes =
|
|
43
|
+
this.presets = presets;
|
|
44
|
+
this.schedules = schedules;
|
|
45
|
+
this.scenes = scenes;
|
|
46
46
|
this.buttons = (device.buttonsSensors || []).filter(button => (button.displayType ?? 0) > 0);
|
|
47
47
|
|
|
48
48
|
//files
|
package/src/melcloud.js
CHANGED
|
@@ -54,7 +54,7 @@ class MelCloud extends EventEmitter {
|
|
|
54
54
|
|
|
55
55
|
async checkDevicesList() {
|
|
56
56
|
try {
|
|
57
|
-
const devicesList = { State: false, Info: null, Devices: [], Scenes: [] }
|
|
57
|
+
const devicesList = { State: false, Info: null, Buildings: [], Devices: [], Scenes: [] }
|
|
58
58
|
if (this.logDebug) this.emit('debug', `Scanning for devices...`);
|
|
59
59
|
const listDevicesData = await this.client(ApiUrls.Get.ListDevices, { method: 'GET', });
|
|
60
60
|
|
|
@@ -71,9 +71,6 @@ class MelCloud extends EventEmitter {
|
|
|
71
71
|
return devicesList;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
await this.functions.saveData(this.buildingsFile, buildingsList);
|
|
75
|
-
if (this.logDebug) this.emit('debug', `Buildings list saved`);
|
|
76
|
-
|
|
77
74
|
const devices = [];
|
|
78
75
|
for (const building of buildingsList) {
|
|
79
76
|
if (!building.Structure) {
|
|
@@ -108,7 +105,12 @@ class MelCloud extends EventEmitter {
|
|
|
108
105
|
|
|
109
106
|
devicesList.State = true;
|
|
110
107
|
devicesList.Info = `Found ${devicesCount} devices`;
|
|
108
|
+
devicesList.Buildings = buildingsList;
|
|
111
109
|
devicesList.Devices = devices;
|
|
110
|
+
|
|
111
|
+
await this.functions.saveData(this.buildingsFile, devicesList);
|
|
112
|
+
if (this.logDebug) this.emit('debug', `Buildings list saved`);
|
|
113
|
+
|
|
112
114
|
this.emit('devicesList', devicesList);
|
|
113
115
|
|
|
114
116
|
return devicesList;
|
package/src/melcloudhome.js
CHANGED
|
@@ -107,7 +107,7 @@ class MelCloudHome extends EventEmitter {
|
|
|
107
107
|
|
|
108
108
|
async checkDevicesList() {
|
|
109
109
|
try {
|
|
110
|
-
const devicesList = { State: false, Info: null, Devices: [], Scenes: [] }
|
|
110
|
+
const devicesList = { State: false, Info: null, Buildings: {}, Devices: [], Scenes: [] }
|
|
111
111
|
if (this.logDebug) this.emit('debug', `Scanning for devices`);
|
|
112
112
|
const listDevicesData = await this.client(ApiUrls.Home.Get.ListDevices, { method: 'GET' });
|
|
113
113
|
|
|
@@ -122,9 +122,6 @@ class MelCloudHome extends EventEmitter {
|
|
|
122
122
|
return devicesList;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
await this.functions.saveData(this.buildingsFile, userContext);
|
|
126
|
-
if (this.logDebug) this.emit('debug', `Buildings list saved`);
|
|
127
|
-
|
|
128
125
|
const devices = buildingsList.flatMap(building => {
|
|
129
126
|
// Funkcja kapitalizująca klucze obiektu
|
|
130
127
|
const capitalizeKeys = obj => Object.fromEntries(Object.entries(obj).map(([key, value]) => [key.charAt(0).toUpperCase() + key.slice(1), value]));
|
|
@@ -205,8 +202,13 @@ class MelCloudHome extends EventEmitter {
|
|
|
205
202
|
|
|
206
203
|
devicesList.State = true;
|
|
207
204
|
devicesList.Info = `Found ${devicesCount} devices ${scenes.length > 0 ? `and ${scenes.length} scenes` : ''}`;
|
|
205
|
+
devicesList.Buildings = userContext;
|
|
208
206
|
devicesList.Devices = devices;
|
|
209
207
|
devicesList.Scenes = scenes;
|
|
208
|
+
|
|
209
|
+
await this.functions.saveData(this.buildingsFile, devicesList);
|
|
210
|
+
if (this.logDebug) this.emit('debug', `Buildings list saved`);
|
|
211
|
+
|
|
210
212
|
this.emit('devicesList', devicesList);
|
|
211
213
|
|
|
212
214
|
return devicesList;
|