homebridge-melcloud-control 4.2.4 → 4.2.5-beta.2
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/package.json +1 -1
- package/src/deviceata.js +23 -23
- package/src/deviceatw.js +20 -20
- package/src/deviceerv.js +20 -38
- package/src/melcloud.js +1 -1
- package/src/melcloudata.js +13 -11
- package/src/melcloudatw.js +11 -9
- package/src/melclouderv.js +11 -9
- package/src/melcloudhome.js +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.2.
|
|
4
|
+
"version": "4.2.5-beta.2",
|
|
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
|
@@ -56,7 +56,7 @@ class DeviceAta extends EventEmitter {
|
|
|
56
56
|
this.restFulConnected = false;
|
|
57
57
|
this.mqtt = account.mqtt ?? {};
|
|
58
58
|
this.mqttConnected = false;
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
const serviceType = [null, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor];
|
|
61
61
|
const characteristicType = [null, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState];
|
|
62
62
|
|
|
@@ -349,8 +349,9 @@ class DeviceAta extends EventEmitter {
|
|
|
349
349
|
.onSet(async (state) => {
|
|
350
350
|
try {
|
|
351
351
|
deviceData.Device.Power = state ? true : false;
|
|
352
|
-
|
|
352
|
+
|
|
353
353
|
if (this.logInfo) this.emit('info', `Set power: ${state ? 'On' : 'Off'}`);
|
|
354
|
+
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.Power);
|
|
354
355
|
} catch (error) {
|
|
355
356
|
if (this.logWarn) this.emit('warn', `Set power error: ${error}`);
|
|
356
357
|
};
|
|
@@ -387,8 +388,8 @@ class DeviceAta extends EventEmitter {
|
|
|
387
388
|
break;
|
|
388
389
|
};
|
|
389
390
|
|
|
390
|
-
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.OperationMode);
|
|
391
391
|
if (this.logInfo) this.emit('info', `Set operation mode: ${AirConditioner.OperationModeMapEnumToString[value]}`);
|
|
392
|
+
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.OperationMode);
|
|
392
393
|
} catch (error) {
|
|
393
394
|
if (this.logWarn) this.emit('warn', `Set operation mode error: ${error}`);
|
|
394
395
|
};
|
|
@@ -427,9 +428,9 @@ class DeviceAta extends EventEmitter {
|
|
|
427
428
|
break;
|
|
428
429
|
};
|
|
429
430
|
|
|
430
|
-
deviceData.Device[fanKey] = value
|
|
431
|
-
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.SetFanSpeed);
|
|
431
|
+
deviceData.Device[fanKey] = value;
|
|
432
432
|
if (this.logInfo) this.emit('info', `Set fan speed mode: ${AirConditioner.FanSpeedMapEnumToString[value]}`);
|
|
433
|
+
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.SetFanSpeed);
|
|
433
434
|
} catch (error) {
|
|
434
435
|
if (this.logWarn) this.emit('warn', `Set fan speed mode error: ${error}`);
|
|
435
436
|
};
|
|
@@ -446,8 +447,8 @@ class DeviceAta extends EventEmitter {
|
|
|
446
447
|
try {
|
|
447
448
|
deviceData.Device.VaneHorizontalDirection = value ? 12 : 0;
|
|
448
449
|
deviceData.Device.VaneVerticalDirection = value ? 7 : 0;
|
|
449
|
-
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.VaneVerticalVaneHorizontal);
|
|
450
450
|
if (this.logInfo) this.emit('info', `Set air direction mode: ${AirConditioner.AirDirectionMapEnumToString[value]}`);
|
|
451
|
+
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.VaneVerticalVaneHorizontal);
|
|
451
452
|
} catch (error) {
|
|
452
453
|
if (this.logWarn) this.emit('warn', `Set vane swing mode error: ${error}`);
|
|
453
454
|
};
|
|
@@ -467,8 +468,8 @@ class DeviceAta extends EventEmitter {
|
|
|
467
468
|
try {
|
|
468
469
|
const tempKey = this.accessory.operationMode === 8 ? 'DefaultCoolingSetTemperature' : 'SetTemperature';
|
|
469
470
|
deviceData.Device[tempKey] = value;
|
|
470
|
-
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.SetTemperature);
|
|
471
471
|
if (this.logInfo) this.emit('info', `Set cooling threshold temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
472
|
+
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.SetTemperature);
|
|
472
473
|
} catch (error) {
|
|
473
474
|
if (this.logWarn) this.emit('warn', `Set cooling threshold temperature error: ${error}`);
|
|
474
475
|
};
|
|
@@ -488,8 +489,8 @@ class DeviceAta extends EventEmitter {
|
|
|
488
489
|
try {
|
|
489
490
|
const tempKey = this.accessory.operationMode === 8 ? 'DefaultHeatingSetTemperature' : 'SetTemperature';
|
|
490
491
|
deviceData.Device[tempKey] = value;
|
|
491
|
-
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.SetTemperature);
|
|
492
492
|
if (this.logInfo) this.emit('info', `Set heating threshold temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
493
|
+
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.SetTemperature);
|
|
493
494
|
} catch (error) {
|
|
494
495
|
if (this.logWarn) this.emit('warn', `Set heating threshold temperature error: ${error}`);
|
|
495
496
|
};
|
|
@@ -508,8 +509,8 @@ class DeviceAta extends EventEmitter {
|
|
|
508
509
|
deviceData.Device.ProhibitSetTemperature = value;
|
|
509
510
|
deviceData.Device.ProhibitOperationMode = value;
|
|
510
511
|
deviceData.Device.ProhibitPower = value;
|
|
512
|
+
if (this.logInfo) this.emit('info', `Set local physical controls: ${value ? 'Lock' : 'Unlock'}`);
|
|
511
513
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.Prohibit);
|
|
512
|
-
if (this.logInfo) this.emit('info', `Set local physical controls: ${value ? 'LOCK' : 'UNLOCK'}`);
|
|
513
514
|
} catch (error) {
|
|
514
515
|
if (this.logWarn) this.emit('warn', `Set lock physical controls error: ${error}`);
|
|
515
516
|
};
|
|
@@ -525,8 +526,8 @@ class DeviceAta extends EventEmitter {
|
|
|
525
526
|
try {
|
|
526
527
|
value = [false, true][value];
|
|
527
528
|
this.accessory.useFahrenheit = value;
|
|
528
|
-
this.emit('melCloud', 'UseFahrenheit', value);
|
|
529
529
|
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
530
|
+
this.emit('melCloud', 'UseFahrenheit', value);
|
|
530
531
|
} catch (error) {
|
|
531
532
|
if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
532
533
|
};
|
|
@@ -579,9 +580,8 @@ class DeviceAta extends EventEmitter {
|
|
|
579
580
|
};
|
|
580
581
|
|
|
581
582
|
deviceData.Device.OperationMode = value;
|
|
583
|
+
if (this.logInfo) this.emit('info', `Set operation mode: ${AirConditioner.OperationModeMapEnumToString[value]}`);
|
|
582
584
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, flag);
|
|
583
|
-
const operationModeText = AirConditioner.OperationModeMapEnumToString[value];
|
|
584
|
-
if (this.logInfo) this.emit('info', `Set operation mode: ${operationModeText}`);
|
|
585
585
|
} catch (error) {
|
|
586
586
|
if (this.logWarn) this.emit('warn', `Set operation mode error: ${error}`);
|
|
587
587
|
};
|
|
@@ -604,8 +604,8 @@ class DeviceAta extends EventEmitter {
|
|
|
604
604
|
.onSet(async (value) => {
|
|
605
605
|
try {
|
|
606
606
|
deviceData.Device.SetTemperature = value;
|
|
607
|
-
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.SetTemperature);
|
|
608
607
|
if (this.logInfo) this.emit('info', `Set temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
608
|
+
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.SetTemperature);
|
|
609
609
|
} catch (error) {
|
|
610
610
|
if (this.logWarn) this.emit('warn', `Set temperature error: ${error}`);
|
|
611
611
|
};
|
|
@@ -619,10 +619,10 @@ class DeviceAta extends EventEmitter {
|
|
|
619
619
|
if (this.account.type === 'melcloudhome') return;
|
|
620
620
|
|
|
621
621
|
try {
|
|
622
|
-
value =
|
|
622
|
+
value = value ? true : false;
|
|
623
623
|
this.accessory.useFahrenheit = value;
|
|
624
|
-
this.emit('melCloud', 'UseFahrenheit', value);
|
|
625
624
|
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
625
|
+
this.emit('melCloud', 'UseFahrenheit', value);
|
|
626
626
|
} catch (error) {
|
|
627
627
|
if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
628
628
|
};
|
|
@@ -725,8 +725,8 @@ class DeviceAta extends EventEmitter {
|
|
|
725
725
|
.onSet(async (state) => {
|
|
726
726
|
try {
|
|
727
727
|
deviceData.FrostProtection.Enabled = state;
|
|
728
|
+
if (this.logInfo) this.emit('info', `Frost protection: ${state ? 'Enable' : 'Disable'}`);
|
|
728
729
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'frostprotection');
|
|
729
|
-
if (this.logInfo) this.emit('info', `Frost protection: ${state ? 'Enabled' : 'Disabled'}`);
|
|
730
730
|
} catch (error) {
|
|
731
731
|
if (this.logWarn) this.emit('warn', `Set frost protection error: ${error}`);
|
|
732
732
|
};
|
|
@@ -772,8 +772,8 @@ class DeviceAta extends EventEmitter {
|
|
|
772
772
|
.onSet(async (state) => {
|
|
773
773
|
try {
|
|
774
774
|
deviceData.OverheatProtection.Enabled = state;
|
|
775
|
+
if (this.logInfo) this.emit('info', `Overheat protection: ${state ? 'Enable' : 'Disable'}`);
|
|
775
776
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'overheatprotection');
|
|
776
|
-
if (this.logInfo) this.emit('info', `Overheat protection: ${state ? 'Enabled' : 'Disabled'}`);
|
|
777
777
|
} catch (error) {
|
|
778
778
|
if (this.logWarn) this.emit('warn', `Set overheat protection error: ${error}`);
|
|
779
779
|
};
|
|
@@ -818,8 +818,8 @@ class DeviceAta extends EventEmitter {
|
|
|
818
818
|
.onSet(async (state) => {
|
|
819
819
|
try {
|
|
820
820
|
deviceData.HolidayMode.Enabled = state;
|
|
821
|
+
if (this.logInfo) this.emit('info', `Holiday mode: ${state ? 'Enable' : 'Disable'}`);
|
|
821
822
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'holidaymode');
|
|
822
|
-
if (this.logInfo) this.emit('info', `Holiday mode: ${state ? 'Enabled' : 'Disabled'}`);
|
|
823
823
|
} catch (error) {
|
|
824
824
|
if (this.logWarn) this.emit('warn', `Set holiday mode error: ${error}`);
|
|
825
825
|
};
|
|
@@ -900,8 +900,8 @@ class DeviceAta extends EventEmitter {
|
|
|
900
900
|
break;
|
|
901
901
|
};
|
|
902
902
|
|
|
903
|
+
if (this.logInfo) this.emit('info', `Preset ${name}: ${state ? 'Set:' : 'Unset:'}`);
|
|
903
904
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.Presets);
|
|
904
|
-
if (this.logInfo) this.emit('info', `Preset ${name}: ${state ? 'Set:' : 'Unset:'} ${name}`);
|
|
905
905
|
} catch (error) {
|
|
906
906
|
if (this.logWarn) this.emit('warn', `Set preset error: ${error}`);
|
|
907
907
|
};
|
|
@@ -957,10 +957,10 @@ class DeviceAta extends EventEmitter {
|
|
|
957
957
|
.onSet(async (state) => {
|
|
958
958
|
try {
|
|
959
959
|
deviceData.ScheduleEnabled = state;
|
|
960
|
+
if (this.logInfo) this.emit('info', `Schedules: ${state ? 'Enable' : 'Disable'}`);
|
|
960
961
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'schedule');
|
|
961
|
-
if (this.logInfo) this.emit('info', `Schedule ${name}: ${state ? 'Enabled' : 'Disabled'}`);
|
|
962
962
|
} catch (error) {
|
|
963
|
-
if (this.logWarn) this.emit('warn', `Set
|
|
963
|
+
if (this.logWarn) this.emit('warn', `Set schedules error: ${error}`);
|
|
964
964
|
};
|
|
965
965
|
});
|
|
966
966
|
accessory.addService(this.scheduleControlService);
|
|
@@ -1026,8 +1026,8 @@ class DeviceAta extends EventEmitter {
|
|
|
1026
1026
|
.onSet(async (state) => {
|
|
1027
1027
|
try {
|
|
1028
1028
|
sceneData.Enabled = state;
|
|
1029
|
+
if (this.logInfo) this.emit('info', `Scene ${name}: ${state ? 'Enable' : 'Disable'}`);
|
|
1029
1030
|
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'scene', sceneData);
|
|
1030
|
-
if (this.logInfo) this.emit('info', `Scene ${name}: ${state ? 'Enabled' : 'Disabled'}`);
|
|
1031
1031
|
} catch (error) {
|
|
1032
1032
|
if (this.logWarn) this.emit('warn', `Set scene error: ${error}`);
|
|
1033
1033
|
};
|
|
@@ -1281,8 +1281,8 @@ class DeviceAta extends EventEmitter {
|
|
|
1281
1281
|
break;
|
|
1282
1282
|
};
|
|
1283
1283
|
|
|
1284
|
-
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, flag);
|
|
1285
1284
|
if (this.logInfo) this.emit('info', `${state ? `Set: ${name}` : `Unset: ${name}, Set: ${button.previousValue}`}`);
|
|
1285
|
+
await this.melCloudAta.send(this.accountType, this.displayType, deviceData, flag);
|
|
1286
1286
|
} catch (error) {
|
|
1287
1287
|
if (this.logWarn) this.emit('warn', `Set button error: ${error}`);
|
|
1288
1288
|
};
|
package/src/deviceatw.js
CHANGED
|
@@ -357,8 +357,8 @@ class DeviceAtw extends EventEmitter {
|
|
|
357
357
|
switch (i) {
|
|
358
358
|
case 0: //Heat Pump
|
|
359
359
|
deviceData.Device.Power = state ? true : false;
|
|
360
|
-
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, HeatPump.EffectiveFlags.Power);
|
|
361
360
|
if (this.logInfo) this.emit('info', `${zoneName}, Set power: ${state ? 'On' : 'Off'}`);
|
|
361
|
+
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, HeatPump.EffectiveFlags.Power);
|
|
362
362
|
break;
|
|
363
363
|
};
|
|
364
364
|
} catch (error) {
|
|
@@ -457,8 +457,8 @@ class DeviceAtw extends EventEmitter {
|
|
|
457
457
|
break;
|
|
458
458
|
};
|
|
459
459
|
|
|
460
|
-
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, flag);
|
|
461
460
|
if (this.logInfo) this.emit('info', `${zoneName}, Set operation mode: ${operationModeText}`);
|
|
461
|
+
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, flag);
|
|
462
462
|
} catch (error) {
|
|
463
463
|
if (this.logWarn) this.emit('warn', `${zoneName}, Set operation mode error: ${error}`);
|
|
464
464
|
};
|
|
@@ -531,8 +531,8 @@ class DeviceAtw extends EventEmitter {
|
|
|
531
531
|
break;
|
|
532
532
|
};
|
|
533
533
|
|
|
534
|
-
if (i > 0) await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, flag);
|
|
535
534
|
if (this.logInfo && i !== 0) this.emit('info', `${zoneName}, Set cooling threshold temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
535
|
+
if (i > 0) await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, flag);
|
|
536
536
|
} catch (error) {
|
|
537
537
|
if (this.logWarn) this.emit('warn', `${zoneName}, Set cooling threshold temperature error: ${error}`);
|
|
538
538
|
};
|
|
@@ -596,8 +596,8 @@ class DeviceAtw extends EventEmitter {
|
|
|
596
596
|
break;
|
|
597
597
|
};
|
|
598
598
|
|
|
599
|
-
if (i > 0) await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, flag);
|
|
600
599
|
if (this.logInfo && i !== 0) this.emit('info', `${zoneName}, Set heating threshold temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
600
|
+
if (i > 0) await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, flag);
|
|
601
601
|
} catch (error) {
|
|
602
602
|
if (this.logWarn) this.emit('warn', `${zoneName}, Set heating threshold temperature error: ${error}`);
|
|
603
603
|
};
|
|
@@ -634,8 +634,8 @@ class DeviceAtw extends EventEmitter {
|
|
|
634
634
|
break;
|
|
635
635
|
};
|
|
636
636
|
|
|
637
|
+
if (this.logInfo) this.emit('info', `${zoneName}, Set lock physical controls: ${value ? 'Lock' : 'Unlock'}`);
|
|
637
638
|
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData);
|
|
638
|
-
if (this.logInfo) this.emit('info', `${zoneName}, Set lock physical controls: ${value ? 'LOCK' : 'UNLOCK'}`);
|
|
639
639
|
} catch (error) {
|
|
640
640
|
if (this.logWarn) this.emit('warn', `${zoneName}, Set lock physical controls error: ${error}`);
|
|
641
641
|
};
|
|
@@ -651,8 +651,8 @@ class DeviceAtw extends EventEmitter {
|
|
|
651
651
|
try {
|
|
652
652
|
value = [false, true][value];
|
|
653
653
|
this.accessory.useFahrenheit = value;
|
|
654
|
-
this.emit('melCloud', 'UseFahrenheit', value);
|
|
655
654
|
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
655
|
+
this.emit('melCloud', 'UseFahrenheit', value);
|
|
656
656
|
} catch (error) {
|
|
657
657
|
if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
658
658
|
};
|
|
@@ -772,8 +772,8 @@ class DeviceAtw extends EventEmitter {
|
|
|
772
772
|
break;
|
|
773
773
|
};
|
|
774
774
|
|
|
775
|
-
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, flag);
|
|
776
775
|
if (this.logInfo) this.emit('info', `${zoneName}, Set operation mode: ${operationModeText}`);
|
|
776
|
+
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, flag);
|
|
777
777
|
} catch (error) {
|
|
778
778
|
if (this.logWarn) this.emit('warn', `${zoneName}, Set operation mode error: ${error}`);
|
|
779
779
|
};
|
|
@@ -820,8 +820,8 @@ class DeviceAtw extends EventEmitter {
|
|
|
820
820
|
break;
|
|
821
821
|
};
|
|
822
822
|
|
|
823
|
-
if (i > 0) await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, flag);
|
|
824
823
|
if (this.logInfo && i !== 0) this.emit('info', `${zoneName}, Set temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
824
|
+
if (i > 0) await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, flag);
|
|
825
825
|
} catch (error) {
|
|
826
826
|
if (this.logWarn) this.emit('warn', `${zoneName}, Set temperature error: ${error}`);
|
|
827
827
|
};
|
|
@@ -835,10 +835,10 @@ class DeviceAtw extends EventEmitter {
|
|
|
835
835
|
if (this.account.type === 'melcloudhome') return;
|
|
836
836
|
|
|
837
837
|
try {
|
|
838
|
-
value =
|
|
838
|
+
value = value ? true : false;
|
|
839
839
|
this.accessory.useFahrenheit = value;
|
|
840
|
-
this.emit('melCloud', 'UseFahrenheit', value);
|
|
841
840
|
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
841
|
+
this.emit('melCloud', 'UseFahrenheit', value);
|
|
842
842
|
} catch (error) {
|
|
843
843
|
if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
844
844
|
};
|
|
@@ -1137,8 +1137,8 @@ class DeviceAtw extends EventEmitter {
|
|
|
1137
1137
|
.onSet(async (state) => {
|
|
1138
1138
|
try {
|
|
1139
1139
|
deviceData.HolidayMode.Enabled = state;
|
|
1140
|
-
|
|
1141
|
-
|
|
1140
|
+
if (this.logInfo) this.emit('info', `Holiday mode: ${state ? 'Enable' : 'Disable'}`);
|
|
1141
|
+
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, 'holidaymode');
|
|
1142
1142
|
} catch (error) {
|
|
1143
1143
|
if (this.logWarn) this.emit('warn', `Set holiday mode error: ${error}`);
|
|
1144
1144
|
};
|
|
@@ -1219,8 +1219,8 @@ class DeviceAtw extends EventEmitter {
|
|
|
1219
1219
|
break;
|
|
1220
1220
|
};
|
|
1221
1221
|
|
|
1222
|
-
|
|
1223
|
-
|
|
1222
|
+
if (this.logInfo) this.emit('info', `Preset ${name}: ${state ? 'Set:' : 'Unset:'}`);
|
|
1223
|
+
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.Presets);
|
|
1224
1224
|
} catch (error) {
|
|
1225
1225
|
if (this.logWarn) this.emit('warn', `Set preset error: ${error}`);
|
|
1226
1226
|
};
|
|
@@ -1276,10 +1276,10 @@ class DeviceAtw extends EventEmitter {
|
|
|
1276
1276
|
.onSet(async (state) => {
|
|
1277
1277
|
try {
|
|
1278
1278
|
deviceData.ScheduleEnabled = state;
|
|
1279
|
-
|
|
1280
|
-
|
|
1279
|
+
if (this.logInfo) this.emit('info', `Schedules: ${state ? 'Enable' : 'Disable'}`);
|
|
1280
|
+
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, 'schedule');
|
|
1281
1281
|
} catch (error) {
|
|
1282
|
-
if (this.logWarn) this.emit('warn', `Set
|
|
1282
|
+
if (this.logWarn) this.emit('warn', `Set schedules error: ${error}`);
|
|
1283
1283
|
};
|
|
1284
1284
|
});
|
|
1285
1285
|
accessory.addService(this.scheduleControlService);
|
|
@@ -1345,8 +1345,8 @@ class DeviceAtw extends EventEmitter {
|
|
|
1345
1345
|
.onSet(async (state) => {
|
|
1346
1346
|
try {
|
|
1347
1347
|
sceneData.Enabled = state;
|
|
1348
|
-
|
|
1349
|
-
|
|
1348
|
+
if (this.logInfo) this.emit('info', `Scene ${name}: ${state ? 'Enable' : 'Disable'}`);
|
|
1349
|
+
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, 'scene', sceneData);
|
|
1350
1350
|
} catch (error) {
|
|
1351
1351
|
if (this.logWarn) this.emit('warn', `Set scene error: ${error}`);
|
|
1352
1352
|
};
|
|
@@ -1534,8 +1534,8 @@ class DeviceAtw extends EventEmitter {
|
|
|
1534
1534
|
break;
|
|
1535
1535
|
};
|
|
1536
1536
|
|
|
1537
|
-
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, flag);
|
|
1538
1537
|
if (this.logInfo) this.emit('info', `${state ? `Set: ${name}` : `Unset: ${name}, Set: ${button.previousValue}`}`);
|
|
1538
|
+
await this.melCloudAtw.send(this.accountType, this.displayType, deviceData, flag);
|
|
1539
1539
|
} catch (error) {
|
|
1540
1540
|
if (this.logWarn) this.emit('warn', `Set button error: ${error}`);
|
|
1541
1541
|
};
|
package/src/deviceerv.js
CHANGED
|
@@ -320,8 +320,8 @@ class DeviceErv extends EventEmitter {
|
|
|
320
320
|
.onSet(async (state) => {
|
|
321
321
|
try {
|
|
322
322
|
deviceData.Device.Power = state ? true : false;
|
|
323
|
-
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, Ventilation.EffectiveFlags.Power);
|
|
324
323
|
if (this.logInfo) this.emit('info', `Set power: ${state ? 'On' : 'Off'}`);
|
|
324
|
+
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, Ventilation.EffectiveFlags.Power);
|
|
325
325
|
} catch (error) {
|
|
326
326
|
if (this.logWarn) this.emit('warn', `Set power error: ${error}`);
|
|
327
327
|
};
|
|
@@ -355,9 +355,8 @@ class DeviceErv extends EventEmitter {
|
|
|
355
355
|
break;
|
|
356
356
|
};
|
|
357
357
|
|
|
358
|
+
if (this.logInfo) this.emit('info', `Set operation mode: ${Ventilation.VentilationModeMapEnumToString[deviceData.Device.VentilationMode]}`);
|
|
358
359
|
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, Ventilation.EffectiveFlags.VentilationMode);
|
|
359
|
-
const operationModeText = Ventilation.VentilationModeMapEnumToString[deviceData.Device.VentilationMode];
|
|
360
|
-
if (this.logInfo) this.emit('info', `Set operation mode: ${operationModeText}`);
|
|
361
360
|
} catch (error) {
|
|
362
361
|
if (this.logWarn) this.emit('warn', `Set operation mode error: ${error}`);
|
|
363
362
|
};
|
|
@@ -395,9 +394,9 @@ class DeviceErv extends EventEmitter {
|
|
|
395
394
|
break;;
|
|
396
395
|
};
|
|
397
396
|
|
|
398
|
-
deviceData.Device.SetFanSpeed = value
|
|
399
|
-
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, Ventilation.EffectiveFlags.SetFanSpeed);
|
|
397
|
+
deviceData.Device.SetFanSpeed = value;
|
|
400
398
|
if (this.logInfo) this.emit('info', `Set fan speed mode: ${Ventilation.FanSpeedMapEnumToString[value]}`);
|
|
399
|
+
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, Ventilation.EffectiveFlags.SetFanSpeed);
|
|
401
400
|
} catch (error) {
|
|
402
401
|
if (this.logWarn) this.emit('warn', `Set fan speed mode error: ${error}`);
|
|
403
402
|
};
|
|
@@ -418,8 +417,8 @@ class DeviceErv extends EventEmitter {
|
|
|
418
417
|
.onSet(async (value) => {
|
|
419
418
|
try {
|
|
420
419
|
deviceData.Device.DefaultCoolingSetTemperature = value;
|
|
421
|
-
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, Ventilation.EffectiveFlags.SetTemperature);
|
|
422
420
|
if (this.logInfo) this.emit('info', `Set cooling threshold temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
421
|
+
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, Ventilation.EffectiveFlags.SetTemperature);
|
|
423
422
|
} catch (error) {
|
|
424
423
|
if (this.logWarn) this.emit('warn', `Set cooling threshold temperature error: ${error}`);
|
|
425
424
|
};
|
|
@@ -440,29 +439,13 @@ class DeviceErv extends EventEmitter {
|
|
|
440
439
|
.onSet(async (value) => {
|
|
441
440
|
try {
|
|
442
441
|
deviceData.Device.DefaultHeatingSetTemperature = value;
|
|
443
|
-
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, Ventilation.EffectiveFlags.SetTemperature);
|
|
444
442
|
if (this.logInfo) this.emit('info', `Set heating threshold temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
443
|
+
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, Ventilation.EffectiveFlags.SetTemperature);
|
|
445
444
|
} catch (error) {
|
|
446
445
|
if (this.logWarn) this.emit('warn', `Set heating threshold temperature error: ${error}`);
|
|
447
446
|
};
|
|
448
447
|
});
|
|
449
448
|
};
|
|
450
|
-
//this.melCloudService.getCharacteristic(Characteristic.LockPhysicalControls)
|
|
451
|
-
// .onGet(async () => {
|
|
452
|
-
// const value = this.accessory.lockPhysicalControl;
|
|
453
|
-
// if (this.logInfo) this.emit('info', `Lock physical controls: ${value ? 'LOCKED' : 'UNLOCKED'}`);
|
|
454
|
-
// return value;
|
|
455
|
-
// })
|
|
456
|
-
// .onSet(async (value) => {
|
|
457
|
-
// try {
|
|
458
|
-
// value = value ? true : false;
|
|
459
|
-
// deviceData.Device = deviceData.Device;
|
|
460
|
-
// await this.melCloudErv.send(this.accountType, this.displayType, deviceData, Ventilation.EffectiveFlags.Prohibit);
|
|
461
|
-
// if (this.logInfo) this.emit('info', `Set local physical controls: ${value ? 'LOCK' : 'UNLOCK'}`);
|
|
462
|
-
// } catch (error) {
|
|
463
|
-
// if (this.logWarn) this.emit('warn', `Set lock physical controls error: ${error}`);
|
|
464
|
-
// };
|
|
465
|
-
// });
|
|
466
449
|
this.melCloudService.getCharacteristic(Characteristic.TemperatureDisplayUnits)
|
|
467
450
|
.onGet(async () => {
|
|
468
451
|
const value = this.accessory.useFahrenheit;
|
|
@@ -474,8 +457,8 @@ class DeviceErv extends EventEmitter {
|
|
|
474
457
|
try {
|
|
475
458
|
value = [false, true][value];
|
|
476
459
|
this.accessory.useFahrenheit = value;
|
|
477
|
-
this.emit('melCloud', 'UseFahrenheit', value);
|
|
478
460
|
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
461
|
+
this.emit('melCloud', 'UseFahrenheit', value);
|
|
479
462
|
} catch (error) {
|
|
480
463
|
if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
481
464
|
};
|
|
@@ -526,9 +509,8 @@ class DeviceErv extends EventEmitter {
|
|
|
526
509
|
break;
|
|
527
510
|
};
|
|
528
511
|
|
|
512
|
+
if (this.logInfo) this.emit('info', `Set operation mode: ${Ventilation.VentilationModeMapEnumToString[deviceData.Device.VentilationMode]}`);
|
|
529
513
|
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, flag);
|
|
530
|
-
const operationModeText = Ventilation.VentilationModeMapEnumToString[deviceData.Device.VentilationMode];
|
|
531
|
-
if (this.logInfo) this.emit('info', `Set operation mode: ${operationModeText}`);
|
|
532
514
|
} catch (error) {
|
|
533
515
|
if (this.logWarn) this.emit('warn', `Set operation mode error: ${error}`);
|
|
534
516
|
};
|
|
@@ -551,8 +533,8 @@ class DeviceErv extends EventEmitter {
|
|
|
551
533
|
.onSet(async (value) => {
|
|
552
534
|
try {
|
|
553
535
|
deviceData.Device.SetTemperature = value;
|
|
554
|
-
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, Ventilation.EffectiveFlags.SetTemperature);
|
|
555
536
|
if (this.logInfo) this.emit('info', `Set temperature: ${value}${this.accessory.temperatureUnit}`);
|
|
537
|
+
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, Ventilation.EffectiveFlags.SetTemperature);
|
|
556
538
|
} catch (error) {
|
|
557
539
|
if (this.logWarn) this.emit('warn', `Set temperature error: ${error}`);
|
|
558
540
|
};
|
|
@@ -568,8 +550,8 @@ class DeviceErv extends EventEmitter {
|
|
|
568
550
|
try {
|
|
569
551
|
value = [false, true][value];
|
|
570
552
|
this.accessory.useFahrenheit = value;
|
|
571
|
-
this.emit('melCloud', 'UseFahrenheit', value);
|
|
572
553
|
if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
|
|
554
|
+
this.emit('melCloud', 'UseFahrenheit', value);
|
|
573
555
|
} catch (error) {
|
|
574
556
|
if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
|
|
575
557
|
};
|
|
@@ -759,8 +741,8 @@ class DeviceErv extends EventEmitter {
|
|
|
759
741
|
.onSet(async (state) => {
|
|
760
742
|
try {
|
|
761
743
|
deviceData.HolidayMode.Enabled = state;
|
|
762
|
-
|
|
763
|
-
|
|
744
|
+
if (this.logInfo) this.emit('info', `Holiday mode: ${state ? 'Enable' : 'Disable'}`);
|
|
745
|
+
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, 'holidaymode');
|
|
764
746
|
} catch (error) {
|
|
765
747
|
if (this.logWarn) this.emit('warn', `Set holiday mode error: ${error}`);
|
|
766
748
|
};
|
|
@@ -841,8 +823,8 @@ class DeviceErv extends EventEmitter {
|
|
|
841
823
|
break;
|
|
842
824
|
};
|
|
843
825
|
|
|
844
|
-
|
|
845
|
-
|
|
826
|
+
if (this.logInfo) this.emit('info', `Preset ${name}: ${state ? 'Set:' : 'Unset:'}`);
|
|
827
|
+
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.Presets);
|
|
846
828
|
} catch (error) {
|
|
847
829
|
if (this.logWarn) this.emit('warn', `Set preset error: ${error}`);
|
|
848
830
|
};
|
|
@@ -898,10 +880,10 @@ class DeviceErv extends EventEmitter {
|
|
|
898
880
|
.onSet(async (state) => {
|
|
899
881
|
try {
|
|
900
882
|
deviceData.ScheduleEnabled = state;
|
|
901
|
-
|
|
902
|
-
|
|
883
|
+
if (this.logInfo) this.emit('info', `Schedules: ${state ? 'Enable' : 'Disable'}`);
|
|
884
|
+
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, 'schedule');
|
|
903
885
|
} catch (error) {
|
|
904
|
-
if (this.logWarn) this.emit('warn', `Set schedule
|
|
886
|
+
if (this.logWarn) this.emit('warn', `Set schedule serror: ${error}`);
|
|
905
887
|
};
|
|
906
888
|
});
|
|
907
889
|
accessory.addService(this.scheduleControlService);
|
|
@@ -967,8 +949,8 @@ class DeviceErv extends EventEmitter {
|
|
|
967
949
|
.onSet(async (state) => {
|
|
968
950
|
try {
|
|
969
951
|
sceneData.Enabled = state;
|
|
970
|
-
|
|
971
|
-
|
|
952
|
+
if (this.logInfo) this.emit('info', `Scene ${name}: ${state ? 'Enable' : 'Disable'}`);
|
|
953
|
+
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, 'scene', sceneData);
|
|
972
954
|
} catch (error) {
|
|
973
955
|
if (this.logWarn) this.emit('warn', `Set scene error: ${error}`);
|
|
974
956
|
};
|
|
@@ -1095,8 +1077,8 @@ class DeviceErv extends EventEmitter {
|
|
|
1095
1077
|
break;
|
|
1096
1078
|
};
|
|
1097
1079
|
|
|
1098
|
-
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, flag);
|
|
1099
1080
|
if (this.logInfo) this.emit('info', `${state ? `Set: ${buttonName}` : `Unset: ${buttonName}, Set: ${button.previousValue}`}`);
|
|
1081
|
+
await this.melCloudErv.send(this.accountType, this.displayType, deviceData, flag);
|
|
1100
1082
|
} catch (error) {
|
|
1101
1083
|
if (this.logWarn) this.emit('warn', `Set button error: ${error}`);
|
|
1102
1084
|
};
|
package/src/melcloud.js
CHANGED
|
@@ -101,7 +101,6 @@ class MelCloud extends EventEmitter {
|
|
|
101
101
|
// Zamiana ID na string
|
|
102
102
|
allDevices.forEach(device => {
|
|
103
103
|
device.DeviceID = String(device.DeviceID);
|
|
104
|
-
device.Headers = this.headers;
|
|
105
104
|
});
|
|
106
105
|
|
|
107
106
|
if (this.logDebug) this.emit('debug', `Found ${allDevices.length} devices in building: ${building.Name || 'Unnamed'}`);
|
|
@@ -117,6 +116,7 @@ class MelCloud extends EventEmitter {
|
|
|
117
116
|
devicesList.State = true;
|
|
118
117
|
devicesList.Info = `Found ${devicesCount} devices`;
|
|
119
118
|
devicesList.Devices = devices;
|
|
119
|
+
devicesList.Headers = this.headers;
|
|
120
120
|
|
|
121
121
|
await this.functions.saveData(this.devicesFile, devicesList);
|
|
122
122
|
if (this.logDebug) this.emit('debug', `${devicesCount} devices saved`);
|
package/src/melcloudata.js
CHANGED
|
@@ -23,6 +23,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
23
23
|
|
|
24
24
|
//set default values
|
|
25
25
|
this.deviceData = {};
|
|
26
|
+
this.headers = {};
|
|
26
27
|
|
|
27
28
|
//lock flag
|
|
28
29
|
this.locks = true;
|
|
@@ -52,6 +53,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
52
53
|
try {
|
|
53
54
|
//read device info from file
|
|
54
55
|
const devicesData = await this.functions.readData(this.devicesFile, true);
|
|
56
|
+
this.headers = devicesData.Headers;
|
|
55
57
|
const scenes = devicesData.Scenes ?? [];
|
|
56
58
|
const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
|
|
57
59
|
|
|
@@ -165,7 +167,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
165
167
|
method: 'POST',
|
|
166
168
|
baseURL: ApiUrls.BaseURL,
|
|
167
169
|
timeout: 10000,
|
|
168
|
-
headers:
|
|
170
|
+
headers: this.headers,
|
|
169
171
|
data: payload
|
|
170
172
|
});
|
|
171
173
|
this.updateData(deviceData);
|
|
@@ -193,7 +195,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
193
195
|
};
|
|
194
196
|
method = 'POST';
|
|
195
197
|
path = ApiUrlsHome.PostProtectionFrost;
|
|
196
|
-
|
|
198
|
+
this.headers.Referer = ApiUrlsHome.Referers.PostProtectionFrost.replace('deviceid', deviceData.DeviceID);
|
|
197
199
|
break;
|
|
198
200
|
case 'overheatprotection':
|
|
199
201
|
payload = {
|
|
@@ -204,7 +206,7 @@ class MelCloudAta extends EventEmitter {
|
|
|
204
206
|
};
|
|
205
207
|
method = 'POST';
|
|
206
208
|
path = ApiUrlsHome.PostProtectionOverheat;
|
|
207
|
-
|
|
209
|
+
this.headers.Referer = ApiUrlsHome.Referers.PostProtectionOverheat.replace('deviceid', deviceData.DeviceID);
|
|
208
210
|
break;
|
|
209
211
|
case 'holidaymode':
|
|
210
212
|
payload = {
|
|
@@ -215,19 +217,19 @@ class MelCloudAta extends EventEmitter {
|
|
|
215
217
|
};
|
|
216
218
|
method = 'POST';
|
|
217
219
|
path = ApiUrlsHome.PostHolidayMode;
|
|
218
|
-
|
|
220
|
+
this.headers.Referer = ApiUrlsHome.Referers.PostHolidayMode.replace('deviceid', deviceData.DeviceID);
|
|
219
221
|
break;
|
|
220
222
|
case 'schedule':
|
|
221
223
|
payload = { enabled: deviceData.ScheduleEnabled };
|
|
222
224
|
method = 'PUT';
|
|
223
225
|
path = ApiUrlsHome.PutScheduleEnabled.replace('deviceid', deviceData.DeviceID);
|
|
224
|
-
|
|
226
|
+
this.headers.Referer = ApiUrlsHome.Referers.PutScheduleEnabled.replace('deviceid', deviceData.DeviceID);
|
|
225
227
|
break;
|
|
226
228
|
case 'scene':
|
|
227
229
|
method = 'PUT';
|
|
228
230
|
const state = flagData.Enabled ? 'Enable' : 'Disable';
|
|
229
231
|
path = ApiUrlsHome.PutScene[state].replace('sceneid', flagData.Id);
|
|
230
|
-
|
|
232
|
+
this.headers.Referer = ApiUrlsHome.Referers.GetPutScenes;
|
|
231
233
|
break;
|
|
232
234
|
default:
|
|
233
235
|
payload = {
|
|
@@ -242,18 +244,18 @@ class MelCloudAta extends EventEmitter {
|
|
|
242
244
|
};
|
|
243
245
|
method = 'PUT';
|
|
244
246
|
path = ApiUrlsHome.PutAta.replace('deviceid', deviceData.DeviceID);
|
|
245
|
-
|
|
247
|
+
this.headers.Referer = ApiUrlsHome.Referers.PutDeviceSettings
|
|
246
248
|
break
|
|
247
249
|
}
|
|
248
250
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}, Headers: ${JSON.stringify(
|
|
251
|
+
this.headers['Content-Type'] = 'application/json; charset=utf-8';
|
|
252
|
+
this.headers.Origin = ApiUrlsHome.Origin;
|
|
253
|
+
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}, Headers: ${JSON.stringify(this.headers, null, 2)}`);
|
|
252
254
|
await axios(path, {
|
|
253
255
|
method: method,
|
|
254
256
|
baseURL: ApiUrlsHome.BaseURL,
|
|
255
257
|
timeout: 10000,
|
|
256
|
-
headers:
|
|
258
|
+
headers: this.headers,
|
|
257
259
|
data: payload
|
|
258
260
|
});
|
|
259
261
|
this.updateData(deviceData);
|
package/src/melcloudatw.js
CHANGED
|
@@ -23,6 +23,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
23
23
|
|
|
24
24
|
//set default values
|
|
25
25
|
this.devicesData = {};
|
|
26
|
+
this.headers = {};
|
|
26
27
|
|
|
27
28
|
//lock flags
|
|
28
29
|
this.locks = true;
|
|
@@ -52,6 +53,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
52
53
|
try {
|
|
53
54
|
//read device info from file
|
|
54
55
|
const devicesData = await this.functions.readData(this.devicesFile, true);
|
|
56
|
+
this.headers = devicesData.Headers;
|
|
55
57
|
const scenes = devicesData.Scenes ?? [];
|
|
56
58
|
const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
|
|
57
59
|
|
|
@@ -171,7 +173,7 @@ class MelCloudAtw extends EventEmitter {
|
|
|
171
173
|
method: 'POST',
|
|
172
174
|
baseURL: ApiUrls.BaseURL,
|
|
173
175
|
timeout: 10000,
|
|
174
|
-
headers:
|
|
176
|
+
headers: this.headers,
|
|
175
177
|
data: payload
|
|
176
178
|
});
|
|
177
179
|
this.updateData(deviceData);
|
|
@@ -187,19 +189,19 @@ class MelCloudAtw extends EventEmitter {
|
|
|
187
189
|
};
|
|
188
190
|
method = 'POST';
|
|
189
191
|
path = ApiUrlsHome.PostHolidayMode;
|
|
190
|
-
|
|
192
|
+
this.headers.Referer = ApiUrlsHome.Referers.PostHolidayMode.replace('deviceid', deviceData.DeviceID);
|
|
191
193
|
break;
|
|
192
194
|
case 'schedule':
|
|
193
195
|
payload = { enabled: deviceData.ScheduleEnabled };
|
|
194
196
|
method = 'PUT';
|
|
195
197
|
path = ApiUrlsHome.PutScheduleEnabled.replace('deviceid', deviceData.DeviceID);
|
|
196
|
-
|
|
198
|
+
this.headers.Referer = ApiUrlsHome.Referers.PutScheduleEnabled.replace('deviceid', deviceData.DeviceID);
|
|
197
199
|
break;
|
|
198
200
|
case 'scene':
|
|
199
201
|
method = 'PUT';
|
|
200
202
|
const state = flagData.Enabled ? 'Enable' : 'Disable';
|
|
201
203
|
path = ApiUrlsHome.PutScene[state].replace('sceneid', flagData.Id);
|
|
202
|
-
|
|
204
|
+
this.headers.Referer = ApiUrlsHome.Referers.GetPutScenes;
|
|
203
205
|
break;
|
|
204
206
|
default:
|
|
205
207
|
payload = {
|
|
@@ -219,18 +221,18 @@ class MelCloudAtw extends EventEmitter {
|
|
|
219
221
|
};
|
|
220
222
|
method = 'PUT';
|
|
221
223
|
path = ApiUrlsHome.PutAtw.replace('deviceid', deviceData.DeviceID);
|
|
222
|
-
|
|
224
|
+
this.headers.Referer = ApiUrlsHome.Referers.PutDeviceSettings
|
|
223
225
|
break
|
|
224
226
|
}
|
|
225
227
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}, Headers: ${JSON.stringify(
|
|
228
|
+
this.headers['Content-Type'] = 'application/json; charset=utf-8';
|
|
229
|
+
this.headers.Origin = ApiUrlsHome.Origin;
|
|
230
|
+
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}, Headers: ${JSON.stringify(this.headers, null, 2)}`);
|
|
229
231
|
await axios(path, {
|
|
230
232
|
method: method,
|
|
231
233
|
baseURL: ApiUrlsHome.BaseURL,
|
|
232
234
|
timeout: 10000,
|
|
233
|
-
headers:
|
|
235
|
+
headers: this.headers,
|
|
234
236
|
data: payload
|
|
235
237
|
});
|
|
236
238
|
this.updateData(deviceData);
|
package/src/melclouderv.js
CHANGED
|
@@ -23,6 +23,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
23
23
|
|
|
24
24
|
//set default values
|
|
25
25
|
this.devicesData = {};
|
|
26
|
+
this.headers = {};
|
|
26
27
|
|
|
27
28
|
//lock flags
|
|
28
29
|
this.locks = true;
|
|
@@ -52,6 +53,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
52
53
|
try {
|
|
53
54
|
//read device info from file
|
|
54
55
|
const devicesData = await this.functions.readData(this.devicesFile, true);
|
|
56
|
+
this.headers = devicesData.Headers;
|
|
55
57
|
const scenes = devicesData.Scenes ?? [];
|
|
56
58
|
const deviceData = devicesData.Devices.find(device => device.DeviceID === this.deviceId);
|
|
57
59
|
|
|
@@ -174,7 +176,7 @@ class MelCloudErv extends EventEmitter {
|
|
|
174
176
|
method: 'POST',
|
|
175
177
|
baseURL: ApiUrls.BaseURL,
|
|
176
178
|
timeout: 10000,
|
|
177
|
-
headers:
|
|
179
|
+
headers: this.headers,
|
|
178
180
|
data: payload
|
|
179
181
|
});
|
|
180
182
|
this.updateData(deviceData);
|
|
@@ -202,19 +204,19 @@ class MelCloudErv extends EventEmitter {
|
|
|
202
204
|
};
|
|
203
205
|
method = 'POST';
|
|
204
206
|
path = ApiUrlsHome.PostHolidayMode;
|
|
205
|
-
|
|
207
|
+
this.headers.Referer = ApiUrlsHome.Referers.PostHolidayMode.replace('deviceid', deviceData.DeviceID);
|
|
206
208
|
break;
|
|
207
209
|
case 'schedule':
|
|
208
210
|
payload = { enabled: deviceData.ScheduleEnabled };
|
|
209
211
|
method = 'PUT';
|
|
210
212
|
path = ApiUrlsHome.PutScheduleEnabled.replace('deviceid', deviceData.DeviceID);
|
|
211
|
-
|
|
213
|
+
this.headers.Referer = ApiUrlsHome.Referers.PutScheduleEnabled.replace('deviceid', deviceData.DeviceID);
|
|
212
214
|
break;
|
|
213
215
|
case 'scene':
|
|
214
216
|
method = 'PUT';
|
|
215
217
|
const state = flagData.Enabled ? 'Enable' : 'Disable';
|
|
216
218
|
path = ApiUrlsHome.PutScene[state].replace('sceneid', flagData.Id);
|
|
217
|
-
|
|
219
|
+
this.headers.Referer = ApiUrlsHome.Referers.GetPutScenes;
|
|
218
220
|
break;
|
|
219
221
|
default:
|
|
220
222
|
payload = {
|
|
@@ -226,18 +228,18 @@ class MelCloudErv extends EventEmitter {
|
|
|
226
228
|
};
|
|
227
229
|
method = 'PUT';
|
|
228
230
|
path = ApiUrlsHome.PutErv.replace('deviceid', deviceData.DeviceID);
|
|
229
|
-
|
|
231
|
+
this.headers.Referer = ApiUrlsHome.Referers.PutDeviceSettings
|
|
230
232
|
break
|
|
231
233
|
}
|
|
232
234
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}, Headers: ${JSON.stringify(
|
|
235
|
+
this.headers['Content-Type'] = 'application/json; charset=utf-8';
|
|
236
|
+
this.headers.Origin = ApiUrlsHome.Origin;
|
|
237
|
+
if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(payload, null, 2)}, Headers: ${JSON.stringify(this.headers, null, 2)}`);
|
|
236
238
|
await axios(path, {
|
|
237
239
|
method: method,
|
|
238
240
|
baseURL: ApiUrlsHome.BaseURL,
|
|
239
241
|
timeout: 10000,
|
|
240
|
-
headers:
|
|
242
|
+
headers: this.headers,
|
|
241
243
|
data: payload
|
|
242
244
|
});
|
|
243
245
|
this.updateData(deviceData);
|
package/src/melcloudhome.js
CHANGED
|
@@ -189,7 +189,6 @@ class MelCloud extends EventEmitter {
|
|
|
189
189
|
DeviceName: GivenDisplayName,
|
|
190
190
|
SerialNumber: Id,
|
|
191
191
|
Device: deviceObject,
|
|
192
|
-
Headers: this.headers
|
|
193
192
|
};
|
|
194
193
|
};
|
|
195
194
|
|
|
@@ -212,6 +211,7 @@ class MelCloud extends EventEmitter {
|
|
|
212
211
|
devicesList.Info = `Found ${devicesCount} devices`;
|
|
213
212
|
devicesList.Devices = devices;
|
|
214
213
|
devicesList.Scenes = scenes;
|
|
214
|
+
devicesList.Headers = this.headers;
|
|
215
215
|
|
|
216
216
|
await this.functions.saveData(this.devicesFile, devicesList);
|
|
217
217
|
if (this.logDebug) this.emit('debug', `${devicesCount} devices saved`);
|