homebridge-melcloud-control 4.1.3-beta.14 → 4.1.3-beta.16

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.
@@ -395,29 +395,38 @@
395
395
  "default": false,
396
396
  "description": "This enable extra outdoor temperature sensor to use with automations in HomeKit app."
397
397
  },
398
- "frostProtectionSensor": {
399
- "title": "Frost Protection",
398
+ "errorSensor": {
399
+ "title": "Error",
400
+ "type": "boolean",
401
+ "default": false,
402
+ "description": "This enable error sensor to use with automations in HomeKit app."
403
+ },
404
+ "frostProtectionSupport": {
405
+ "title": "Frost Protection Support",
400
406
  "type": "boolean",
401
407
  "default": false,
402
- "description": "This enable extra frost protection sensor to use with automations in HomeKit app.",
408
+ "description": "This enable extra frost protection control and sensors to use with automations in HomeKit app.",
403
409
  "condition": {
404
410
  "functionBody": "return model.accounts[arrayIndices[0]].type === 'melcloudhome';"
405
411
  }
406
412
  },
407
- "overheatProtectionSensor": {
408
- "title": "Overheat Protection",
413
+ "overheatProtectionSupport": {
414
+ "title": "Overheat Protection Support",
409
415
  "type": "boolean",
410
416
  "default": false,
411
- "description": "This enable extra overheat protection sensor to use with automations in HomeKit app.",
417
+ "description": "This enable extra overheat protection control and sensors to use with automations in HomeKit app.",
412
418
  "condition": {
413
419
  "functionBody": "return model.accounts[arrayIndices[0]].type === 'melcloudhome';"
414
420
  }
415
421
  },
416
- "errorSensor": {
417
- "title": "Error",
422
+ "holidayModeSupport": {
423
+ "title": "Holiday Mode Support",
418
424
  "type": "boolean",
419
425
  "default": false,
420
- "description": "This enable error sensor to use with automations in HomeKit app."
426
+ "description": "This enable extra holiday mode control and sensors to use with automations in HomeKit app.",
427
+ "condition": {
428
+ "functionBody": "return model.accounts[arrayIndices[0]].type === 'melcloudhome';"
429
+ }
421
430
  },
422
431
  "refreshInterval": {
423
432
  "title": "Refresh Interval",
@@ -1104,6 +1113,15 @@
1104
1113
  "default": false,
1105
1114
  "description": "This enable error sensor to use with automations in HomeKit app."
1106
1115
  },
1116
+ "holidayModeSupport": {
1117
+ "title": "Holiday Mode Support",
1118
+ "type": "boolean",
1119
+ "default": false,
1120
+ "description": "This enable extra holiday mode control and sensors to use with automations in HomeKit app.",
1121
+ "condition": {
1122
+ "functionBody": "return model.accounts[arrayIndices[0]].type === 'melcloudhome';"
1123
+ }
1124
+ },
1107
1125
  "refreshInterval": {
1108
1126
  "title": "Refresh Interval",
1109
1127
  "type": "integer",
@@ -1567,6 +1585,15 @@
1567
1585
  "default": false,
1568
1586
  "description": "This enable error sensor to use with automations in HomeKit app."
1569
1587
  },
1588
+ "holidayModeSupport": {
1589
+ "title": "Holiday Mode Support",
1590
+ "type": "boolean",
1591
+ "default": false,
1592
+ "description": "This enable extra holiday mode control and sensors to use with automations in HomeKit app.",
1593
+ "condition": {
1594
+ "functionBody": "return model.accounts[arrayIndices[0]].type === 'melcloudhome';"
1595
+ }
1596
+ },
1570
1597
  "refreshInterval": {
1571
1598
  "title": "Refresh Interval",
1572
1599
  "type": "integer",
@@ -2112,6 +2139,9 @@
2112
2139
  "accounts[].ataDevices[].heatDryFanMode",
2113
2140
  "accounts[].ataDevices[].coolDryFanMode",
2114
2141
  "accounts[].ataDevices[].autoDryFanMode",
2142
+ "accounts[].ataDevices[].frostProtectionSupportr",
2143
+ "accounts[].ataDevices[].overheatProtectionSupport",
2144
+ "accounts[].ataDevices[].holidayModeSupport",
2115
2145
  "accounts[].ataDevices[].refreshInterval"
2116
2146
  ],
2117
2147
  "condition": {
@@ -2191,8 +2221,6 @@
2191
2221
  {
2192
2222
  "title": "System",
2193
2223
  "items": [
2194
- "accounts[].ataDevices[].frostProtectionSensor",
2195
- "accounts[].ataDevices[].overheatProtectionSensor",
2196
2224
  "accounts[].ataDevices[].errorSensor"
2197
2225
  ]
2198
2226
  },
@@ -2257,6 +2285,7 @@
2257
2285
  "items": [
2258
2286
  "accounts[].atwDevices[].hideZone",
2259
2287
  "accounts[].atwDevices[].name",
2288
+ "accounts[].atwDevices[].holidayModeSupport",
2260
2289
  "accounts[].atwDevices[].refreshInterval"
2261
2290
  ],
2262
2291
  "condition": {
@@ -2406,6 +2435,7 @@
2406
2435
  "expanded": false,
2407
2436
  "items": [
2408
2437
  "accounts[].ervDevices[].name",
2438
+ "accounts[].ervDevices[].holidayModeSupport",
2409
2439
  "accounts[].ervDevices[].refreshInterval"
2410
2440
  ],
2411
2441
  "condition": {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.1.3-beta.14",
4
+ "version": "4.1.3-beta.16",
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
@@ -29,9 +29,10 @@ class DeviceAta extends EventEmitter {
29
29
  this.displayType = device.displayType;
30
30
  this.temperatureSensor = device.temperatureSensor || false;
31
31
  this.temperatureOutdoorSensor = device.temperatureOutdoorSensor || false;
32
- this.frostProtectionSensor = device.frostProtectionSensor || false;
33
- this.overheatProtectionSensor = device.overheatProtectionSensor || false;
34
32
  this.errorSensor = device.errorSensor || false;
33
+ this.frostProtectionSupport = device.frostProtectionSupport || false;
34
+ this.overheatProtectionSupport = device.overheatProtectionSupport || false;
35
+ this.holidayModeSupport = device.holidayModeSupport || false;
35
36
  this.heatDryFanMode = device.heatDryFanMode || 1; //NONE, HEAT, DRY, FAN
36
37
  this.coolDryFanMode = device.coolDryFanMode || 1; //NONE, COOL, DRY, FAN
37
38
  this.autoDryFanMode = device.autoDryFanMode || 1; //NONE, AUTO, DRY, FAN
@@ -617,10 +618,57 @@ class DeviceAta extends EventEmitter {
617
618
  accessory.addService(this.outdoorTemperatureSensorService);
618
619
  };
619
620
 
620
- //frost protection sensor
621
- if (this.frostProtectionSensor && this.accessory.frostProtectionEnabled !== null) {
621
+ //error sensor
622
+ if (this.errorSensor && this.accessory.isInError !== null) {
623
+ if (this.logDebug) this.emit('debug', `Prepare error service`);
624
+ this.errorService = new Service.ContactSensor(`${serviceName} Error`, `Error Sensor ${deviceId}`);
625
+ this.errorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
626
+ this.errorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Error`);
627
+ this.errorService.getCharacteristic(Characteristic.ContactSensorState)
628
+ .onGet(async () => {
629
+ const state = this.accessory.isInError;
630
+ return state;
631
+ })
632
+ accessory.addService(this.errorService);
633
+ }
634
+
635
+ //frost protection
636
+ if (this.frostProtectionSupport && this.accessory.frostProtectionEnabled !== null) {
637
+ //control
638
+ if (this.logDebug) this.emit('debug', `Prepare frost protection control service`);
639
+ this.frostProtectionControlService = new Service.Switch(`${serviceName} Frost Protection`, `frostProtectionControlService${deviceId}`);
640
+ this.frostProtectionControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
641
+ this.frostProtectionControlService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName}Frost Protection`);
642
+ this.frostProtectionControlService.getCharacteristic(Characteristic.On)
643
+ .onGet(async () => {
644
+ const state = this.accessory.holidayModeEnabled;
645
+ return state;
646
+ })
647
+ .onSet(async (state) => {
648
+ try {
649
+ deviceData.FrostProtection.Enabled = state;
650
+ await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'frostprotection');
651
+ if (this.logInfo) this.emit('info', `Frost protection: ${state ? 'Enabled' : 'Disabled'}`);
652
+ } catch (error) {
653
+ if (this.logWarn) this.emit('warn', `Set frost protection error: ${error}`);
654
+ };
655
+ });
656
+ accessory.addService(this.frostProtectionControlService);
657
+
658
+ if (this.logDebug) this.emit('debug', `Prepare frost protection control sensor service`);
659
+ this.frostProtectionControlSensorService = new Service.ContactSensor(`${serviceName} Frost Protection Control`, `frostProtectionControlSensorService${deviceId}`);
660
+ this.frostProtectionControlSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
661
+ this.frostProtectionControlSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Frost Protection Control`);
662
+ this.frostProtectionControlSensorService.getCharacteristic(Characteristic.ContactSensorState)
663
+ .onGet(async () => {
664
+ const state = this.accessory.holidayModeEnabled;
665
+ return state;
666
+ })
667
+ accessory.addService(this.frostProtectionControlSensorService);
668
+
669
+ //sensor
622
670
  if (this.logDebug) this.emit('debug', `Prepare frost protection service`);
623
- this.frostProtectionSensorService = new Service.ContactSensor(`${serviceName} Frost Protection`, `Frost Protection Sensor ${deviceId}`);
671
+ this.frostProtectionSensorService = new Service.ContactSensor(`${serviceName} Frost Protection`, `frostProtectionSensorService${deviceId}`);
624
672
  this.frostProtectionSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
625
673
  this.frostProtectionSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Frost Protection`);
626
674
  this.frostProtectionSensorService.getCharacteristic(Characteristic.ContactSensorState)
@@ -631,10 +679,42 @@ class DeviceAta extends EventEmitter {
631
679
  accessory.addService(this.frostProtectionSensorService);
632
680
  }
633
681
 
634
- //overheat sensor
635
- if (this.overheatProtectionSensor && this.accessory.overheatProtectionEnabled !== null) {
636
- if (this.logDebug) this.emit('debug', `Prepare overheat protection service`);
637
- this.overheatProtectionSensorService = new Service.ContactSensor(`${serviceName} Overheat Protection`, `Overheat Protection Sensor ${deviceId}`);
682
+ //overheat protection
683
+ if (this.overheatProtectionSupport && this.accessory.overheatProtectionEnabled !== null) {
684
+ //control
685
+ if (this.logDebug) this.emit('debug', `Prepare overheat protection control service`);
686
+ this.overheatProtectionControlService = new Service.Switch(`${serviceName} Overheat Protection`, `overheatProtectionControlService${deviceId}`);
687
+ this.overheatProtectionControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
688
+ this.overheatProtectionControlService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Overheat Protection`);
689
+ this.overheatProtectionControlService.getCharacteristic(Characteristic.On)
690
+ .onGet(async () => {
691
+ const state = this.accessory.overheatProtectionEnabled;
692
+ return state;
693
+ })
694
+ .onSet(async (state) => {
695
+ try {
696
+ deviceData.OverheatProtection.Enabled = state;
697
+ await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'overheatprotection');
698
+ if (this.logInfo) this.emit('info', `Overheat protection: ${state ? 'Enabled' : 'Disabled'}`);
699
+ } catch (error) {
700
+ if (this.logWarn) this.emit('warn', `Set overheat protection error: ${error}`);
701
+ };
702
+ });
703
+ accessory.addService(this.overheatProtectionControlService);
704
+
705
+ if (this.logDebug) this.emit('debug', `Prepare overheat protection control sensor service`);
706
+ this.overheatProtectionControlSensorService = new Service.ContactSensor(`${serviceName} Overheat Protection Control`, `overheatProtectionControlSensorService${deviceId}`);
707
+ this.overheatProtectionControlSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
708
+ this.overheatProtectionControlSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Overheat Protection Control`);
709
+ this.overheatProtectionControlSensorService.getCharacteristic(Characteristic.ContactSensorState)
710
+ .onGet(async () => {
711
+ const state = this.accessory.overheatProtectionEnabled;
712
+ return state;
713
+ })
714
+ accessory.addService(this.overheatProtectionControlSensorService);
715
+
716
+ if (this.logDebug) this.emit('debug', `Prepare overheat protection sensor service`);
717
+ this.overheatProtectionSensorService = new Service.ContactSensor(`${serviceName} Overheat Protection`, `overheatProtectionSensorService${deviceId}`);
638
718
  this.overheatProtectionSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
639
719
  this.overheatProtectionSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Overheat Protection`);
640
720
  this.overheatProtectionSensorService.getCharacteristic(Characteristic.ContactSensorState)
@@ -646,7 +726,7 @@ class DeviceAta extends EventEmitter {
646
726
  }
647
727
 
648
728
  //holiday mode
649
- if (this.accessory.holidayModeEnabled !== null) {
729
+ if (this.holidayModeSupport && this.accessory.holidayModeEnabled !== null) {
650
730
  //control
651
731
  if (this.logDebug) this.emit('debug', `Prepare holiday mode control service`);
652
732
  this.holidayModeControlService = new Service.Switch(`${serviceName} Holiday Mode`, `Holiday Mode Control ${deviceId}`);
@@ -692,20 +772,6 @@ class DeviceAta extends EventEmitter {
692
772
  accessory.addService(this.holidayModeSensorService);
693
773
  }
694
774
 
695
- //error sensor
696
- if (this.errorSensor && this.accessory.isInError !== null) {
697
- if (this.logDebug) this.emit('debug', `Prepare error service`);
698
- this.errorService = new Service.ContactSensor(`${serviceName} Error`, `Error Sensor ${deviceId}`);
699
- this.errorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
700
- this.errorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Error`);
701
- this.errorService.getCharacteristic(Characteristic.ContactSensorState)
702
- .onGet(async () => {
703
- const state = this.accessory.isInError;
704
- return state;
705
- })
706
- accessory.addService(this.errorService);
707
- }
708
-
709
775
  //presets services
710
776
  if (this.presets.length > 0) {
711
777
  if (this.logDebug) this.emit('debug', `Prepare presets services`);
@@ -789,7 +855,7 @@ class DeviceAta extends EventEmitter {
789
855
  .onSet(async (state) => {
790
856
  try {
791
857
  deviceData.ScheduleEnabled = state;
792
- await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'scheduleenabled');
858
+ await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'schedule');
793
859
  if (this.logInfo) this.emit('info', `Schedule: ${state ? 'Enabled' : 'Disabled'}`);
794
860
  } catch (error) {
795
861
  if (this.logWarn) this.emit('warn', `Set schedule error: ${error}`);
@@ -798,15 +864,15 @@ class DeviceAta extends EventEmitter {
798
864
  accessory.addService(this.schedulesControlService);
799
865
 
800
866
  if (this.logDebug) this.emit('debug', `Prepare schedule control sensor service`);
801
- this.scheduleSensorService = new Service.ContactSensor(serviceNameSchedule, `Schedule Control Sensor ${deviceId}`);
802
- this.scheduleSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
803
- this.scheduleSensorService.setCharacteristic(Characteristic.ConfiguredName, serviceNameSchedule);
804
- this.scheduleSensorService.getCharacteristic(Characteristic.ContactSensorState)
867
+ this.schedulesControlSensorService = new Service.ContactSensor(serviceNameSchedule, `Schedule Control Sensor ${deviceId}`);
868
+ this.schedulesControlSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
869
+ this.schedulesControlSensorService.setCharacteristic(Characteristic.ConfiguredName, serviceNameSchedule);
870
+ this.schedulesControlSensorService.getCharacteristic(Characteristic.ContactSensorState)
805
871
  .onGet(async () => {
806
872
  const state = this.accessory.scheduleEnabled;
807
873
  return state;
808
874
  })
809
- accessory.addService(this.scheduleSensorService);
875
+ accessory.addService(this.schedulesControlSensorService);
810
876
  }
811
877
 
812
878
  //sensors
@@ -1104,8 +1170,6 @@ class DeviceAta extends EventEmitter {
1104
1170
  this.deviceData = deviceData;
1105
1171
 
1106
1172
  //keys
1107
- const presetsIdKey = this.accountType === 'melcloud' ? 'ID' : 'Id';
1108
- const setTempKey = this.accountType === 'melcloud' ? 'SetTemperature' : 'SetPoint';
1109
1173
  const fanKey = this.accountType === 'melcloud' ? 'FanSpeed' : 'SetFanSpeed';
1110
1174
  const tempStepKey = this.accountType === 'melcloud' ? 'TemperatureIncrement' : 'HasHalfDegreeIncrements';
1111
1175
  const errorKey = this.accountType === 'melcloud' ? 'HasError' : 'IsInError';
@@ -1362,19 +1426,36 @@ class DeviceAta extends EventEmitter {
1362
1426
  };
1363
1427
  this.accessory = obj;
1364
1428
 
1429
+ //senors
1365
1430
  this.roomTemperatureSensorService?.updateCharacteristic(Characteristic.CurrentTemperature, roomTemperature);
1366
1431
  this.outdoorTemperatureSensorService?.updateCharacteristic(Characteristic.CurrentTemperature, outdoorTemperature);
1367
- this.frostProtectionSensorService?.updateCharacteristic(Characteristic.ContactSensorState, frostProtectionActive);
1368
- this.overheatProtectionSensorService?.updateCharacteristic(Characteristic.ContactSensorState, overheatProtectionActive);
1369
- this.holidayModeControlService?.updateCharacteristic(Characteristic.On, holidayModeEnabled);
1370
- this.holidayModeControlSensorService?.updateCharacteristic(Characteristic.ContactSensorState, holidayModeEnabled);
1371
- this.holidayModeSensorService?.updateCharacteristic(Characteristic.ContactSensorState, holidayModeActive);
1372
1432
  this.errorService?.updateCharacteristic(Characteristic.ContactSensorState, isInError);
1373
1433
 
1374
- //update presets state
1434
+ //frost protection
1435
+ if (this.frostProtectionSupport && frostProtectionEnabled !== null) {
1436
+ this.frostProtectionControlService?.updateCharacteristic(Characteristic.On, frostProtectionEnabled);
1437
+ this.frostProtectionControlSensorService?.updateCharacteristic(Characteristic.ContactSensorState, frostProtectionEnabled);
1438
+ this.frostProtectionSensorService?.updateCharacteristic(Characteristic.ContactSensorState, frostProtectionActive);
1439
+ }
1440
+
1441
+ //overheat protection
1442
+ if (this.overheatProtectionSupport && overheatProtectionEnabled !== null) {
1443
+ this.overheatProtectionControlService?.updateCharacteristic(Characteristic.On, overheatProtectionEnabled);
1444
+ this.overheatProtectionControlSensorService.updateCharacteristic(Characteristic.ContactSensorState, overheatProtectionEnabled);
1445
+ this.overheatProtectionSensorService?.updateCharacteristic(Characteristic.ContactSensorState, overheatProtectionActive);
1446
+ }
1447
+
1448
+ //holiday mode
1449
+ if (this.holidayModeSupport && holidayModeEnabled !== null) {
1450
+ this.holidayModeControlService?.updateCharacteristic(Characteristic.On, holidayModeEnabled);
1451
+ this.holidayModeControlSensorService?.updateCharacteristic(Characteristic.ContactSensorState, holidayModeEnabled);
1452
+ this.holidayModeSensorService?.updateCharacteristic(Characteristic.ContactSensorState, holidayModeActive);
1453
+ }
1454
+
1455
+ //presets
1375
1456
  if (this.presets.length > 0) {
1376
1457
  this.presets.forEach((preset, i) => {
1377
- const presetData = presetsOnServer.find(p => p[presetsIdKey] === preset.id);
1458
+ const presetData = presetsOnServer.find(p => p.ID === preset.id);
1378
1459
 
1379
1460
  preset.state = presetData ? (presetData.Power === power
1380
1461
  && presetData.SetTemperature === setTemperature
@@ -1388,14 +1469,17 @@ class DeviceAta extends EventEmitter {
1388
1469
  });
1389
1470
  };
1390
1471
 
1391
- //update schedules state
1472
+ //schedules
1392
1473
  if (this.schedules.length > 0 && scheduleEnabled !== null) {
1393
1474
  this.schedules.forEach((schedule, i) => {
1394
1475
  //control
1395
- if (i === 0) this.schedulesControlService?.updateCharacteristic(Characteristic.On, scheduleEnabled);
1476
+ if (i === 0) {
1477
+ this.schedulesControlService?.updateCharacteristic(Characteristic.On, scheduleEnabled);
1478
+ this.schedulesControlSensorService?.updateCharacteristic(Characteristic.ContactSensorState, scheduleEnabled);
1479
+ }
1396
1480
 
1397
1481
  //sensors
1398
- const scheduleData = schedulesOnServer.find(s => s[presetsIdKey] === schedule.id);
1482
+ const scheduleData = schedulesOnServer.find(s => s.Id === schedule.id);
1399
1483
  schedule.state = scheduleEnabled ? scheduleData.Enabled ?? false : false;
1400
1484
 
1401
1485
  const characteristicType = schedule.characteristicType;
@@ -1403,7 +1487,7 @@ class DeviceAta extends EventEmitter {
1403
1487
  });
1404
1488
  };
1405
1489
 
1406
- //update buttons state
1490
+ //buttons
1407
1491
  if (this.buttons.length > 0) {
1408
1492
  this.buttons.forEach((button, i) => {
1409
1493
  const mode = button.mode;
package/src/deviceatw.js CHANGED
@@ -38,6 +38,7 @@ class DeviceAtw extends EventEmitter {
38
38
  this.temperatureFlowZone2Sensor = device.temperatureFlowZone2Sensor || false;
39
39
  this.temperatureReturnZone2Sensor = device.temperatureReturnZone2Sensor || false;
40
40
  this.errorSensor = device.errorSensor || false;
41
+ this.holidayModeSupport = device.holidayModeSupport || false;
41
42
  this.presets = this.accountType === 'melcloud' ? (device.presets || []).filter(preset => (preset.displayType ?? 0) > 0 && preset.id !== '0') : [];
42
43
  this.schedules = this.accountType === 'melcloudhome' ? (device.schedules || []).filter(schedule => (schedule.displayType ?? 0) > 0 && schedule.id !== '0') : [];
43
44
  this.buttons = (device.buttonsSensors || []).filter(button => (button.displayType ?? 0) > 0);
@@ -1047,11 +1048,25 @@ class DeviceAtw extends EventEmitter {
1047
1048
  });
1048
1049
  };
1049
1050
 
1051
+ //error sensor
1052
+ if (this.errorSensor && this.accessory.isInError !== null) {
1053
+ if (this.logDebug) this.emit('debug', `Prepare error service`);
1054
+ const serviceName = `${deviceTypeText} ${accessoryName}`;
1055
+ this.errorService = new Service.ContactSensor(`${serviceName} Error`, `Error Sensor ${deviceId}`);
1056
+ this.errorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
1057
+ this.errorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Error`);
1058
+ this.errorService.getCharacteristic(Characteristic.ContactSensorState)
1059
+ .onGet(async () => {
1060
+ const state = this.accessory.isInError;
1061
+ return state;
1062
+ })
1063
+ accessory.addService(this.errorService);
1064
+ }
1065
+
1050
1066
  //holiday mode
1051
- if (this.accessory.holidayModeEnabled !== null) {
1067
+ if (this.holidayModeSupport && this.accessory.holidayModeEnabled !== null) {
1052
1068
  //control
1053
1069
  if (this.logDebug) this.emit('debug', `Prepare holiday mode control service`);
1054
- const serviceName = `${deviceTypeText} ${accessoryName}`;
1055
1070
  this.holidayModeControlService = new Service.Switch(`${serviceName} Holiday Mode`, `Holiday Mode Control ${deviceId}`);
1056
1071
  this.holidayModeControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
1057
1072
  this.holidayModeControlService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Holiday Mode`);
@@ -1082,7 +1097,7 @@ class DeviceAtw extends EventEmitter {
1082
1097
  })
1083
1098
  accessory.addService(this.holidayModeControlSensorService);
1084
1099
 
1085
- //sensor
1100
+ //sensors
1086
1101
  if (this.logDebug) this.emit('debug', `Prepare holiday mode sensor service`);
1087
1102
  this.holidayModeSensorService = new Service.ContactSensor(`${serviceName} Holiday Mode`, `Holiday Mode Sensor ${deviceId}`);
1088
1103
  this.holidayModeSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
@@ -1095,21 +1110,6 @@ class DeviceAtw extends EventEmitter {
1095
1110
  accessory.addService(this.holidayModeSensorService);
1096
1111
  }
1097
1112
 
1098
- //error sensor
1099
- if (this.errorSensor && this.accessory.isInError !== null) {
1100
- if (this.logDebug) this.emit('debug', `Prepare error service`);
1101
- const serviceName = `${deviceTypeText} ${accessoryName}`;
1102
- this.errorService = new Service.ContactSensor(`${serviceName} Error`, `Error Sensor ${deviceId}`);
1103
- this.errorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
1104
- this.errorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Error`);
1105
- this.errorService.getCharacteristic(Characteristic.ContactSensorState)
1106
- .onGet(async () => {
1107
- const state = this.accessory.isInError;
1108
- return state;
1109
- })
1110
- accessory.addService(this.errorService);
1111
- }
1112
-
1113
1113
  //presets services
1114
1114
  if (this.presets.length > 0) {
1115
1115
  if (this.logDebug) this.emit('debug', `Prepare presets services`);
@@ -1206,7 +1206,7 @@ class DeviceAtw extends EventEmitter {
1206
1206
  .onSet(async (state) => {
1207
1207
  try {
1208
1208
  deviceData.ScheduleEnabled = state;
1209
- await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'scheduleenabled');
1209
+ await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'schedule');
1210
1210
  if (this.logInfo) this.emit('info', `Schedule: ${state ? 'Enabled' : 'Disabled'}`);
1211
1211
  } catch (error) {
1212
1212
  if (this.logWarn) this.emit('warn', `Set schedule error: ${error}`);
@@ -1945,13 +1945,17 @@ class DeviceAtw extends EventEmitter {
1945
1945
  };
1946
1946
  this.accessory = obj;
1947
1947
 
1948
- //update sensors state
1949
- this.holidayModeControlService?.updateCharacteristic(Characteristic.On, holidayModeEnabled);
1950
- this.holidayModeControlSensorService?.updateCharacteristic(Characteristic.ContactSensorState, holidayModeEnabled);
1951
- this.holidayModeSensorService?.updateCharacteristic(Characteristic.ContactSensorState, holidayModeActive);
1948
+ //error sensor
1952
1949
  this.errorService?.updateCharacteristic(Characteristic.ContactSensorState, isInError);
1953
1950
 
1954
- //update presets state
1951
+ //holiday mode
1952
+ if (this.holidayModeSupport && holidayModeEnabled !== null) {
1953
+ this.holidayModeControlService?.updateCharacteristic(Characteristic.On, holidayModeEnabled);
1954
+ this.holidayModeControlSensorService?.updateCharacteristic(Characteristic.ContactSensorState, holidayModeEnabled);
1955
+ this.holidayModeSensorService?.updateCharacteristic(Characteristic.ContactSensorState, holidayModeActive);
1956
+ }
1957
+
1958
+ //presets
1955
1959
  if (this.presets.length > 0) {
1956
1960
  this.presets.forEach((preset, i) => {
1957
1961
  const presetData = presetsOnServer.find(p => p[presetsIdKey] === preset.id);
@@ -1974,7 +1978,7 @@ class DeviceAtw extends EventEmitter {
1974
1978
  });
1975
1979
  };
1976
1980
 
1977
- //update schedules state
1981
+ //schedules
1978
1982
  if (this.schedules.length > 0 && scheduleEnabled !== null) {
1979
1983
  this.schedules.forEach((schedule, i) => {
1980
1984
  //control
@@ -1989,7 +1993,7 @@ class DeviceAtw extends EventEmitter {
1989
1993
  });
1990
1994
  };
1991
1995
 
1992
- //update buttons state
1996
+ //buttons
1993
1997
  if (this.buttons.length > 0) {
1994
1998
  this.buttons.forEach((button, i) => {
1995
1999
  const mode = button.mode;
package/src/deviceerv.js CHANGED
@@ -31,6 +31,7 @@ class DeviceErv extends EventEmitter {
31
31
  this.temperatureOutdoorSensor = device.temperatureOutdoorSensor || false;
32
32
  this.temperatureSupplySensor = device.temperatureSupplySensor || false;
33
33
  this.errorSensor = device.errorSensor || false;
34
+ this.holidayModeSupport = device.holidayModeSupport || false;
34
35
  this.presets = this.accountType === 'melcloud' ? (device.presets || []).filter(preset => (preset.displayType ?? 0) > 0 && preset.id !== '0') : [];
35
36
  this.schedules = this.accountType === 'melcloudhome' ? (device.schedules || []).filter(schedule => (schedule.displayType ?? 0) > 0 && schedule.id !== '0') : [];
36
37
  this.buttons = (device.buttonsSensors || []).filter(button => (button.displayType ?? 0) > 0);
@@ -666,8 +667,22 @@ class DeviceErv extends EventEmitter {
666
667
  accessory.addService(this.airQualitySensorService);
667
668
  }
668
669
 
670
+ //error sensor
671
+ if (this.errorSensor && this.accessory.isInError !== null) {
672
+ if (this.logDebug) this.emit('debug', `Prepare error service`);
673
+ this.errorService = new Service.ContactSensor(`${serviceName} Error`, `Error Sensor ${deviceId}`);
674
+ this.errorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
675
+ this.errorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Error`);
676
+ this.errorService.getCharacteristic(Characteristic.ContactSensorState)
677
+ .onGet(async () => {
678
+ const state = this.accessory.isInError;
679
+ return state;
680
+ })
681
+ accessory.addService(this.errorService);
682
+ }
683
+
669
684
  //holiday mode
670
- if (this.accessory.holidayModeEnabled !== null) {
685
+ if (this.holidayModeSupport && this.accessory.holidayModeEnabled !== null) {
671
686
  //control
672
687
  if (this.logDebug) this.emit('debug', `Prepare holiday mode control service`);
673
688
  this.holidayModeControlService = new Service.Switch(`${serviceName} Holiday Mode`, `Holiday Mode Control ${deviceId}`);
@@ -700,7 +715,7 @@ class DeviceErv extends EventEmitter {
700
715
  })
701
716
  accessory.addService(this.holidayModeControlSensorService);
702
717
 
703
- //sensor
718
+ //sensors
704
719
  if (this.logDebug) this.emit('debug', `Prepare holiday mode sensor service`);
705
720
  this.holidayModeSensorService = new Service.ContactSensor(`${serviceName} Holiday Mode`, `Holiday Mode Sensor ${deviceId}`);
706
721
  this.holidayModeSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
@@ -713,20 +728,6 @@ class DeviceErv extends EventEmitter {
713
728
  accessory.addService(this.holidayModeSensorService);
714
729
  }
715
730
 
716
- //error sensor
717
- if (this.errorSensor && this.accessory.isInError !== null) {
718
- if (this.logDebug) this.emit('debug', `Prepare error service`);
719
- this.errorService = new Service.ContactSensor(`${serviceName} Error`, `Error Sensor ${deviceId}`);
720
- this.errorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
721
- this.errorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Error`);
722
- this.errorService.getCharacteristic(Characteristic.ContactSensorState)
723
- .onGet(async () => {
724
- const state = this.accessory.isInError;
725
- return state;
726
- })
727
- accessory.addService(this.errorService);
728
- }
729
-
730
731
  //presets services
731
732
  if (this.presets.length > 0) {
732
733
  if (this.logDebug) this.emit('debug', `Prepare presets services`);
@@ -808,7 +809,7 @@ class DeviceErv extends EventEmitter {
808
809
  .onSet(async (state) => {
809
810
  try {
810
811
  deviceData.ScheduleEnabled = state;
811
- await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'scheduleenabled');
812
+ await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'schedule');
812
813
  if (this.logInfo) this.emit('info', `Schedule: ${state ? 'Enabled' : 'Disabled'}`);
813
814
  } catch (error) {
814
815
  if (this.logWarn) this.emit('warn', `Set schedule error: ${error}`);
@@ -1238,12 +1239,16 @@ class DeviceErv extends EventEmitter {
1238
1239
  .updateCharacteristic(Characteristic.PM2_5Density, pM25Level);
1239
1240
 
1240
1241
  //error sensor
1241
- this.holidayModeControlService?.updateCharacteristic(Characteristic.On, holidayModeEnabled);
1242
- this.holidayModeControlSensorService?.updateCharacteristic(Characteristic.ContactSensorState, holidayModeEnabled);
1243
- this.holidayModeSensorService?.updateCharacteristic(Characteristic.ContactSensorState, holidayModeActive);
1244
1242
  this.errorService?.updateCharacteristic(Characteristic.ContactSensorState, isInError);
1245
1243
 
1246
- //update presets state
1244
+ //holiday mode
1245
+ if (this.holidayModeSupport && holidayModeEnabled !== null) {
1246
+ this.holidayModeControlService?.updateCharacteristic(Characteristic.On, holidayModeEnabled);
1247
+ this.holidayModeControlSensorService?.updateCharacteristic(Characteristic.ContactSensorState, holidayModeEnabled);
1248
+ this.holidayModeSensorService?.updateCharacteristic(Characteristic.ContactSensorState, holidayModeActive);
1249
+ }
1250
+
1251
+ //presets
1247
1252
  if (this.presets.length > 0) {
1248
1253
  this.presets.forEach((preset, i) => {
1249
1254
  const presetData = presetsOnServer.find(p => p[presetsIdKey] === preset.id);
@@ -1259,7 +1264,7 @@ class DeviceErv extends EventEmitter {
1259
1264
  });
1260
1265
  };
1261
1266
 
1262
- //update schedules state
1267
+ //schedules
1263
1268
  if (this.schedules.length > 0 && scheduleEnabled !== null) {
1264
1269
  this.schedules.forEach((schedule, i) => {
1265
1270
  //control
@@ -1274,7 +1279,7 @@ class DeviceErv extends EventEmitter {
1274
1279
  });
1275
1280
  };
1276
1281
 
1277
- //update buttons state
1282
+ //buttons
1278
1283
  if (this.buttons.length > 0) {
1279
1284
  this.buttons.forEach((button, i) => {
1280
1285
  const mode = button.mode;;
@@ -183,14 +183,6 @@ class MelCloudAta extends EventEmitter {
183
183
  this.updateData(deviceData);
184
184
  return true;
185
185
  case "melcloudhome":
186
- const axiosInstancePut = axios.create({
187
- method: 'PUT',
188
- baseURL: ApiUrlsHome.BaseURL,
189
- timeout: 10000,
190
- headers: deviceData.Headers,
191
- withCredentials: true
192
- });
193
-
194
186
  if (displayType === 1 && deviceData.Device.OperationMode === 8) {
195
187
  deviceData.Device.SetTemperature = (deviceData.Device.DefaultCoolingSetTemperature + deviceData.Device.DefaultHeatingSetTemperature) / 2;
196
188
 
@@ -203,15 +195,44 @@ class MelCloudAta extends EventEmitter {
203
195
  }
204
196
  }
205
197
 
198
+ let method = null
206
199
  let settings = {};
207
200
  let path = '';
208
201
  switch (effectiveFlags) {
209
- case 'scheduleenabled':
202
+ case 'frostprotection':
203
+ settings = {
204
+ data: {
205
+ enabled: deviceData.FrostProtection.Enabled
206
+ }
207
+ };
208
+ method = 'POST';
209
+ path = ApiUrlsHome.PostProtectionFrost.replace('deviceid', deviceData.DeviceID);
210
+ break;
211
+ case 'overheatprotection':
212
+ settings = {
213
+ data: {
214
+ enabled: deviceData.OverheatProtection.Enabled
215
+ }
216
+ };
217
+ method = 'POST';
218
+ path = ApiUrlsHome.PostProtectionOverheat.replace('deviceid', deviceData.DeviceID);
219
+ break;
220
+ case 'holidaymode':
221
+ settings = {
222
+ data: {
223
+ enabled: deviceData.HolidayMode.Enabled
224
+ }
225
+ };
226
+ method = 'POST';
227
+ path = ApiUrlsHome.PostHolidayMode.replace('deviceid', deviceData.DeviceID);
228
+ break;
229
+ case 'schedule':
210
230
  settings = {
211
231
  data: {
212
232
  enabled: deviceData.ScheduleEnabled
213
233
  }
214
234
  };
235
+ method = 'PUT';
215
236
  path = ApiUrlsHome.PutScheduleEnable.replace('deviceid', deviceData.DeviceID);
216
237
  break;
217
238
  default:
@@ -225,10 +246,19 @@ class MelCloudAta extends EventEmitter {
225
246
  VaneVerticalDirection: AirConditioner.VaneVerticalDirectionMapEnumToString[deviceData.Device.VaneVerticalDirection],
226
247
  }
227
248
  };
249
+ method = 'PUT';
228
250
  path = ApiUrlsHome.SetAta.replace('deviceid', deviceData.DeviceID);
229
251
  break
230
252
  }
231
253
 
254
+ const axiosInstancePut = axios.create({
255
+ method: method,
256
+ baseURL: ApiUrlsHome.BaseURL,
257
+ timeout: 10000,
258
+ headers: deviceData.Headers,
259
+ withCredentials: true
260
+ });
261
+
232
262
  if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(settings.data, null, 2)}`);
233
263
  await axiosInstancePut(path, settings);
234
264
  this.updateData(deviceData);
@@ -187,23 +187,26 @@ class MelCloudAtw extends EventEmitter {
187
187
  this.updateData(deviceData);
188
188
  return true;
189
189
  case "melcloudhome":
190
- const axiosInstancePut = axios.create({
191
- method: 'PUT',
192
- baseURL: ApiUrlsHome.BaseURL,
193
- timeout: 10000,
194
- headers: deviceData.Headers,
195
- withCredentials: true
196
- });
197
-
190
+ let method = null
198
191
  let settings = {};
199
192
  let path = '';
200
193
  switch (effectiveFlags) {
201
- case 'scheduleenabled':
194
+ case 'holidaymode':
195
+ settings = {
196
+ data: {
197
+ enabled: deviceData.HolidayMode.Enabled
198
+ }
199
+ };
200
+ method = 'POST';
201
+ path = ApiUrlsHome.PostHolidayMode.replace('deviceid', deviceData.DeviceID);
202
+ break;
203
+ case 'schedule':
202
204
  settings = {
203
205
  data: {
204
206
  enabled: deviceData.ScheduleEnabled
205
207
  }
206
208
  };
209
+ method = 'PUT';
207
210
  path = ApiUrlsHome.PutScheduleEnable.replace('deviceid', deviceData.DeviceID);
208
211
  break;
209
212
  default:
@@ -224,10 +227,19 @@ class MelCloudAtw extends EventEmitter {
224
227
  EcoHotWater: deviceData.Device.EcoHotWater,
225
228
  }
226
229
  };
230
+ method = 'PUT';
227
231
  path = ApiUrlsHome.SetAtw.replace('deviceid', deviceData.DeviceID);
228
232
  break
229
233
  }
230
234
 
235
+ const axiosInstancePut = axios.create({
236
+ method: method,
237
+ baseURL: ApiUrlsHome.BaseURL,
238
+ timeout: 10000,
239
+ headers: deviceData.Headers,
240
+ withCredentials: true
241
+ });
242
+
231
243
  if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(settings.data, null, 2)}`);
232
244
  await axiosInstancePut(path, settings);
233
245
  this.updateData(deviceData);
@@ -191,14 +191,6 @@ class MelCloudErv extends EventEmitter {
191
191
  this.updateData(deviceData);
192
192
  return true;
193
193
  case "melcloudhome":
194
- const axiosInstancePut = axios.create({
195
- method: 'PUT',
196
- baseURL: ApiUrlsHome.BaseURL,
197
- timeout: 10000,
198
- headers: deviceData.Headers,
199
- withCredentials: true
200
- });
201
-
202
194
  if (displayType === 1 && deviceData.Device.VentilationMode === 2) {
203
195
  deviceData.Device.SetTemperature = (deviceData.Device.DefaultCoolingSetTemperature + deviceData.Device.DefaultHeatingSetTemperature) / 2;
204
196
 
@@ -211,15 +203,26 @@ class MelCloudErv extends EventEmitter {
211
203
  }
212
204
  }
213
205
 
206
+ let method = null;
214
207
  let settings = {};
215
208
  let path = '';
216
209
  switch (effectiveFlags) {
217
- case 'scheduleenabled':
210
+ case 'holidaymode':
211
+ settings = {
212
+ data: {
213
+ enabled: deviceData.HolidayMode.Enabled
214
+ }
215
+ };
216
+ method = 'POST';
217
+ path = ApiUrlsHome.PostHolidayMode.replace('deviceid', deviceData.DeviceID);
218
+ break;
219
+ case 'schedule':
218
220
  settings = {
219
221
  data: {
220
222
  enabled: deviceData.ScheduleEnabled
221
223
  }
222
224
  };
225
+ method = 'PUT';
223
226
  path = ApiUrlsHome.PutScheduleEnable.replace('deviceid', deviceData.DeviceID);
224
227
  break;
225
228
  default:
@@ -232,10 +235,19 @@ class MelCloudErv extends EventEmitter {
232
235
  VentilationMode: Ventilation.VentilationModeMapEnumToString[deviceData.Device.VentilationMode],
233
236
  }
234
237
  };
238
+ method = 'PUT';
235
239
  path = ApiUrlsHome.SetErv.replace('deviceid', deviceData.DeviceID);
236
240
  break
237
241
  }
238
242
 
243
+ const axiosInstancePut = axios.create({
244
+ method: method,
245
+ baseURL: ApiUrlsHome.BaseURL,
246
+ timeout: 10000,
247
+ headers: deviceData.Headers,
248
+ withCredentials: true
249
+ });
250
+
239
251
  if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(settings.data, null, 2)}`);
240
252
  await axiosInstancePut(path, settings);
241
253
  this.updateData(deviceData);