homebridge-melcloud-control 4.1.3-beta.1 → 4.1.3-beta.10

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/README.md CHANGED
@@ -65,7 +65,8 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
65
65
  * Vane V mode `AUTO/1/2/3/4/5/SWING`.
66
66
  * Fan speed mode `AUTO/1/2/3/4/5`.
67
67
  * Presets `SET/UNSET`.
68
- * Schedules `ON/OFF`.
68
+ * Holiday mode `ON/OFF`.
69
+ * Schedule `ON/OFF`.
69
70
  * Sensors:
70
71
  * For automation and notifications.
71
72
  * Power `ON/OFF`.
@@ -80,7 +81,8 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
80
81
  * Frost protection.
81
82
  * Overheat protection.
82
83
  * Holiday mode.
83
- * Shedule.
84
+ * Shedule control.
85
+ * Shedule active
84
86
  * Error
85
87
  * Heat Pump:
86
88
  * Heater Cooler:
@@ -118,6 +120,8 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
118
120
  * Operating mode `HEAT/COOL/CURVE/HOLIDAY/AUTO HOT WATER/ECO HOT WATER/FORCE HOT WATER`.
119
121
  * Physical lock controls `LOCK/UNLOCK`.
120
122
  * Presets `SET/UNSET`.
123
+ * Holiday mode `ON/OFF`.
124
+ * Schedule `ON/OFF`.
121
125
  * Sensors:
122
126
  * For automation and notifications.
123
127
  * Power `ON/OFF`.
@@ -130,6 +134,9 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
130
134
  * Water tank temperature.
131
135
  * Flow Temperature Zone 1, 2, Hot Water.
132
136
  * Return Temperature Zone 1, 2, Hot Water.
137
+ * Holiday mode.
138
+ * Shedule control.
139
+ * Shedule active
133
140
  * Error
134
141
  * Energy Recovery Ventilation Lossnay:
135
142
  * Heater Cooler:
@@ -147,6 +154,8 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
147
154
  * Operating mode `LOSSNAY/BYPASS/AUTO/NIGHT PURGE`.
148
155
  * Fan speed mode `AUTO/1/2/3/4`.
149
156
  * Presets `SET/UNSET`.
157
+ * Holiday mode `ON/OFF`.
158
+ * Schedule `ON/OFF`.
150
159
  * Sensors:
151
160
  * For automation and notifications.
152
161
  * Power `ON/OFF`.
@@ -160,6 +169,9 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
160
169
  * Filter maintenance.
161
170
  * CO2 detected and level.
162
171
  * PM2.5 air quality and level.
172
+ * Holiday mode.
173
+ * Shedule control.
174
+ * Shedule active
163
175
  * Error
164
176
 
165
177
  ### HOME app current device mode display
@@ -229,8 +241,6 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
229
241
  | `ataDevices[].temperatureOutdoorSensor` | This enable extra `Outdoor` temperature sensor to use with automations in HomeKit app. |
230
242
  | `ataDevices[].frostProtectionSensor` | This enable extra `Frost Protectio` sensor to use with automations in HomeKit app. |
231
243
  | `ataDevices[].overHeatProtectionSensor` | This enable extra `Overheat Protection` sensor to use with automations in HomeKit app. |
232
- | `ataDevices[].holidayModeSensor` | This enable extra `Holiday Mode` sensor to use with automations in HomeKit app. |
233
- | `ataDevices[].scheduleSensor` | This enable extra `Shedule` sensor to use with automations in HomeKit app. |
234
244
  | `ataDevices[].errorSensor` | This enable `Error` sensor to use with automations in HomeKit app. |
235
245
  | `ataDevices[].refreshInterval` | Here set the background devices state refresh time in (sec), default `5s`. |
236
246
  | `ataDevices[].presets[]` | Array of ATA device `Presets` created automatically after login to MELCloud from plugin config UI. |
@@ -240,7 +250,7 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
240
250
  | `ataDevices[].schedules[]` | Array of ATA device `Schedules` created automatically after login to MELCloud Home from plugin config UI. |
241
251
  | `ataDevices[].schedules[].id` | Read only data, do not change it. |
242
252
  | `ataDevices[].schedules[].name` | Here You can schange the `Schedule Name` which is exposed to the `Homebridge/HomeKit`. |
243
- | `ataDevices[].schedules[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Outlet`, `2 - Switch`, `3 - Motion Sensor`, `4 - Occupancy Sensor`, `5 - Contact Sensor`. |
253
+ | `ataDevices[].schedules[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`. |
244
254
  | `ataDevices[].buttonsSensors[]` | Array of buttons sensors. |
245
255
  | `ataDevices[].buttonsSensors[].name` | Here set `Button Name` which You want expose to the `Homebridge/HomeKit`. |
246
256
  | `ataDevices[].buttonsSensors[].mode` | Here select button mode, VH - Vane Horizontal, VV - Vane Horizontal. |
@@ -271,7 +281,7 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
271
281
  | `atwDevices[].schedules[]` | Array of ATW device `Schedules` created automatically after login to MELCloud Home from plugin config UI. |
272
282
  | `atwDevices[].schedules[].id` | Read only data, do not change it. |
273
283
  | `atwDevices[].schedules[].name` | Here You can schange the `Schedule Name` which is exposed to the `Homebridge/HomeKit`. |
274
- | `atwDevices[].schedules[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Outlet`, `2 - Switch`, `3 - Motion Sensor`, `4 - Occupancy Sensor`, `5 - Contact Sensor`. |
284
+ | `atwDevices[].schedules[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`. |
275
285
  | `atwDevices[].buttonsSensors[]` | Array of buttons sensors. |
276
286
  | `atwDevices[].buttonsSensors[].name` | Here set `Button Name` which You want expose to the `Homebridge/HomeKit`. |
277
287
  | `atwDevices[].buttonsSensors[].mode` | Here select button mode. |
@@ -295,13 +305,13 @@ Homebridge plugin for Air Conditioner, Heat Pump and Energy Recovery Ventilation
295
305
  | `ervDevices[].schedules[]` | Array of ERV device `Schedules` created automatically after login to MELCloud Home from plugin config UI. |
296
306
  | `ervDevices[].schedules[].id` | Read only data, do not change it. |
297
307
  | `ervDevices[].schedules[].name` | Here You can schange the `Schedule Name` which is exposed to the `Homebridge/HomeKit`. |
298
- | `ervDevices[].schedules[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Outlet`, `2 - Switch`, `3 - Motion Sensor`, `4 - Occupancy Sensor`, `5 - Contact Sensor`. |
308
+ | `ervDevices[].schedules[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Motion Sensor`, `2 - Occupancy Sensor`, `3 - Contact Sensor`. |
299
309
  | `ervDevices[].buttonsSensors[]` | Array of buttons sensors. |
300
310
  | `ervDevices[].buttonsSensors[].name` | Here set `Button Name` which You want expose to the `Homebridge/HomeKit`. |
301
311
  | `ervDevices[].buttonsSensors[].mode` | Here select button mode. |
302
312
  | `ervDevices[].buttonsSensors[].displayType` | Here select display type in HomeKit, `0 - None/Disabled`, `1 - Outlet`, `2 - Switch`, `3 - Motion Sensor`, `4 - Occupancy Sensor`, `5 - Contact Sensor`. |
303
313
  | `ervDevices[].buttonsSensors[].namePrefix` | Here enable/disable the accessory name as a prefix for button/sensor name. |
304
- | `refreshInterval` | Here set the background account data refresh time in (sec), default `120s`. |
314
+ | `refreshInterval` | Here set the background account data refresh time in (sec) , only for old MELCLoud, default `120s`. |
305
315
  | `log{}` | Log object. |
306
316
  | `log.deviceInfo` | If enabled, log device info will be displayed by every connections device to the network. |
307
317
  | `log.success` | If enabled, success log will be displayed in console. |
@@ -413,24 +413,6 @@
413
413
  "functionBody": "return model.accounts[arrayIndices[0]].type === 'melcloudhome';"
414
414
  }
415
415
  },
416
- "holidayModeSensor": {
417
- "title": "Holiday Mode",
418
- "type": "boolean",
419
- "default": false,
420
- "description": "This enable extra holiday mode sensor to use with automations in HomeKit app.",
421
- "condition": {
422
- "functionBody": "return model.accounts[arrayIndices[0]].type === 'melcloudhome';"
423
- }
424
- },
425
- "scheduleSensor": {
426
- "title": "Schedule Enabled",
427
- "type": "boolean",
428
- "default": false,
429
- "description": "This enable extra schedule sensor to use with automations in HomeKit app.",
430
- "condition": {
431
- "functionBody": "return model.accounts[arrayIndices[0]].type === 'melcloudhome';"
432
- }
433
- },
434
416
  "errorSensor": {
435
417
  "title": "Error",
436
418
  "type": "boolean",
@@ -541,7 +523,7 @@
541
523
  "title": "Display Type",
542
524
  "type": "integer",
543
525
  "minimum": 0,
544
- "maximum": 5,
526
+ "maximum": 3,
545
527
  "default": 0,
546
528
  "description": "Select the characteristic type to be displayed in HomeKit app.",
547
529
  "anyOf": [
@@ -551,34 +533,22 @@
551
533
  0
552
534
  ]
553
535
  },
554
- {
555
- "title": "Outlet",
556
- "enum": [
557
- 1
558
- ]
559
- },
560
- {
561
- "title": "Switch",
562
- "enum": [
563
- 2
564
- ]
565
- },
566
536
  {
567
537
  "title": "Motion Sensor",
568
538
  "enum": [
569
- 3
539
+ 1
570
540
  ]
571
541
  },
572
542
  {
573
543
  "title": "Occupancy Sensor",
574
544
  "enum": [
575
- 4
545
+ 2
576
546
  ]
577
547
  },
578
548
  {
579
549
  "title": "Contact Sensor",
580
550
  "enum": [
581
- 5
551
+ 3
582
552
  ]
583
553
  }
584
554
  ]
@@ -1128,24 +1098,6 @@
1128
1098
  "default": false,
1129
1099
  "description": "This enable extra Return Zone 2 temperature sensor to use with automations in HomeKit app."
1130
1100
  },
1131
- "holidayModeSensor": {
1132
- "title": "Holiday Mode",
1133
- "type": "boolean",
1134
- "default": false,
1135
- "description": "This enable extra holiday mode sensor to use with automations in HomeKit app.",
1136
- "condition": {
1137
- "functionBody": "return model.accounts[arrayIndices[0]].type === 'melcloudhome';"
1138
- }
1139
- },
1140
- "scheduleSensor": {
1141
- "title": "Schedule Enabled",
1142
- "type": "boolean",
1143
- "default": false,
1144
- "description": "This enable extra schedule sensor to use with automations in HomeKit app.",
1145
- "condition": {
1146
- "functionBody": "return model.accounts[arrayIndices[0]].type === 'melcloudhome';"
1147
- }
1148
- },
1149
1101
  "errorSensor": {
1150
1102
  "title": "Error",
1151
1103
  "type": "boolean",
@@ -1256,7 +1208,7 @@
1256
1208
  "title": "Display Type",
1257
1209
  "type": "integer",
1258
1210
  "minimum": 0,
1259
- "maximum": 5,
1211
+ "maximum": 3,
1260
1212
  "default": 0,
1261
1213
  "description": "Select the characteristic type to be displayed in HomeKit app.",
1262
1214
  "anyOf": [
@@ -1266,34 +1218,22 @@
1266
1218
  0
1267
1219
  ]
1268
1220
  },
1269
- {
1270
- "title": "Outlet",
1271
- "enum": [
1272
- 1
1273
- ]
1274
- },
1275
- {
1276
- "title": "Switch",
1277
- "enum": [
1278
- 2
1279
- ]
1280
- },
1281
1221
  {
1282
1222
  "title": "Motion Sensor",
1283
1223
  "enum": [
1284
- 3
1224
+ 1
1285
1225
  ]
1286
1226
  },
1287
1227
  {
1288
1228
  "title": "Occupancy Sensor",
1289
1229
  "enum": [
1290
- 4
1230
+ 2
1291
1231
  ]
1292
1232
  },
1293
1233
  {
1294
1234
  "title": "Contact Sensor",
1295
1235
  "enum": [
1296
- 5
1236
+ 3
1297
1237
  ]
1298
1238
  }
1299
1239
  ]
@@ -1621,24 +1561,6 @@
1621
1561
  "default": false,
1622
1562
  "description": "This enable extra supply temperature sensor to use with automations in HomeKit app."
1623
1563
  },
1624
- "holidayModeSensor": {
1625
- "title": "Holiday Mode",
1626
- "type": "boolean",
1627
- "default": false,
1628
- "description": "This enable extra holiday mode sensor to use with automations in HomeKit app.",
1629
- "condition": {
1630
- "functionBody": "return model.accounts[arrayIndices[0]].type === 'melcloudhome';"
1631
- }
1632
- },
1633
- "scheduleSensor": {
1634
- "title": "Schedule Enabled",
1635
- "type": "boolean",
1636
- "default": false,
1637
- "description": "This enable extra schedule sensor to use with automations in HomeKit app.",
1638
- "condition": {
1639
- "functionBody": "return model.accounts[arrayIndices[0]].type === 'melcloudhome';"
1640
- }
1641
- },
1642
1564
  "errorSensor": {
1643
1565
  "title": "Error",
1644
1566
  "type": "boolean",
@@ -1753,7 +1675,7 @@
1753
1675
  "title": "Display Type",
1754
1676
  "type": "integer",
1755
1677
  "minimum": 0,
1756
- "maximum": 5,
1678
+ "maximum": 3,
1757
1679
  "default": 0,
1758
1680
  "description": "Select the characteristic type to be displayed in HomeKit app.",
1759
1681
  "anyOf": [
@@ -1763,34 +1685,22 @@
1763
1685
  0
1764
1686
  ]
1765
1687
  },
1766
- {
1767
- "title": "Outlet",
1768
- "enum": [
1769
- 1
1770
- ]
1771
- },
1772
- {
1773
- "title": "Switch",
1774
- "enum": [
1775
- 2
1776
- ]
1777
- },
1778
1688
  {
1779
1689
  "title": "Motion Sensor",
1780
1690
  "enum": [
1781
- 3
1691
+ 1
1782
1692
  ]
1783
1693
  },
1784
1694
  {
1785
1695
  "title": "Occupancy Sensor",
1786
1696
  "enum": [
1787
- 4
1697
+ 2
1788
1698
  ]
1789
1699
  },
1790
1700
  {
1791
1701
  "title": "Contact Sensor",
1792
1702
  "enum": [
1793
- 5
1703
+ 3
1794
1704
  ]
1795
1705
  }
1796
1706
  ]
@@ -2003,7 +1913,10 @@
2003
1913
  "default": 120,
2004
1914
  "minimum": 1,
2005
1915
  "maximum": 600,
2006
- "description": "Set the background account data refresh time in seconds."
1916
+ "description": "Set the background account data refresh time in seconds.",
1917
+ "condition": {
1918
+ "functionBody": "return model.accounts[arrayIndices[0]].type === 'melcloud';"
1919
+ }
2007
1920
  },
2008
1921
  "log": {
2009
1922
  "title": "Log",
@@ -2280,8 +2193,6 @@
2280
2193
  "items": [
2281
2194
  "accounts[].ataDevices[].frostProtectionSensor",
2282
2195
  "accounts[].ataDevices[].overheatProtectionSensor",
2283
- "accounts[].ataDevices[].holidayModeSensor",
2284
- "accounts[].ataDevices[].scheduleSensor",
2285
2196
  "accounts[].ataDevices[].errorSensor"
2286
2197
  ]
2287
2198
  },
@@ -2432,8 +2343,6 @@
2432
2343
  {
2433
2344
  "title": "System",
2434
2345
  "items": [
2435
- "accounts[].atwDevices[].holidayModeSensor",
2436
- "accounts[].atwDevices[].scheduleSensor",
2437
2346
  "accounts[].atwDevices[].errorSensor"
2438
2347
  ]
2439
2348
  },
@@ -2577,8 +2486,6 @@
2577
2486
  {
2578
2487
  "title": "System",
2579
2488
  "items": [
2580
- "accounts[].ervDevices[].holidayModeSensor",
2581
- "accounts[].ervDevices[].scheduleSensor",
2582
2489
  "accounts[].ervDevices[].errorSensor"
2583
2490
  ]
2584
2491
  },
@@ -2632,7 +2539,6 @@
2632
2539
  "title": "{{ value.name }}",
2633
2540
  "items": [
2634
2541
  {
2635
- "key": "accounts[]",
2636
2542
  "title": "Account Data Refresh",
2637
2543
  "items": [
2638
2544
  "accounts[].refreshInterval"
@@ -2651,7 +2557,6 @@
2651
2557
  ]
2652
2558
  },
2653
2559
  {
2654
- "key": "accounts[]",
2655
2560
  "title": "External Integrations",
2656
2561
  "items": [
2657
2562
  {
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.1",
4
+ "version": "4.1.3-beta.10",
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
@@ -31,8 +31,6 @@ class DeviceAta extends EventEmitter {
31
31
  this.temperatureOutdoorSensor = device.temperatureOutdoorSensor || false;
32
32
  this.frostProtectionSensor = device.frostProtectionSensor || false;
33
33
  this.overheatProtectionSensor = device.overheatProtectionSensor || false;
34
- this.holidayModeSensor = device.holidayModeSensor || false;
35
- this.scheduleSensor = device.scheduleSensor || false;
36
34
  this.errorSensor = device.errorSensor || false;
37
35
  this.heatDryFanMode = device.heatDryFanMode || 1; //NONE, HEAT, DRY, FAN
38
36
  this.coolDryFanMode = device.coolDryFanMode || 1; //NONE, COOL, DRY, FAN
@@ -65,8 +63,8 @@ class DeviceAta extends EventEmitter {
65
63
  //schedules configured
66
64
  for (const schedule of this.schedules) {
67
65
  schedule.name = schedule.name || 'Schedule'
68
- schedule.serviceType = [null, Service.Outlet, Service.Switch, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][schedule.displayType];
69
- schedule.characteristicType = [null, Characteristic.On, Characteristic.On, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][schedule.displayType];
66
+ schedule.serviceType = [null, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][schedule.displayType];
67
+ schedule.characteristicType = [null, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][schedule.displayType];
70
68
  schedule.state = false;
71
69
  }
72
70
 
@@ -647,9 +645,29 @@ class DeviceAta extends EventEmitter {
647
645
  accessory.addService(this.overheatProtectionSensorService);
648
646
  }
649
647
 
650
- //holiday mode sensor
651
- if (this.holidayModeSensor && this.accessory.holidayModeEnabled !== null) {
652
- if (this.logDebug) this.emit('debug', `Prepare holiday mode service`);
648
+ //holiday mode
649
+ if (this.accessory.holidayModeEnabled !== null) {
650
+ if (this.logDebug) this.emit('debug', `Prepare holiday mode control service`);
651
+ this.holidayModeControlService = new Service.Switch(serviceName, `Holiday Mode Control ${deviceId} ${i}`);
652
+ this.holidayModeControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
653
+ this.holidayModeControlService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Holiday Mode Control`);
654
+ this.holidayModeControlService.getCharacteristic(Characteristic.On)
655
+ .onGet(async () => {
656
+ const state = this.accessory.holidayModeEnabled;
657
+ return state;
658
+ })
659
+ .onSet(async (state) => {
660
+ try {
661
+ deviceData.HolidayMode.Enabled = state;
662
+ await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'holidaymode');
663
+ if (this.logInfo) this.emit('info', `Holiday mode: ${state ? 'Enabled' : 'Disabled'}`);
664
+ } catch (error) {
665
+ if (this.logWarn) this.emit('warn', `Set holiday mode error: ${error}`);
666
+ };
667
+ });
668
+ accessory.addService(this.holidayModeControlService);
669
+
670
+ if (this.logDebug) this.emit('debug', `Prepare holiday mode sensor service`);
653
671
  this.holidayModeSensorService = new Service.ContactSensor(`${serviceName} Holiday Mode`, `Holiday Mode Sensor ${deviceId}`);
654
672
  this.holidayModeSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
655
673
  this.holidayModeSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Holiday Mode`);
@@ -661,20 +679,6 @@ class DeviceAta extends EventEmitter {
661
679
  accessory.addService(this.holidayModeSensorService);
662
680
  }
663
681
 
664
- //schedule sensor
665
- if (this.scheduleSensor && this.accessory.scheduleEnabled !== null) {
666
- if (this.logDebug) this.emit('debug', `Prepare schedule service`);
667
- this.scheduleSensorService = new Service.ContactSensor(`${serviceName} Schedule`, `Schedule Sensor ${deviceId}`);
668
- this.scheduleSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
669
- this.scheduleSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Schedule`);
670
- this.scheduleSensorService.getCharacteristic(Characteristic.ContactSensorState)
671
- .onGet(async () => {
672
- const state = this.accessory.scheduleEnabled;
673
- return state;
674
- })
675
- accessory.addService(this.scheduleSensorService);
676
- }
677
-
678
682
  //error sensor
679
683
  if (this.errorSensor && this.accessory.isInError !== null) {
680
684
  if (this.logDebug) this.emit('debug', `Prepare error service`);
@@ -747,7 +751,7 @@ class DeviceAta extends EventEmitter {
747
751
  };
748
752
 
749
753
  //schedules services
750
- if (this.schedules.length > 0) {
754
+ if (this.schedules.length > 0 && this.accessory.scheduleEnabled !== null) {
751
755
  if (this.logDebug) this.emit('debug', `Prepare schedules services`);
752
756
  this.schedulesServices = [];
753
757
  this.schedules.forEach((schedule, i) => {
@@ -757,25 +761,52 @@ class DeviceAta extends EventEmitter {
757
761
  //get preset name prefix
758
762
  const namePrefix = schedule.namePrefix;
759
763
 
764
+ //control
765
+ if (i === 0) {
766
+ if (this.logDebug) this.emit('debug', `Prepare schedule control service`);
767
+ const serviceNameSchedule = namePrefix ? `${accessoryName} Schedule Control` : `Schedule Control`;
768
+ this.schedulesControlService = new Service.Switch(serviceNameSchedule, `Schedule Control ${deviceId} ${i}`);
769
+ this.schedulesControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
770
+ this.schedulesControlService.setCharacteristic(Characteristic.ConfiguredName, serviceNameSchedule);
771
+ this.schedulesControlService.getCharacteristic(Characteristic.On)
772
+ .onGet(async () => {
773
+ const state = this.accessory.scheduleEnabled;
774
+ return state;
775
+ })
776
+ .onSet(async (state) => {
777
+ try {
778
+ deviceData.ScheduleEnabled = state;
779
+ await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'scheduleenabled');
780
+ if (this.logInfo) this.emit('info', `Schedule: ${state ? 'Enabled' : 'Disabled'}`);
781
+ } catch (error) {
782
+ if (this.logWarn) this.emit('warn', `Set schedule error: ${error}`);
783
+ };
784
+ });
785
+ accessory.addService(this.schedulesControlService);
786
+
787
+ if (this.logDebug) this.emit('debug', `Prepare schedule control sensor service`);
788
+ this.scheduleSensorService = new Service.ContactSensor(serviceNameSchedule, `Schedule Control Sensor ${deviceId}`);
789
+ this.scheduleSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
790
+ this.scheduleSensorService.setCharacteristic(Characteristic.ConfiguredName, serviceNameSchedule);
791
+ this.scheduleSensorService.getCharacteristic(Characteristic.ContactSensorState)
792
+ .onGet(async () => {
793
+ const state = this.accessory.scheduleEnabled;
794
+ return state;
795
+ })
796
+ accessory.addService(this.scheduleSensorService);
797
+ }
798
+
799
+ //sensors
760
800
  const serviceName = namePrefix ? `${accessoryName} ${name}` : name;
761
801
  const serviceType = schedule.serviceType;
762
802
  const characteristicType = schedule.characteristicType;
763
- const scheduleService = new serviceType(serviceName, `Schedule ${deviceId} ${i}`);
803
+ const scheduleService = new serviceType(serviceName, `Schedule Sensor ${deviceId} ${i}`);
764
804
  scheduleService.addOptionalCharacteristic(Characteristic.ConfiguredName);
765
805
  scheduleService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
766
806
  scheduleService.getCharacteristic(characteristicType)
767
807
  .onGet(async () => {
768
808
  const state = schedule.state;
769
809
  return state;
770
- })
771
- .onSet(async (state) => {
772
- try {
773
- deviceData.ScheduleEnabled = state;
774
- await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'scheduleenabled');
775
- if (this.logInfo) this.emit('info', `${state ? 'Set:' : 'Unset:'} ${name}`);
776
- } catch (error) {
777
- if (this.logWarn) this.emit('warn', `Set schedule error: ${error}`);
778
- };
779
810
  });
780
811
  this.schedulesServices.push(scheduleService);
781
812
  accessory.addService(scheduleService);
@@ -1073,14 +1104,13 @@ class DeviceAta extends EventEmitter {
1073
1104
  const supportDryKey = this.accountType === 'melcloud' ? 'ModelSupportsDry' : 'HasDryOperationMode';
1074
1105
  const supportCoolKey = this.accountType === 'melcloud' ? 'ModelSupportsCool' : 'HasCoolOperationMode';
1075
1106
 
1076
- //presets schedule
1107
+ //presets schedules
1077
1108
  const scheduleEnabled = deviceData.ScheduleEnabled;
1078
1109
  const schedulesOnServer = deviceData.Schedule ?? [];
1079
1110
  const presetsOnServer = deviceData.Presets ?? [];
1080
1111
  const holidayModeEnabled = deviceData.HolidayMode?.Enabled;
1081
1112
  const holidayModeActive = deviceData.HolidayMode?.Active;
1082
1113
 
1083
-
1084
1114
  //protection
1085
1115
  const frostProtectionEnabled = deviceData.FrostProtection?.Enabled;
1086
1116
  const frostProtectionActive = deviceData.FrostProtection?.Active;
@@ -1323,8 +1353,8 @@ class DeviceAta extends EventEmitter {
1323
1353
  this.outdoorTemperatureSensorService?.updateCharacteristic(Characteristic.CurrentTemperature, outdoorTemperature);
1324
1354
  this.frostProtectionSensorService?.updateCharacteristic(Characteristic.ContactSensorState, frostProtectionActive);
1325
1355
  this.overheatProtectionSensorService?.updateCharacteristic(Characteristic.ContactSensorState, overheatProtectionActive);
1356
+ this.holidayModeControlService?.updateCharacteristic(Characteristic.ContactSensorState, holidayModeEnabled);
1326
1357
  this.holidayModeSensorService?.updateCharacteristic(Characteristic.ContactSensorState, holidayModeActive);
1327
- this.scheduleSensorService?.updateCharacteristic(Characteristic.ContactSensorState, scheduleEnabled);
1328
1358
  this.errorService?.updateCharacteristic(Characteristic.ContactSensorState, isInError);
1329
1359
 
1330
1360
  //update presets state
@@ -1345,10 +1375,14 @@ class DeviceAta extends EventEmitter {
1345
1375
  };
1346
1376
 
1347
1377
  //update schedules state
1348
- if (this.schedules.length > 0) {
1378
+ if (this.schedules.length > 0 && scheduleEnabled !== null) {
1349
1379
  this.schedules.forEach((schedule, i) => {
1380
+ //control
1381
+ if (i === 0) this.schedulesControlService?.updateCharacteristic(Characteristic.On, scheduleEnabled);
1382
+
1383
+ //sensors
1350
1384
  const scheduleData = schedulesOnServer.find(s => s[presetsIdKey] === schedule.id);
1351
- schedule.state = scheduleEnabled; //scheduleData.Enabled : false;
1385
+ schedule.state = scheduleEnabled ? scheduleData.Enabled ?? false : false;
1352
1386
 
1353
1387
  const characteristicType = schedule.characteristicType;
1354
1388
  this.schedulesServices?.[i]?.updateCharacteristic(characteristicType, schedule.state);
package/src/deviceatw.js CHANGED
@@ -37,8 +37,6 @@ class DeviceAtw extends EventEmitter {
37
37
  this.temperatureReturnWaterTankSensor = device.temperatureReturnWaterTankSensor || false;
38
38
  this.temperatureFlowZone2Sensor = device.temperatureFlowZone2Sensor || false;
39
39
  this.temperatureReturnZone2Sensor = device.temperatureReturnZone2Sensor || false;
40
- this.holidayModeSensor = device.holidayModeSensor || false;
41
- this.scheduleSensor = device.scheduleSensor || false;
42
40
  this.errorSensor = device.errorSensor || false;
43
41
  this.presets = this.accountType === 'melcloud' ? (device.presets || []).filter(preset => (preset.displayType ?? 0) > 0 && preset.id !== '0') : [];
44
42
  this.schedules = this.accountType === 'melcloudhome' ? (device.schedules || []).filter(schedule => (schedule.displayType ?? 0) > 0 && schedule.id !== '0') : [];
@@ -68,8 +66,8 @@ class DeviceAtw extends EventEmitter {
68
66
  //schedules configured
69
67
  for (const schedule of this.schedules) {
70
68
  schedule.name = schedule.name || 'Schedule'
71
- schedule.serviceType = [null, Service.Outlet, Service.Switch, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][schedule.displayType];
72
- schedule.characteristicType = [null, Characteristic.On, Characteristic.On, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][schedule.displayType];
69
+ schedule.serviceType = [null, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][schedule.displayType];
70
+ schedule.characteristicType = [null, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][schedule.displayType];
73
71
  schedule.state = false;
74
72
  }
75
73
 
@@ -1049,9 +1047,29 @@ class DeviceAtw extends EventEmitter {
1049
1047
  });
1050
1048
  };
1051
1049
 
1052
- //holiday mode sensor
1053
- if (this.holidayModeSensor && this.accessory.holidayModeEnabled !== null) {
1054
- if (this.logDebug) this.emit('debug', `Prepare holiday mode service`);
1050
+ //holiday mode
1051
+ if (this.accessory.holidayModeEnabled !== null) {
1052
+ if (this.logDebug) this.emit('debug', `Prepare holiday mode control service`);
1053
+ this.holidayModeControlService = new Service.Switch(serviceName, `Holiday Mode Control ${deviceId} ${i}`);
1054
+ this.holidayModeControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
1055
+ this.holidayModeControlService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Holiday Mode Control`);
1056
+ this.holidayModeControlService.getCharacteristic(Characteristic.On)
1057
+ .onGet(async () => {
1058
+ const state = this.accessory.holidayModeEnabled;
1059
+ return state;
1060
+ })
1061
+ .onSet(async (state) => {
1062
+ try {
1063
+ deviceData.HolidayMode.Enabled = state;
1064
+ await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'holidaymode');
1065
+ if (this.logInfo) this.emit('info', `Holiday mode: ${state ? 'Enabled' : 'Disabled'}`);
1066
+ } catch (error) {
1067
+ if (this.logWarn) this.emit('warn', `Set holiday mode error: ${error}`);
1068
+ };
1069
+ });
1070
+ accessory.addService(this.holidayModeControlService);
1071
+
1072
+ if (this.logDebug) this.emit('debug', `Prepare holiday mode sensor service`);
1055
1073
  this.holidayModeSensorService = new Service.ContactSensor(`${serviceName} Holiday Mode`, `Holiday Mode Sensor ${deviceId}`);
1056
1074
  this.holidayModeSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
1057
1075
  this.holidayModeSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Holiday Mode`);
@@ -1063,20 +1081,6 @@ class DeviceAtw extends EventEmitter {
1063
1081
  accessory.addService(this.holidayModeSensorService);
1064
1082
  }
1065
1083
 
1066
- //schedule sensor
1067
- if (this.scheduleSensor && this.accessory.scheduleEnabled !== null) {
1068
- if (this.logDebug) this.emit('debug', `Prepare schedule service`);
1069
- this.scheduleSensorService = new Service.ContactSensor(`${serviceName} Schedule`, `Schedule Sensor ${deviceId}`);
1070
- this.scheduleSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
1071
- this.scheduleSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Schedule`);
1072
- this.scheduleSensorService.getCharacteristic(Characteristic.ContactSensorState)
1073
- .onGet(async () => {
1074
- const state = this.accessory.scheduleEnabled;
1075
- return state;
1076
- })
1077
- accessory.addService(this.scheduleSensorService);
1078
- }
1079
-
1080
1084
  //error sensor
1081
1085
  if (this.errorSensor && this.accessory.isInError !== null) {
1082
1086
  if (this.logDebug) this.emit('debug', `Prepare error service`);
@@ -1162,7 +1166,7 @@ class DeviceAtw extends EventEmitter {
1162
1166
  };
1163
1167
 
1164
1168
  //schedules services
1165
- if (this.schedules.length > 0) {
1169
+ if (this.schedules.length > 0 && this.accessory.scheduleEnabled !== null) {
1166
1170
  if (this.logDebug) this.emit('debug', `Prepare schedules services`);
1167
1171
  this.schedulesServices = [];
1168
1172
  this.schedules.forEach((schedule, i) => {
@@ -1172,25 +1176,52 @@ class DeviceAtw extends EventEmitter {
1172
1176
  //get preset name prefix
1173
1177
  const namePrefix = schedule.namePrefix;
1174
1178
 
1179
+ //control
1180
+ if (i === 0) {
1181
+ if (this.logDebug) this.emit('debug', `Prepare schedule control service`);
1182
+ const serviceNameSchedule = namePrefix ? `${accessoryName} Schedule Control` : `Schedule Control`;
1183
+ this.schedulesControlService = new Service.Switch(serviceNameSchedule, `Schedule Control ${deviceId} ${i}`);
1184
+ this.schedulesControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
1185
+ this.schedulesControlService.setCharacteristic(Characteristic.ConfiguredName, serviceNameSchedule);
1186
+ this.schedulesControlService.getCharacteristic(Characteristic.On)
1187
+ .onGet(async () => {
1188
+ const state = this.accessory.scheduleEnabled;
1189
+ return state;
1190
+ })
1191
+ .onSet(async (state) => {
1192
+ try {
1193
+ deviceData.ScheduleEnabled = state;
1194
+ await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'scheduleenabled');
1195
+ if (this.logInfo) this.emit('info', `Schedule: ${state ? 'Enabled' : 'Disabled'}`);
1196
+ } catch (error) {
1197
+ if (this.logWarn) this.emit('warn', `Set schedule error: ${error}`);
1198
+ };
1199
+ });
1200
+ accessory.addService(this.schedulesControlService);
1201
+
1202
+ if (this.logDebug) this.emit('debug', `Prepare schedule control sensor service`);
1203
+ this.scheduleSensorService = new Service.ContactSensor(serviceNameSchedule, `Schedule Control Sensor ${deviceId}`);
1204
+ this.scheduleSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
1205
+ this.scheduleSensorService.setCharacteristic(Characteristic.ConfiguredName, serviceNameSchedule);
1206
+ this.scheduleSensorService.getCharacteristic(Characteristic.ContactSensorState)
1207
+ .onGet(async () => {
1208
+ const state = this.accessory.scheduleEnabled;
1209
+ return state;
1210
+ })
1211
+ accessory.addService(this.scheduleSensorService);
1212
+ }
1213
+
1214
+ //sensors
1175
1215
  const serviceName = namePrefix ? `${accessoryName} ${name}` : name;
1176
1216
  const serviceType = schedule.serviceType;
1177
1217
  const characteristicType = schedule.characteristicType;
1178
- const scheduleService = new serviceType(serviceName, `Schedule ${deviceId} ${i}`);
1218
+ const scheduleService = new serviceType(serviceName, `Schedule Sensor ${deviceId} ${i}`);
1179
1219
  scheduleService.addOptionalCharacteristic(Characteristic.ConfiguredName);
1180
1220
  scheduleService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
1181
1221
  scheduleService.getCharacteristic(characteristicType)
1182
1222
  .onGet(async () => {
1183
1223
  const state = schedule.state;
1184
1224
  return state;
1185
- })
1186
- .onSet(async (state) => {
1187
- try {
1188
- deviceData.ScheduleEnabled = state;
1189
- await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'scheduleenabled');
1190
- if (this.logInfo) this.emit('info', `${state ? 'Set:' : 'Unset:'} ${name}`);
1191
- } catch (error) {
1192
- if (this.logWarn) this.emit('warn', `Set schedule error: ${error}`);
1193
- };
1194
1225
  });
1195
1226
  this.schedulesServices.push(scheduleService);
1196
1227
  accessory.addService(scheduleService);
@@ -1900,8 +1931,8 @@ class DeviceAtw extends EventEmitter {
1900
1931
  this.accessory = obj;
1901
1932
 
1902
1933
  //update sensors state
1934
+ this.holidayModeControlService?.updateCharacteristic(Characteristic.ContactSensorState, holidayModeEnabled);
1903
1935
  this.holidayModeSensorService?.updateCharacteristic(Characteristic.ContactSensorState, holidayModeActive);
1904
- this.scheduleSensorService?.updateCharacteristic(Characteristic.ContactSensorState, scheduleEnabled);
1905
1936
  this.errorService?.updateCharacteristic(Characteristic.ContactSensorState, isInError);
1906
1937
 
1907
1938
  //update presets state
@@ -1928,10 +1959,14 @@ class DeviceAtw extends EventEmitter {
1928
1959
  };
1929
1960
 
1930
1961
  //update schedules state
1931
- if (this.schedules.length > 0) {
1962
+ if (this.schedules.length > 0 && scheduleEnabled !== null) {
1932
1963
  this.schedules.forEach((schedule, i) => {
1964
+ //control
1965
+ if (i === 0) this.schedulesControlService?.updateCharacteristic(Characteristic.On, scheduleEnabled);
1966
+
1967
+ //sensors
1933
1968
  const scheduleData = schedulesOnServer.find(s => s[presetsIdKey] === schedule.id);
1934
- schedule.state = scheduleEnabled; //scheduleData.Enabled : false;
1969
+ schedule.state = scheduleEnabled ? scheduleData.Enabled ?? false : false;
1935
1970
 
1936
1971
  const characteristicType = schedule.characteristicType;
1937
1972
  this.schedulesServices?.[i]?.updateCharacteristic(characteristicType, schedule.state);
package/src/deviceerv.js CHANGED
@@ -30,8 +30,6 @@ class DeviceErv extends EventEmitter {
30
30
  this.temperatureSensor = device.temperatureSensor || false;
31
31
  this.temperatureOutdoorSensor = device.temperatureOutdoorSensor || false;
32
32
  this.temperatureSupplySensor = device.temperatureSupplySensor || false;
33
- this.holidayModeSensor = device.holidayModeSensor || false;
34
- this.scheduleSensor = device.scheduleSensor || false;
35
33
  this.errorSensor = device.errorSensor || false;
36
34
  this.presets = this.accountType === 'melcloud' ? (device.presets || []).filter(preset => (preset.displayType ?? 0) > 0 && preset.id !== '0') : [];
37
35
  this.schedules = this.accountType === 'melcloudhome' ? (device.schedules || []).filter(schedule => (schedule.displayType ?? 0) > 0 && schedule.id !== '0') : [];
@@ -61,8 +59,8 @@ class DeviceErv extends EventEmitter {
61
59
  //schedules configured
62
60
  for (const schedule of this.schedules) {
63
61
  schedule.name = schedule.name || 'Schedule'
64
- schedule.serviceType = [null, Service.Outlet, Service.Switch, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][schedule.displayType];
65
- schedule.characteristicType = [null, Characteristic.On, Characteristic.On, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][schedule.displayType];
62
+ schedule.serviceType = [null, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][schedule.displayType];
63
+ schedule.characteristicType = [null, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][schedule.displayType];
66
64
  schedule.state = false;
67
65
  }
68
66
 
@@ -668,9 +666,29 @@ class DeviceErv extends EventEmitter {
668
666
  accessory.addService(this.airQualitySensorService);
669
667
  }
670
668
 
671
- //holiday mode sensor
672
- if (this.holidayModeSensor && this.accessory.holidayModeEnabled !== null) {
673
- if (this.logDebug) this.emit('debug', `Prepare holiday mode service`);
669
+ //holiday mode
670
+ if (this.accessory.holidayModeEnabled !== null) {
671
+ if (this.logDebug) this.emit('debug', `Prepare holiday mode control service`);
672
+ this.holidayModeControlService = new Service.Switch(serviceName, `Holiday Mode Control ${deviceId} ${i}`);
673
+ this.holidayModeControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
674
+ this.holidayModeControlService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Holiday Mode Control`);
675
+ this.holidayModeControlService.getCharacteristic(Characteristic.On)
676
+ .onGet(async () => {
677
+ const state = this.accessory.holidayModeEnabled;
678
+ return state;
679
+ })
680
+ .onSet(async (state) => {
681
+ try {
682
+ deviceData.HolidayMode.Enabled = state;
683
+ await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'holidaymode');
684
+ if (this.logInfo) this.emit('info', `Holiday mode: ${state ? 'Enabled' : 'Disabled'}`);
685
+ } catch (error) {
686
+ if (this.logWarn) this.emit('warn', `Set holiday mode error: ${error}`);
687
+ };
688
+ });
689
+ accessory.addService(this.holidayModeControlService);
690
+
691
+ if (this.logDebug) this.emit('debug', `Prepare holiday mode sensor service`);
674
692
  this.holidayModeSensorService = new Service.ContactSensor(`${serviceName} Holiday Mode`, `Holiday Mode Sensor ${deviceId}`);
675
693
  this.holidayModeSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
676
694
  this.holidayModeSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Holiday Mode`);
@@ -682,20 +700,6 @@ class DeviceErv extends EventEmitter {
682
700
  accessory.addService(this.holidayModeSensorService);
683
701
  }
684
702
 
685
- //schedule sensor
686
- if (this.scheduleSensor && this.accessory.scheduleEnabled !== null) {
687
- if (this.logDebug) this.emit('debug', `Prepare schedule service`);
688
- this.scheduleSensorService = new Service.ContactSensor(`${serviceName} Schedule`, `Schedule Sensor ${deviceId}`);
689
- this.scheduleSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
690
- this.scheduleSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Schedule`);
691
- this.scheduleSensorService.getCharacteristic(Characteristic.ContactSensorState)
692
- .onGet(async () => {
693
- const state = this.accessory.scheduleEnabled;
694
- return state;
695
- })
696
- accessory.addService(this.scheduleSensorService);
697
- }
698
-
699
703
  //error sensor
700
704
  if (this.errorSensor && this.accessory.isInError !== null) {
701
705
  if (this.logDebug) this.emit('debug', `Prepare error service`);
@@ -766,7 +770,7 @@ class DeviceErv extends EventEmitter {
766
770
  };
767
771
 
768
772
  //schedules services
769
- if (this.schedules.length > 0) {
773
+ if (this.schedules.length > 0 && this.accessory.scheduleEnabled !== null) {
770
774
  if (this.logDebug) this.emit('debug', `Prepare schedules services`);
771
775
  this.schedulesServices = [];
772
776
  this.schedules.forEach((schedule, i) => {
@@ -776,25 +780,52 @@ class DeviceErv extends EventEmitter {
776
780
  //get preset name prefix
777
781
  const namePrefix = schedule.namePrefix;
778
782
 
783
+ //control
784
+ if (i === 0) {
785
+ if (this.logDebug) this.emit('debug', `Prepare schedule control service`);
786
+ const serviceNameSchedule = namePrefix ? `${accessoryName} Schedule Control` : `Schedule Control`;
787
+ this.schedulesControlService = new Service.Switch(serviceNameSchedule, `Schedule Control ${deviceId} ${i}`);
788
+ this.schedulesControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
789
+ this.schedulesControlService.setCharacteristic(Characteristic.ConfiguredName, serviceNameSchedule);
790
+ this.schedulesControlService.getCharacteristic(Characteristic.On)
791
+ .onGet(async () => {
792
+ const state = this.accessory.scheduleEnabled;
793
+ return state;
794
+ })
795
+ .onSet(async (state) => {
796
+ try {
797
+ deviceData.ScheduleEnabled = state;
798
+ await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'scheduleenabled');
799
+ if (this.logInfo) this.emit('info', `Schedule: ${state ? 'Enabled' : 'Disabled'}`);
800
+ } catch (error) {
801
+ if (this.logWarn) this.emit('warn', `Set schedule error: ${error}`);
802
+ };
803
+ });
804
+ accessory.addService(this.schedulesControlService);
805
+
806
+ if (this.logDebug) this.emit('debug', `Prepare schedule control sensor service`);
807
+ this.scheduleSensorService = new Service.ContactSensor(serviceNameSchedule, `Schedule Control Sensor ${deviceId}`);
808
+ this.scheduleSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
809
+ this.scheduleSensorService.setCharacteristic(Characteristic.ConfiguredName, serviceNameSchedule);
810
+ this.scheduleSensorService.getCharacteristic(Characteristic.ContactSensorState)
811
+ .onGet(async () => {
812
+ const state = this.accessory.scheduleEnabled;
813
+ return state;
814
+ })
815
+ accessory.addService(this.scheduleSensorService);
816
+ }
817
+
818
+ //sensors
779
819
  const serviceName = namePrefix ? `${accessoryName} ${name}` : name;
780
820
  const serviceType = schedule.serviceType;
781
821
  const characteristicType = schedule.characteristicType;
782
- const scheduleService = new serviceType(serviceName, `Schedule ${deviceId} ${i}`);
822
+ const scheduleService = new serviceType(serviceName, `Schedule Sensor ${deviceId} ${i}`);
783
823
  scheduleService.addOptionalCharacteristic(Characteristic.ConfiguredName);
784
824
  scheduleService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
785
825
  scheduleService.getCharacteristic(characteristicType)
786
826
  .onGet(async () => {
787
827
  const state = schedule.state;
788
828
  return state;
789
- })
790
- .onSet(async (state) => {
791
- try {
792
- deviceData.ScheduleEnabled = state;
793
- await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'scheduleenabled');
794
- if (this.logInfo) this.emit('info', `${state ? 'Set:' : 'Unset:'} ${name}`);
795
- } catch (error) {
796
- if (this.logWarn) this.emit('warn', `Set schedule error: ${error}`);
797
- };
798
829
  });
799
830
  this.schedulesServices.push(scheduleService);
800
831
  accessory.addService(scheduleService);
@@ -1194,8 +1225,8 @@ class DeviceErv extends EventEmitter {
1194
1225
  .updateCharacteristic(Characteristic.PM2_5Density, pM25Level);
1195
1226
 
1196
1227
  //error sensor
1228
+ this.holidayModeControlService?.updateCharacteristic(Characteristic.ContactSensorState, holidayModeEnabled);
1197
1229
  this.holidayModeSensorService?.updateCharacteristic(Characteristic.ContactSensorState, holidayModeActive);
1198
- this.scheduleSensorService?.updateCharacteristic(Characteristic.ContactSensorState, scheduleEnabled);
1199
1230
  this.errorService?.updateCharacteristic(Characteristic.ContactSensorState, isInError);
1200
1231
 
1201
1232
  //update presets state
@@ -1215,10 +1246,14 @@ class DeviceErv extends EventEmitter {
1215
1246
  };
1216
1247
 
1217
1248
  //update schedules state
1218
- if (this.schedules.length > 0) {
1249
+ if (this.schedules.length > 0 && scheduleEnabled !== null) {
1219
1250
  this.schedules.forEach((schedule, i) => {
1251
+ //control
1252
+ if (i === 0) this.schedulesControlService?.updateCharacteristic(Characteristic.On, scheduleEnabled);
1253
+
1254
+ //sensors
1220
1255
  const scheduleData = schedulesOnServer.find(s => s[presetsIdKey] === schedule.id);
1221
- schedule.state = scheduleEnabled; //scheduleData.Enabled : false;
1256
+ schedule.state = scheduleEnabled ? scheduleData.Enabled ?? false : false;
1222
1257
 
1223
1258
  const characteristicType = schedule.characteristicType;
1224
1259
  this.schedulesServices?.[i]?.updateCharacteristic(characteristicType, schedule.state);
package/src/melcloud.js CHANGED
@@ -168,7 +168,7 @@ class MelCloud extends EventEmitter {
168
168
  const loginData = account.LoginData ?? [];
169
169
  const contextKey = loginData.ContextKey;
170
170
 
171
- const debugData = {
171
+ const safeConfig = {
172
172
  ...loginData,
173
173
  ContextKey: 'removed',
174
174
  ClientId: 'removed',
@@ -177,7 +177,7 @@ class MelCloud extends EventEmitter {
177
177
  MapLongitude: 'removed',
178
178
  MapLatitude: 'removed'
179
179
  };
180
- if (this.logDebug) this.emit('debug', `MELCloud Info: ${JSON.stringify(debugData, null, 2)}`);
180
+ if (this.logDebug) this.emit('debug', `MELCloud Info: ${JSON.stringify(safeConfig, null, 2)}`);
181
181
 
182
182
  if (!contextKey) {
183
183
  accountInfo.Info = 'Context key missing'
@@ -203,19 +203,33 @@ class MelCloudAta extends EventEmitter {
203
203
  }
204
204
  }
205
205
 
206
- const settings = effectiveFlags === 'scheduleenabled' ? { data: { enabled: deviceData.ScheduleEnabled } } : {
207
- data: {
208
- Power: deviceData.Device.Power,
209
- SetTemperature: deviceData.Device.SetTemperature,
210
- SetFanSpeed: String(deviceData.Device.SetFanSpeed),
211
- OperationMode: AirConditioner.OperationModeMapEnumToString[deviceData.Device.OperationMode],
212
- VaneHorizontalDirection: AirConditioner.VaneHorizontalDirectionMapEnumToString[deviceData.Device.VaneHorizontalDirection],
213
- VaneVerticalDirection: AirConditioner.VaneVerticalDirectionMapEnumToString[deviceData.Device.VaneVerticalDirection],
214
- }
215
- };
216
- if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(settings.data, null, 2)}`);
206
+ let settings = {};
207
+ let path = '';
208
+ switch (effectiveFlags) {
209
+ case 'scheduleenabled':
210
+ settings = {
211
+ data: {
212
+ enabled: deviceData.ScheduleEnabled
213
+ }
214
+ };
215
+ path = ApiUrlsHome.PutScheduleEnable.replace('deviceid', deviceData.DeviceID);
216
+ break;
217
+ default:
218
+ settings = {
219
+ data: {
220
+ Power: deviceData.Device.Power,
221
+ SetTemperature: deviceData.Device.SetTemperature,
222
+ SetFanSpeed: String(deviceData.Device.SetFanSpeed),
223
+ OperationMode: AirConditioner.OperationModeMapEnumToString[deviceData.Device.OperationMode],
224
+ VaneHorizontalDirection: AirConditioner.VaneHorizontalDirectionMapEnumToString[deviceData.Device.VaneHorizontalDirection],
225
+ VaneVerticalDirection: AirConditioner.VaneVerticalDirectionMapEnumToString[deviceData.Device.VaneVerticalDirection],
226
+ }
227
+ };
228
+ path = ApiUrlsHome.SetAta.replace('deviceid', deviceData.DeviceID);
229
+ break
230
+ }
217
231
 
218
- const path = effectiveFlags === 'scheduleenabled' ? ApiUrlsHome.PutScheduleEnable.replace('deviceid', deviceData.DeviceID) : ApiUrlsHome.SetAta.replace('deviceid', deviceData.DeviceID);
232
+ if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(settings.data, null, 2)}`);
219
233
  await axiosInstancePut(path, settings);
220
234
  this.updateData(deviceData);
221
235
  return true;
@@ -223,11 +237,7 @@ class MelCloudAta extends EventEmitter {
223
237
  return;
224
238
  }
225
239
  } catch (error) {
226
- // Return 500 for schedule hovewer working correct
227
- if (error?.response?.status === 500) {
228
- return true;
229
- }
230
-
240
+ if (error.response?.status === 500) return true; // Return 500 for schedule hovewer working correct
231
241
  throw new Error(`Send data error: ${error.message}`);
232
242
  }
233
243
  }
@@ -195,26 +195,40 @@ class MelCloudAtw extends EventEmitter {
195
195
  withCredentials: true
196
196
  });
197
197
 
198
- const settings = effectiveFlags === 'scheduleenabled' ? { data: { enabled: deviceData.ScheduleEnabled } } : {
199
- data: {
200
- Power: deviceData.Device.Power,
201
- SetTemperatureZone1: deviceData.Device.SetTemperatureZone1,
202
- SetTemperatureZone2: deviceData.Device.SetTemperatureZone2,
203
- OperationMode: HeatPump.OperationModeMapEnumToString[deviceData.Device.OperationMode],
204
- OperationModeZone1: HeatPump.OperationModeMapEnumToString[deviceData.Device.OperationModeZone1],
205
- OperationModeZone2: HeatPump.OperationModeMapEnumToString[deviceData.Device.OperationModeZone2],
206
- SetHeatFlowTemperatureZone1: deviceData.Device.SetHeatFlowTemperatureZone1,
207
- SetHeatFlowTemperatureZone2: deviceData.Device.SetHeatFlowTemperatureZone2,
208
- SetCoolFlowTemperatureZone1: deviceData.Device.SetCoolFlowTemperatureZone1,
209
- SetCoolFlowTemperatureZone2: deviceData.Device.SetCoolFlowTemperatureZone2,
210
- SetTankWaterTemperature: deviceData.Device.SetTankWaterTemperature,
211
- ForcedHotWaterMode: deviceData.Device.ForcedHotWaterMode,
212
- EcoHotWater: deviceData.Device.EcoHotWater,
213
- }
214
- };
215
- if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(settings.data, null, 2)}`);
198
+ let settings = {};
199
+ let path = '';
200
+ switch (effectiveFlags) {
201
+ case 'scheduleenabled':
202
+ settings = {
203
+ data: {
204
+ enabled: deviceData.ScheduleEnabled
205
+ }
206
+ };
207
+ path = ApiUrlsHome.PutScheduleEnable.replace('deviceid', deviceData.DeviceID);
208
+ break;
209
+ default:
210
+ settings = {
211
+ data: {
212
+ Power: deviceData.Device.Power,
213
+ SetTemperatureZone1: deviceData.Device.SetTemperatureZone1,
214
+ SetTemperatureZone2: deviceData.Device.SetTemperatureZone2,
215
+ OperationMode: HeatPump.OperationModeMapEnumToString[deviceData.Device.OperationMode],
216
+ OperationModeZone1: HeatPump.OperationModeMapEnumToString[deviceData.Device.OperationModeZone1],
217
+ OperationModeZone2: HeatPump.OperationModeMapEnumToString[deviceData.Device.OperationModeZone2],
218
+ SetHeatFlowTemperatureZone1: deviceData.Device.SetHeatFlowTemperatureZone1,
219
+ SetHeatFlowTemperatureZone2: deviceData.Device.SetHeatFlowTemperatureZone2,
220
+ SetCoolFlowTemperatureZone1: deviceData.Device.SetCoolFlowTemperatureZone1,
221
+ SetCoolFlowTemperatureZone2: deviceData.Device.SetCoolFlowTemperatureZone2,
222
+ SetTankWaterTemperature: deviceData.Device.SetTankWaterTemperature,
223
+ ForcedHotWaterMode: deviceData.Device.ForcedHotWaterMode,
224
+ EcoHotWater: deviceData.Device.EcoHotWater,
225
+ }
226
+ };
227
+ path = ApiUrlsHome.SetAtw.replace('deviceid', deviceData.DeviceID);
228
+ break
229
+ }
216
230
 
217
- const path = effectiveFlags === 'scheduleenabled' ? ApiUrlsHome.PutScheduleEnable.replace('deviceid', deviceData.DeviceID) : ApiUrlsHome.SetAtw.replace('deviceid', deviceData.DeviceID);
231
+ if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(settings.data, null, 2)}`);
218
232
  await axiosInstancePut(path, settings);
219
233
  this.updateData(deviceData);
220
234
  return true;
@@ -222,11 +236,7 @@ class MelCloudAtw extends EventEmitter {
222
236
  return;
223
237
  }
224
238
  } catch (error) {
225
- // Return 500 for schedule hovewer working correct
226
- if (error?.response?.status === 500) {
227
- return true;
228
- }
229
-
239
+ if (error.response?.status === 500) return true; // Return 500 for schedule hovewer working correct
230
240
  throw new Error(`Send data error: ${error.message}`);
231
241
  }
232
242
  }
@@ -211,18 +211,32 @@ class MelCloudErv extends EventEmitter {
211
211
  }
212
212
  }
213
213
 
214
- const settings = effectiveFlags === 'scheduleenabled' ? { data: { enabled: deviceData.ScheduleEnabled } } : {
215
- data: {
216
- Power: deviceData.Device.Power,
217
- SetTemperature: deviceData.Device.SetTemperature,
218
- SetFanSpeed: String(deviceData.Device.SetFanSpeed),
219
- OperationMode: Ventilation.OperationModeMapEnumToString[deviceData.Device.OperationMode],
220
- VentilationMode: Ventilation.VentilationModeMapEnumToString[deviceData.Device.VentilationMode],
221
- }
222
- };
223
- if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(settings.data, null, 2)}`);
214
+ let settings = {};
215
+ let path = '';
216
+ switch (effectiveFlags) {
217
+ case 'scheduleenabled':
218
+ settings = {
219
+ data: {
220
+ enabled: deviceData.ScheduleEnabled
221
+ }
222
+ };
223
+ path = ApiUrlsHome.PutScheduleEnable.replace('deviceid', deviceData.DeviceID);
224
+ break;
225
+ default:
226
+ settings = {
227
+ data: {
228
+ Power: deviceData.Device.Power,
229
+ SetTemperature: deviceData.Device.SetTemperature,
230
+ SetFanSpeed: String(deviceData.Device.SetFanSpeed),
231
+ OperationMode: Ventilation.OperationModeMapEnumToString[deviceData.Device.OperationMode],
232
+ VentilationMode: Ventilation.VentilationModeMapEnumToString[deviceData.Device.VentilationMode],
233
+ }
234
+ };
235
+ path = ApiUrlsHome.SetErv.replace('deviceid', deviceData.DeviceID);
236
+ break
237
+ }
224
238
 
225
- const path = effectiveFlags === 'scheduleenabled' ? ApiUrlsHome.PutScheduleEnable.replace('deviceid', deviceData.DeviceID) : ApiUrlsHome.SetErv.replace('deviceid', deviceData.DeviceID);
239
+ if (this.logDebug) this.emit('debug', `Send Data: ${JSON.stringify(settings.data, null, 2)}`);
226
240
  await axiosInstancePut(path, settings);
227
241
  this.updateData(deviceData);
228
242
  return true;
@@ -230,11 +244,7 @@ class MelCloudErv extends EventEmitter {
230
244
  return;
231
245
  }
232
246
  } catch (error) {
233
- // Return 500 for schedule hovewer working correct
234
- if (error?.response?.status === 500) {
235
- return true;
236
- }
237
-
247
+ if (error.response?.status === 500) return true; // Return 500 for schedule hovewer working correct
238
248
  throw new Error(`Send data error: ${error.message}`);
239
249
  }
240
250
  }