homebridge-melcloud-control 4.0.0-beta.52 → 4.0.0-beta.521
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 -4
- package/README.md +10 -12
- package/config.schema.json +294 -336
- package/homebridge-ui/public/index.html +110 -64
- package/homebridge-ui/server.js +7 -9
- package/index.js +45 -28
- package/package.json +5 -4
- package/src/constants.js +15 -22
- package/src/deviceata.js +252 -243
- package/src/deviceatw.js +50 -40
- package/src/deviceerv.js +43 -35
- package/src/functions.js +155 -5
- package/src/melcloud.js +345 -180
- package/src/melcloudata.js +146 -306
- package/src/melcloudatw.js +145 -340
- package/src/melclouderv.js +144 -271
- package/src/restful.js +1 -1
package/src/deviceatw.js
CHANGED
|
@@ -6,7 +6,7 @@ import { TemperatureDisplayUnits, HeatPump } from './constants.js';
|
|
|
6
6
|
let Accessory, Characteristic, Service, Categories, AccessoryUUID;
|
|
7
7
|
|
|
8
8
|
class DeviceAtw extends EventEmitter {
|
|
9
|
-
constructor(api, account, device, contextKey, devicesFile, useFahrenheit, restFul, mqtt) {
|
|
9
|
+
constructor(api, account, device, contextKey, devicesFile, defaultTempsFile, useFahrenheit, restFul, mqtt) {
|
|
10
10
|
super();
|
|
11
11
|
|
|
12
12
|
Accessory = api.platformAccessory;
|
|
@@ -16,8 +16,17 @@ class DeviceAtw extends EventEmitter {
|
|
|
16
16
|
AccessoryUUID = api.hap.uuid;
|
|
17
17
|
|
|
18
18
|
//account config
|
|
19
|
+
this.account = account;
|
|
20
|
+
this.accountType = account.type;
|
|
21
|
+
this.accountName = account.name;
|
|
22
|
+
this.logDeviceInfo = account.log?.deviceInfo || false;
|
|
23
|
+
this.logInfo = account.log?.info || false;
|
|
24
|
+
this.logWarn = account.log?.warn || false;
|
|
25
|
+
this.logDebug = account.log?.debug || false;
|
|
26
|
+
|
|
27
|
+
//device config
|
|
19
28
|
this.device = device;
|
|
20
|
-
this.
|
|
29
|
+
this.displayType = device.displayType;
|
|
21
30
|
this.hideZone = device.hideZone;
|
|
22
31
|
this.temperatureSensor = device.temperatureSensor || false;
|
|
23
32
|
this.temperatureSensorFlow = device.temperatureSensorFlow || false;
|
|
@@ -30,16 +39,11 @@ class DeviceAtw extends EventEmitter {
|
|
|
30
39
|
this.temperatureSensorReturnZone2 = device.temperatureSensorReturnZone2 || false;
|
|
31
40
|
this.presets = (device.presets || []).filter(preset => (preset.displayType ?? 0) > 0);
|
|
32
41
|
this.buttons = (device.buttonsSensors || []).filter(button => (button.displayType ?? 0) > 0);
|
|
33
|
-
this.logDeviceInfo = account.log?.deviceInfo || false;
|
|
34
|
-
this.logInfo = account.log?.info || false;
|
|
35
|
-
this.logWarn = account.log?.warn || false;
|
|
36
|
-
this.logDebug = account.log?.debug || false;
|
|
37
|
-
this.contextKey = contextKey;
|
|
38
|
-
this.accountName = account.name;
|
|
39
42
|
this.deviceId = device.id;
|
|
40
43
|
this.deviceName = device.name;
|
|
41
44
|
this.deviceTypeText = device.typeString;
|
|
42
45
|
this.devicesFile = devicesFile;
|
|
46
|
+
this.defaultTempsFile = defaultTempsFile;
|
|
43
47
|
this.displayDeviceInfo = true;
|
|
44
48
|
|
|
45
49
|
//external integrations
|
|
@@ -159,87 +163,87 @@ class DeviceAtw extends EventEmitter {
|
|
|
159
163
|
case 'Power':
|
|
160
164
|
deviceData.Device[key] = value;
|
|
161
165
|
deviceData.Device.EffectiveFlags = HeatPump.EffectiveFlags.Power;
|
|
162
|
-
set = await this.melCloudAtw.send(deviceData);
|
|
166
|
+
set = await this.melCloudAtw.send(this.accountType, this.displayType, deviceData);
|
|
163
167
|
break;
|
|
164
168
|
case 'OperationMode':
|
|
165
169
|
deviceData.Device[key] = value;
|
|
166
170
|
deviceData.Device.EffectiveFlags = HeatPump.EffectiveFlags.OperationMode;
|
|
167
|
-
set = await this.melCloudAtw.send(deviceData);
|
|
171
|
+
set = await this.melCloudAtw.send(this.accountType, this.displayType, deviceData);
|
|
168
172
|
break;
|
|
169
173
|
case 'OperationModeZone1':
|
|
170
174
|
deviceData.Device[key] = value;
|
|
171
175
|
deviceData.Device.EffectiveFlags = HeatPump.EffectiveFlags.OperationModeZone1;
|
|
172
|
-
set = await this.melCloudAtw.send(deviceData);
|
|
176
|
+
set = await this.melCloudAtw.send(this.accountType, this.displayType, deviceData);
|
|
173
177
|
break;
|
|
174
178
|
case 'OperationModeZone2':
|
|
175
179
|
deviceData.Device[key] = value;
|
|
176
180
|
deviceData.Device.EffectiveFlags = HeatPump.EffectiveFlags.OperationModeZone2;
|
|
177
|
-
set = await this.melCloudAtw.send(deviceData);
|
|
181
|
+
set = await this.melCloudAtw.send(this.accountType, this.displayType, deviceData);
|
|
178
182
|
break;
|
|
179
183
|
case 'SetTemperatureZone1':
|
|
180
184
|
deviceData.Device[key] = value;
|
|
181
185
|
deviceData.Device.EffectiveFlags = HeatPump.EffectiveFlags.SetTemperatureZone2;
|
|
182
|
-
set = await this.melCloudAtw.send(deviceData);
|
|
186
|
+
set = await this.melCloudAtw.send(this.accountType, this.displayType, deviceData);
|
|
183
187
|
break;
|
|
184
188
|
case 'SetTemperatureZone2':
|
|
185
189
|
deviceData.Device[key] = value;
|
|
186
190
|
deviceData.Device.EffectiveFlags = HeatPump.EffectiveFlags.SetTemperatureZone2;
|
|
187
|
-
set = await this.melCloudAtw.send(deviceData);
|
|
191
|
+
set = await this.melCloudAtw.send(this.accountType, this.displayType, deviceData);
|
|
188
192
|
break;
|
|
189
193
|
case 'SetHeatFlowTemperatureZone1':
|
|
190
194
|
deviceData.Device[key] = value;
|
|
191
195
|
deviceData.Device.EffectiveFlags = HeatPump.EffectiveFlags.SetHeatFlowTemperatureZone1;
|
|
192
|
-
set = await this.melCloudAtw.send(deviceData);
|
|
196
|
+
set = await this.melCloudAtw.send(this.accountType, this.displayType, deviceData);
|
|
193
197
|
break;
|
|
194
198
|
case 'SetHeatFlowTemperatureZone2':
|
|
195
199
|
deviceData.Device[key] = value;
|
|
196
200
|
deviceData.Device.EffectiveFlags = HeatPump.EffectiveFlags.SetHeatFlowTemperatureZone2;
|
|
197
|
-
set = await this.melCloudAtw.send(deviceData);
|
|
201
|
+
set = await this.melCloudAtw.send(this.accountType, this.displayType, deviceData);
|
|
198
202
|
break;
|
|
199
203
|
case 'SetCoolFlowTemperatureZone1':
|
|
200
204
|
deviceData.Device[key] = value;
|
|
201
205
|
deviceData.Device.EffectiveFlags = HeatPump.EffectiveFlags.SetCoolFlowTemperatureZone1;
|
|
202
|
-
set = await this.melCloudAtw.send(deviceData);
|
|
206
|
+
set = await this.melCloudAtw.send(this.accountType, this.displayType, deviceData);
|
|
203
207
|
break;
|
|
204
208
|
case 'SetCoolFlowTemperatureZone2':
|
|
205
209
|
deviceData.Device[key] = value;
|
|
206
210
|
deviceData.Device.EffectiveFlags = HeatPump.EffectiveFlags.SetCoolFlowTemperatureZone2;
|
|
207
|
-
set = await this.melCloudAtw.send(deviceData);
|
|
211
|
+
set = await this.melCloudAtw.send(this.accountType, this.displayType, deviceData);
|
|
208
212
|
break;
|
|
209
213
|
case 'SetTankWaterTemperature':
|
|
210
214
|
deviceData.Device[key] = value;
|
|
211
215
|
deviceData.Device.EffectiveFlags = HeatPump.EffectiveFlags.SetTankWaterTemperature;
|
|
212
|
-
set = await this.melCloudAtw.send(deviceData);
|
|
216
|
+
set = await this.melCloudAtw.send(this.accountType, this.displayType, deviceData);
|
|
213
217
|
break;
|
|
214
218
|
case 'ForcedHotWaterMode':
|
|
215
219
|
deviceData.Device[key] = value;
|
|
216
220
|
deviceData.Device.EffectiveFlags = HeatPump.EffectiveFlags.ForcedHotWaterMode;
|
|
217
|
-
set = await this.melCloudAtw.send(deviceData);
|
|
221
|
+
set = await this.melCloudAtw.send(this.accountType, this.displayType, deviceData);
|
|
218
222
|
break;
|
|
219
223
|
case 'EcoHotWater':
|
|
220
224
|
deviceData.Device[key] = value;
|
|
221
225
|
deviceData.Device.EffectiveFlags = HeatPump.EffectiveFlags.EcoHotWater;
|
|
222
|
-
set = await this.melCloudAtw.send(deviceData);
|
|
226
|
+
set = await this.melCloudAtw.send(this.accountType, this.displayType, deviceData);
|
|
223
227
|
break;
|
|
224
228
|
case 'HolidayMode':
|
|
225
229
|
deviceData.Device[key] = value;
|
|
226
230
|
deviceData.Device.EffectiveFlags = HeatPump.EffectiveFlags.HolidayMode;
|
|
227
|
-
set = await this.melCloudAtw.send(deviceData);
|
|
231
|
+
set = await this.melCloudAtw.send(this.accountType, this.displayType, deviceData);
|
|
228
232
|
break;
|
|
229
233
|
case 'ProhibitZone1':
|
|
230
234
|
deviceData.Device[key] = value;
|
|
231
235
|
deviceData.Device.EffectiveFlags = HeatPump.EffectiveFlags.ProhibitZone1;
|
|
232
|
-
set = await this.melCloudAtw.send(deviceData);
|
|
236
|
+
set = await this.melCloudAtw.send(this.accountType, this.displayType, deviceData);
|
|
233
237
|
break;
|
|
234
238
|
case 'ProhibitZone2':
|
|
235
239
|
deviceData.Device[key] = value;
|
|
236
240
|
deviceData.Device.EffectiveFlags = HeatPump.EffectiveFlags.ProhibitZone2;
|
|
237
|
-
set = await this.melCloudAtw.send(deviceData);
|
|
241
|
+
set = await this.melCloudAtw.send(this.accountType, this.displayType, deviceData);
|
|
238
242
|
break;
|
|
239
243
|
case 'ProhibitHotWater':
|
|
240
244
|
deviceData.Device[key] = value;
|
|
241
245
|
deviceData.Device.EffectiveFlags = HeatPump.EffectiveFlags.ProhibitHotWater;
|
|
242
|
-
set = await this.melCloudAtw.send(deviceData);
|
|
246
|
+
set = await this.melCloudAtw.send(this.accountType, this.displayType, deviceData);
|
|
243
247
|
break;
|
|
244
248
|
default:
|
|
245
249
|
this.emit('warn', `${integration}, received key: ${key}, value: ${value}`);
|
|
@@ -305,7 +309,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
305
309
|
this.accessory.zones.forEach((zone, i) => {
|
|
306
310
|
const zoneName = zone.name
|
|
307
311
|
const serviceName = `${deviceTypeText} ${accessoryName}: ${zoneName}`;
|
|
308
|
-
switch (this.
|
|
312
|
+
switch (this.displayType) {
|
|
309
313
|
case 1: //Heater Cooler
|
|
310
314
|
if (this.logDebug) this.emit('debug', `Prepare heather/cooler ${zoneName} service`);
|
|
311
315
|
const melCloudService = new Service.HeaterCooler(serviceName, `HeaterCooler ${deviceId} ${i}`);
|
|
@@ -321,7 +325,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
321
325
|
case 0: //Heat Pump
|
|
322
326
|
deviceData.Device.Power = [false, true][state];
|
|
323
327
|
deviceData.Device.EffectiveFlags = HeatPump.EffectiveFlags.Power;
|
|
324
|
-
await this.melCloudAtw.send(deviceData);
|
|
328
|
+
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData);
|
|
325
329
|
if (this.logInfo) this.emit('info', `${zoneName}, Set power: ${state ? 'ON' : 'OFF'}`);
|
|
326
330
|
break;
|
|
327
331
|
};
|
|
@@ -420,7 +424,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
420
424
|
break;
|
|
421
425
|
};
|
|
422
426
|
|
|
423
|
-
await this.melCloudAtw.send(deviceData);
|
|
427
|
+
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData);
|
|
424
428
|
if (this.logInfo) this.emit('info', `${zoneName}, Set operation mode: ${operationModeText}`);
|
|
425
429
|
} catch (error) {
|
|
426
430
|
if (this.logWarn) this.emit('warn', `${zoneName}, Set operation mode error: ${error}`);
|
|
@@ -493,7 +497,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
493
497
|
break;
|
|
494
498
|
};
|
|
495
499
|
|
|
496
|
-
const set = i > 0 ? await this.melCloudAtw.send(deviceData) : false;
|
|
500
|
+
const set = i > 0 ? await this.melCloudAtw.send(this.accountType, this.displayType, deviceData) : false;
|
|
497
501
|
const info = this.logInfo || i === 0 ? false : this.emit('info', `${zoneName}, Set cooling threshold temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
498
502
|
} catch (error) {
|
|
499
503
|
if (this.logWarn) this.emit('warn', `${zoneName}, Set cooling threshold temperature error: ${error}`);
|
|
@@ -557,7 +561,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
557
561
|
break;
|
|
558
562
|
};
|
|
559
563
|
|
|
560
|
-
const set = i > 0 ? await this.melCloudAtw.send(deviceData) : false;
|
|
564
|
+
const set = i > 0 ? await this.melCloudAtw.send(this.accountType, this.displayType, deviceData) : false;
|
|
561
565
|
const info = this.logInfo || i === 0 ? false : this.emit('info', `${zoneName}, Set heating threshold temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
562
566
|
} catch (error) {
|
|
563
567
|
if (this.logWarn) this.emit('warn', `${zoneName}, Set heating threshold temperature error: ${error}`);
|
|
@@ -570,6 +574,8 @@ class DeviceAtw extends EventEmitter {
|
|
|
570
574
|
return value;
|
|
571
575
|
})
|
|
572
576
|
.onSet(async (value) => {
|
|
577
|
+
if (this.account.type === 'melcloudhome') return;
|
|
578
|
+
|
|
573
579
|
try {
|
|
574
580
|
value = value ? true : false;
|
|
575
581
|
switch (i) {
|
|
@@ -593,7 +599,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
593
599
|
break;
|
|
594
600
|
};
|
|
595
601
|
|
|
596
|
-
await this.melCloudAtw.send(deviceData);
|
|
602
|
+
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData);
|
|
597
603
|
if (this.logInfo) this.emit('info', `${zoneName}, Set lock physical controls: ${value ? 'LOCK' : 'UNLOCK'}`);
|
|
598
604
|
} catch (error) {
|
|
599
605
|
if (this.logWarn) this.emit('warn', `${zoneName}, Set lock physical controls error: ${error}`);
|
|
@@ -605,6 +611,8 @@ class DeviceAtw extends EventEmitter {
|
|
|
605
611
|
return value;
|
|
606
612
|
})
|
|
607
613
|
.onSet(async (value) => {
|
|
614
|
+
if (this.account.type === 'melcloudhome') return;
|
|
615
|
+
|
|
608
616
|
try {
|
|
609
617
|
value = [false, true][value];
|
|
610
618
|
this.accessory.useFahrenheit = value;
|
|
@@ -728,7 +736,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
728
736
|
break;
|
|
729
737
|
};
|
|
730
738
|
|
|
731
|
-
await this.melCloudAtw.send(deviceData);
|
|
739
|
+
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData);
|
|
732
740
|
if (this.logInfo) this.emit('info', `${zoneName}, Set operation mode: ${operationModeText}`);
|
|
733
741
|
} catch (error) {
|
|
734
742
|
if (this.logWarn) this.emit('warn', `${zoneName}, Set operation mode error: ${error}`);
|
|
@@ -775,7 +783,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
775
783
|
break;
|
|
776
784
|
};
|
|
777
785
|
|
|
778
|
-
const set = i > 0 ? await this.melCloudAtw.send(deviceData) : false;
|
|
786
|
+
const set = i > 0 ? await this.melCloudAtw.send(this.accountType, this.displayType, deviceData) : false;
|
|
779
787
|
const info = this.logInfo || i === 0 ? false : this.emit('info', `${zoneName}, Set temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
780
788
|
} catch (error) {
|
|
781
789
|
if (this.logWarn) this.emit('warn', `${zoneName}, Set temperature error: ${error}`);
|
|
@@ -787,6 +795,8 @@ class DeviceAtw extends EventEmitter {
|
|
|
787
795
|
return value;
|
|
788
796
|
})
|
|
789
797
|
.onSet(async (value) => {
|
|
798
|
+
if (this.account.type === 'melcloudhome') return;
|
|
799
|
+
|
|
790
800
|
try {
|
|
791
801
|
value = [false, true][value];
|
|
792
802
|
this.accessory.useFahrenheit = value;
|
|
@@ -1094,7 +1104,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1094
1104
|
break;
|
|
1095
1105
|
};
|
|
1096
1106
|
|
|
1097
|
-
await this.melCloudAtw.send(deviceData);
|
|
1107
|
+
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData);
|
|
1098
1108
|
if (this.logInfo) this.emit('info', `${state ? 'Set:' : 'Unset:'} ${name}`);
|
|
1099
1109
|
} catch (error) {
|
|
1100
1110
|
if (this.logWarn) this.emit('warn', `Set preset error: ${error}`);
|
|
@@ -1262,7 +1272,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1262
1272
|
break;
|
|
1263
1273
|
};
|
|
1264
1274
|
|
|
1265
|
-
await this.melCloudAtw.send(deviceData);
|
|
1275
|
+
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData);
|
|
1266
1276
|
if (this.logInfo) this.emit('info', `${state ? `Set: ${name}` : `Unset: ${name}, Set: ${button.previousValue}`}`);
|
|
1267
1277
|
} catch (error) {
|
|
1268
1278
|
if (this.logWarn) this.emit('warn', `Set button error: ${error}`);
|
|
@@ -1284,7 +1294,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1284
1294
|
async start() {
|
|
1285
1295
|
try {
|
|
1286
1296
|
//melcloud device
|
|
1287
|
-
this.melCloudAtw = new MelCloudAtw(this.device, this.
|
|
1297
|
+
this.melCloudAtw = new MelCloudAtw(this.account, this.device, this.devicesFile, this.defaultTempsFile)
|
|
1288
1298
|
.on('deviceInfo', (manufacturer, modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion, hasHotWaterTank, hasZone2) => {
|
|
1289
1299
|
if (this.logDeviceInfo && this.displayDeviceInfo) {
|
|
1290
1300
|
this.emit('devInfo', `---- ${this.deviceTypeText}: ${this.deviceName} ----`);
|
|
@@ -1305,10 +1315,10 @@ class DeviceAtw extends EventEmitter {
|
|
|
1305
1315
|
//accessory info
|
|
1306
1316
|
this.manufacturer = manufacturer;
|
|
1307
1317
|
this.model = modelIndoor ? modelIndoor : modelOutdoor ? modelOutdoor : `${this.deviceTypeText} ${this.deviceId}`;
|
|
1308
|
-
this.serialNumber = serialNumber;
|
|
1309
|
-
this.firmwareRevision = firmwareAppVersion;
|
|
1318
|
+
this.serialNumber = serialNumber.toString();
|
|
1319
|
+
this.firmwareRevision = firmwareAppVersion.toString();
|
|
1310
1320
|
|
|
1311
|
-
this.informationService?.setCharacteristic(Characteristic.FirmwareRevision, firmwareAppVersion);
|
|
1321
|
+
this.informationService?.setCharacteristic(Characteristic.FirmwareRevision, this.firmwareAppVersion);
|
|
1312
1322
|
})
|
|
1313
1323
|
.on('deviceState', async (deviceData) => {
|
|
1314
1324
|
this.deviceData = deviceData;
|
|
@@ -1435,7 +1445,7 @@ class DeviceAtw extends EventEmitter {
|
|
|
1435
1445
|
let temperatureSetPropsMaxValue = 100;
|
|
1436
1446
|
|
|
1437
1447
|
for (let i = 0; i < zonesCount; i++) {
|
|
1438
|
-
switch (this.
|
|
1448
|
+
switch (this.displayType) {
|
|
1439
1449
|
case 1: //Heater Cooler
|
|
1440
1450
|
switch (i) {
|
|
1441
1451
|
case caseHeatPump: //Heat Pump Operation Mode - IDLE, HOT WATER, HEATING ZONES, COOLING, HOT WATER STORAGE, FREEZE STAT, LEGIONELLA, HEATING ECO, MODE 1, MODE 2, MODE 3, HEATING UP /// Unit Status - HEAT, COOL
|
package/src/deviceerv.js
CHANGED
|
@@ -6,7 +6,7 @@ import { TemperatureDisplayUnits, Ventilation } from './constants.js';
|
|
|
6
6
|
let Accessory, Characteristic, Service, Categories, AccessoryUUID;
|
|
7
7
|
|
|
8
8
|
class DeviceErv extends EventEmitter {
|
|
9
|
-
constructor(api, account, device, contextKey, devicesFile, useFahrenheit, restFul, mqtt) {
|
|
9
|
+
constructor(api, account, device, contextKey, devicesFile, defaultTempsFile, useFahrenheit, restFul, mqtt) {
|
|
10
10
|
super();
|
|
11
11
|
|
|
12
12
|
Accessory = api.platformAccessory;
|
|
@@ -16,23 +16,27 @@ class DeviceErv extends EventEmitter {
|
|
|
16
16
|
AccessoryUUID = api.hap.uuid;
|
|
17
17
|
|
|
18
18
|
//account config
|
|
19
|
+
this.account = account;
|
|
20
|
+
this.accountType = account.type;
|
|
21
|
+
this.accountName = account.name;
|
|
22
|
+
this.logDeviceInfo = account.log?.deviceInfo || false;
|
|
23
|
+
this.logInfo = account.log?.info || false;
|
|
24
|
+
this.logWarn = account.log?.warn || false;
|
|
25
|
+
this.logDebug = account.log?.debug || false;
|
|
26
|
+
|
|
27
|
+
//device config
|
|
19
28
|
this.device = device;
|
|
20
|
-
this.
|
|
29
|
+
this.displayType = device.displayType;
|
|
21
30
|
this.temperatureSensor = device.temperatureSensor || false;
|
|
22
31
|
this.temperatureSensorOutdoor = device.temperatureSensorOutdoor || false;
|
|
23
32
|
this.temperatureSensorSupply = device.temperatureSensorSupply || false;
|
|
24
33
|
this.presets = (device.presets || []).filter(preset => (preset.displayType ?? 0) > 0);
|
|
25
34
|
this.buttons = (device.buttonsSensors || []).filter(button => (button.displayType ?? 0) > 0);
|
|
26
|
-
this.logDeviceInfo = account.log?.deviceInfo || false;
|
|
27
|
-
this.logInfo = account.log?.info || false;
|
|
28
|
-
this.logWarn = account.log?.warn || false;
|
|
29
|
-
this.logDebug = account.log?.debug || false;
|
|
30
|
-
this.contextKey = contextKey;
|
|
31
|
-
this.accountName = account.name;
|
|
32
35
|
this.deviceId = device.id;
|
|
33
36
|
this.deviceName = device.name;
|
|
34
37
|
this.deviceTypeText = device.typeString;
|
|
35
38
|
this.devicesFile = devicesFile;
|
|
39
|
+
this.defaultTempsFile = defaultTempsFile;
|
|
36
40
|
this.displayDeviceInfo = true;
|
|
37
41
|
|
|
38
42
|
//external integrations
|
|
@@ -152,57 +156,57 @@ class DeviceErv extends EventEmitter {
|
|
|
152
156
|
case 'Power':
|
|
153
157
|
deviceData.Device[key] = value;
|
|
154
158
|
deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.Power;
|
|
155
|
-
set = await this.melCloudErv.send(
|
|
159
|
+
set = await this.melCloudErv.send(this.accountType, this.displayType, deviceData);
|
|
156
160
|
break;
|
|
157
161
|
case 'OperationMode':
|
|
158
162
|
deviceData.Device[key] = value;
|
|
159
163
|
deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.OperationMode;
|
|
160
|
-
set = await this.melCloudErv.send(
|
|
164
|
+
set = await this.melCloudErv.send(this.accountType, this.displayType, deviceData);
|
|
161
165
|
break;
|
|
162
166
|
case 'VentilationMode':
|
|
163
167
|
deviceData.Device[key] = value;
|
|
164
168
|
deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.VentilationMode;
|
|
165
|
-
set = await this.melCloudErv.send(
|
|
169
|
+
set = await this.melCloudErv.send(this.accountType, this.displayType, deviceData);
|
|
166
170
|
break;
|
|
167
171
|
case 'SetTemperature':
|
|
168
172
|
deviceData.Device[key] = value;
|
|
169
173
|
deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.SetTemperature;
|
|
170
|
-
set = await this.melCloudErv.send(
|
|
174
|
+
set = await this.melCloudErv.send(this.accountType, this.displayType, deviceData);
|
|
171
175
|
break;
|
|
172
176
|
case 'DefaultCoolingSetTemperature':
|
|
173
177
|
deviceData.Device[key] = value;
|
|
174
178
|
deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.SetTemperature;
|
|
175
|
-
set = await this.melCloudErv.send(
|
|
179
|
+
set = await this.melCloudErv.send(this.accountType, this.displayType, deviceData);
|
|
176
180
|
break;
|
|
177
181
|
case 'DefaultHeatingSetTemperature':
|
|
178
182
|
deviceData.Device[key] = value;
|
|
179
183
|
deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.SetTemperature;
|
|
180
|
-
set = await this.melCloudErv.send(
|
|
184
|
+
set = await this.melCloudErv.send(this.accountType, this.displayType, deviceData);
|
|
181
185
|
break;
|
|
182
186
|
case 'NightPurgeMode':
|
|
183
187
|
deviceData.Device[key] = value;
|
|
184
188
|
deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.NightPurgeMode;
|
|
185
|
-
set = await this.melCloudErv.send(
|
|
189
|
+
set = await this.melCloudErv.send(this.accountType, this.displayType, deviceData);
|
|
186
190
|
break;
|
|
187
191
|
case 'SetFanSpeed':
|
|
188
192
|
deviceData.Device[key] = value;
|
|
189
193
|
deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.SetFanSpeed;
|
|
190
|
-
set = await this.melCloudErv.send(
|
|
194
|
+
set = await this.melCloudErv.send(this.accountType, this.displayType, deviceData);
|
|
191
195
|
break;
|
|
192
196
|
case 'HideRoomTemperature':
|
|
193
197
|
deviceData[key] = value;
|
|
194
198
|
deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.Prohibit;
|
|
195
|
-
set = await this.melCloudErv.send(
|
|
199
|
+
set = await this.melCloudErv.send(this.accountType, this.displayType, deviceData);
|
|
196
200
|
break;
|
|
197
201
|
case 'HideSupplyTemperature':
|
|
198
202
|
deviceData[key] = value;
|
|
199
203
|
deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.Prohibit;
|
|
200
|
-
set = await this.melCloudErv.send(
|
|
204
|
+
set = await this.melCloudErv.send(this.accountType, this.displayType, deviceData);
|
|
201
205
|
break;
|
|
202
206
|
case 'HideOutdoorTemperature':
|
|
203
207
|
deviceData[key] = value;
|
|
204
208
|
deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.Prohibit;
|
|
205
|
-
set = await this.melCloudErv.send(
|
|
209
|
+
set = await this.melCloudErv.send(this.accountType, this.displayType, deviceData);
|
|
206
210
|
break;
|
|
207
211
|
default:
|
|
208
212
|
this.emit('warn', `${integration}, received key: ${key}, value: ${value}`);
|
|
@@ -263,7 +267,7 @@ class DeviceErv extends EventEmitter {
|
|
|
263
267
|
|
|
264
268
|
//services
|
|
265
269
|
const serviceName = `${deviceTypeText} ${accessoryName}`;
|
|
266
|
-
switch (this.
|
|
270
|
+
switch (this.displayType) {
|
|
267
271
|
case 1: //Heater Cooler
|
|
268
272
|
if (this.logDebug) this.emit('debug', `Prepare heather/cooler service`);
|
|
269
273
|
this.melCloudService = new Service.HeaterCooler(serviceName, `HeaterCooler ${deviceId}`);
|
|
@@ -277,7 +281,7 @@ class DeviceErv extends EventEmitter {
|
|
|
277
281
|
try {
|
|
278
282
|
deviceData.Device.Power = [false, true][state];
|
|
279
283
|
deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.Power;
|
|
280
|
-
await this.melCloudErv.send(
|
|
284
|
+
await this.melCloudErv.send(this.accountType, this.displayType, deviceData);
|
|
281
285
|
if (this.logInfo) this.emit('info', `Set power: ${state ? 'ON' : 'OFF'}`);
|
|
282
286
|
} catch (error) {
|
|
283
287
|
if (this.logWarn) this.emit('warn', `Set power error: ${error}`);
|
|
@@ -313,7 +317,7 @@ class DeviceErv extends EventEmitter {
|
|
|
313
317
|
};
|
|
314
318
|
|
|
315
319
|
deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.VentilationMode;
|
|
316
|
-
await this.melCloudErv.send(
|
|
320
|
+
await this.melCloudErv.send(this.accountType, this.displayType, deviceData);
|
|
317
321
|
const operationModeText = Ventilation.VentilationMode[deviceData.Device.VentilationMode];
|
|
318
322
|
if (this.logInfo) this.emit('info', `Set operation mode: ${operationModeText}`);
|
|
319
323
|
} catch (error) {
|
|
@@ -357,7 +361,7 @@ class DeviceErv extends EventEmitter {
|
|
|
357
361
|
break;;
|
|
358
362
|
};
|
|
359
363
|
deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.SetFanSpeed;
|
|
360
|
-
await this.melCloudErv.send(
|
|
364
|
+
await this.melCloudErv.send(this.accountType, this.displayType, deviceData);
|
|
361
365
|
if (this.logInfo) this.emit('info', `Set fan speed mode: ${Ventilation.FanSpeed[fanSpeedModeText]}`);
|
|
362
366
|
} catch (error) {
|
|
363
367
|
if (this.logWarn) this.emit('warn', `Set fan speed mode error: ${error}`);
|
|
@@ -379,7 +383,7 @@ class DeviceErv extends EventEmitter {
|
|
|
379
383
|
try {
|
|
380
384
|
deviceData.Device.DefaultCoolingSetTemperature = value;
|
|
381
385
|
deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.SetTemperature;
|
|
382
|
-
await this.melCloudErv.send(
|
|
386
|
+
await this.melCloudErv.send(this.accountType, this.displayType, deviceData);
|
|
383
387
|
if (this.logInfo) this.emit('info', `Set cooling threshold temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
384
388
|
} catch (error) {
|
|
385
389
|
if (this.logWarn) this.emit('warn', `Set cooling threshold temperature error: ${error}`);
|
|
@@ -402,7 +406,7 @@ class DeviceErv extends EventEmitter {
|
|
|
402
406
|
try {
|
|
403
407
|
deviceData.Device.DefaultHeatingSetTemperature = value;
|
|
404
408
|
deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.SetTemperature;
|
|
405
|
-
await this.melCloudErv.send(
|
|
409
|
+
await this.melCloudErv.send(this.accountType, this.displayType, deviceData);
|
|
406
410
|
if (this.logInfo) this.emit('info', `Set heating threshold temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
407
411
|
} catch (error) {
|
|
408
412
|
if (this.logWarn) this.emit('warn', `Set heating threshold temperature error: ${error}`);
|
|
@@ -420,7 +424,7 @@ class DeviceErv extends EventEmitter {
|
|
|
420
424
|
// value = value ? true : false;
|
|
421
425
|
// deviceData.Device = deviceData.Device;
|
|
422
426
|
// deviceData.Device.EffectiveFlags = CONSTANTS.Ventilation.EffectiveFlags.Prohibit;
|
|
423
|
-
// await this.melCloudErv.send(
|
|
427
|
+
// await this.melCloudErv.send(this.accountType, this.displayType, deviceData);
|
|
424
428
|
// if (this.logInfo) this.emit('info', `Set local physical controls: ${value ? 'LOCK' : 'UNLOCK'}`);
|
|
425
429
|
// } catch (error) {
|
|
426
430
|
// if (this.logWarn) this.emit('warn', `Set lock physical controls error: ${error}`);
|
|
@@ -432,6 +436,8 @@ class DeviceErv extends EventEmitter {
|
|
|
432
436
|
return value;
|
|
433
437
|
})
|
|
434
438
|
.onSet(async (value) => {
|
|
439
|
+
if (this.account.type === 'melcloudhome') return;
|
|
440
|
+
|
|
435
441
|
try {
|
|
436
442
|
value = [false, true][value];
|
|
437
443
|
this.accessory.useFahrenheit = value;
|
|
@@ -486,7 +492,7 @@ class DeviceErv extends EventEmitter {
|
|
|
486
492
|
break;
|
|
487
493
|
};
|
|
488
494
|
|
|
489
|
-
await this.melCloudErv.send(
|
|
495
|
+
await this.melCloudErv.send(this.accountType, this.displayType, deviceData);
|
|
490
496
|
const operationModeText = Ventilation.VentilationMode[deviceData.Device.VentilationMode];
|
|
491
497
|
if (this.logInfo) this.emit('info', `Set operation mode: ${operationModeText}`);
|
|
492
498
|
} catch (error) {
|
|
@@ -512,7 +518,7 @@ class DeviceErv extends EventEmitter {
|
|
|
512
518
|
try {
|
|
513
519
|
deviceData.Device.SetTemperature = value;
|
|
514
520
|
deviceData.Device.EffectiveFlags = Ventilation.EffectiveFlags.SetTemperature;
|
|
515
|
-
await this.melCloudErv.send(
|
|
521
|
+
await this.melCloudErv.send(this.accountType, this.displayType, deviceData);
|
|
516
522
|
if (this.logInfo) this.emit('info', `Set temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
517
523
|
} catch (error) {
|
|
518
524
|
if (this.logWarn) this.emit('warn', `Set temperature error: ${error}`);
|
|
@@ -524,6 +530,8 @@ class DeviceErv extends EventEmitter {
|
|
|
524
530
|
return value;
|
|
525
531
|
})
|
|
526
532
|
.onSet(async (value) => {
|
|
533
|
+
if (this.account.type === 'melcloudhome') return;
|
|
534
|
+
|
|
527
535
|
try {
|
|
528
536
|
value = [false, true][value];
|
|
529
537
|
this.accessory.useFahrenheit = value;
|
|
@@ -704,7 +712,7 @@ class DeviceErv extends EventEmitter {
|
|
|
704
712
|
break;
|
|
705
713
|
};
|
|
706
714
|
|
|
707
|
-
await this.melCloudErv.send(
|
|
715
|
+
await this.melCloudErv.send(this.accountType, this.displayType, deviceData);
|
|
708
716
|
if (this.logInfo) this.emit('info', `${state ? 'Set:' : 'Unset:'} ${name}`);
|
|
709
717
|
} catch (error) {
|
|
710
718
|
if (this.logWarn) this.emit('warn', `Set preset error: ${error}`);
|
|
@@ -818,7 +826,7 @@ class DeviceErv extends EventEmitter {
|
|
|
818
826
|
break;
|
|
819
827
|
};
|
|
820
828
|
|
|
821
|
-
await this.melCloudErv.send(
|
|
829
|
+
await this.melCloudErv.send(this.accountType, this.displayType, deviceData);
|
|
822
830
|
if (this.logInfo) this.emit('info', `${state ? `Set: ${buttonName}` : `Unset: ${buttonName}, Set: ${button.previousValue}`}`);
|
|
823
831
|
} catch (error) {
|
|
824
832
|
if (this.logWarn) this.emit('warn', `Set button error: ${error}`);
|
|
@@ -839,7 +847,7 @@ class DeviceErv extends EventEmitter {
|
|
|
839
847
|
async start() {
|
|
840
848
|
try {
|
|
841
849
|
//melcloud device
|
|
842
|
-
this.melCloudErv = new MelCloudErv(this.device, this.
|
|
850
|
+
this.melCloudErv = new MelCloudErv(this.account, this.device, this.devicesFile, this.defaultTempsFile)
|
|
843
851
|
.on('deviceInfo', (manufacturer, modelIndoor, modelOutdoor, serialNumber, firmwareAppVersion) => {
|
|
844
852
|
if (this.logDeviceInfo && this.displayDeviceInfo) {
|
|
845
853
|
this.emit('devInfo', `---- ${this.deviceTypeText}: ${this.deviceName} ----`);
|
|
@@ -856,10 +864,10 @@ class DeviceErv extends EventEmitter {
|
|
|
856
864
|
//accessory info
|
|
857
865
|
this.manufacturer = manufacturer;
|
|
858
866
|
this.model = modelIndoor ? modelIndoor : modelOutdoor ? modelOutdoor : `${this.deviceTypeText} ${this.deviceId}`;
|
|
859
|
-
this.serialNumber = serialNumber;
|
|
860
|
-
this.firmwareRevision = firmwareAppVersion;
|
|
867
|
+
this.serialNumber = serialNumber.toString();
|
|
868
|
+
this.firmwareRevision = firmwareAppVersion.toString();
|
|
861
869
|
|
|
862
|
-
this.informationService?.setCharacteristic(Characteristic.FirmwareRevision, firmwareAppVersion);
|
|
870
|
+
this.informationService?.setCharacteristic(Characteristic.FirmwareRevision, this.firmwareAppVersion);
|
|
863
871
|
})
|
|
864
872
|
.on('deviceState', async (deviceData) => {
|
|
865
873
|
this.deviceData = deviceData;
|
|
@@ -956,7 +964,7 @@ class DeviceErv extends EventEmitter {
|
|
|
956
964
|
};
|
|
957
965
|
|
|
958
966
|
//ventilation mode - 0, HEAT, 2, COOL, 4, 5, 6, FAN, AUTO
|
|
959
|
-
switch (this.
|
|
967
|
+
switch (this.displayType) {
|
|
960
968
|
case 1: //Heater Cooler
|
|
961
969
|
switch (ventilationMode) {
|
|
962
970
|
case 0: //LOSSNAY
|