homebridge-melcloud-control 4.2.3-beta.57 → 4.2.3-beta.58

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.
@@ -463,7 +463,7 @@
463
463
  "title": "Display Type",
464
464
  "type": "integer",
465
465
  "minimum": 0,
466
- "maximum": 5,
466
+ "maximum": 6,
467
467
  "default": 0,
468
468
  "description": "Select the characteristic type to be displayed in HomeKit app.",
469
469
  "anyOf": [
@@ -474,34 +474,40 @@
474
474
  ]
475
475
  },
476
476
  {
477
- "title": "Outlet",
477
+ "title": "Motion Sensor",
478
478
  "enum": [
479
479
  1
480
480
  ]
481
481
  },
482
482
  {
483
- "title": "Switch",
483
+ "title": "Occupancy Sensor",
484
484
  "enum": [
485
485
  2
486
486
  ]
487
487
  },
488
488
  {
489
- "title": "Motion Sensor",
489
+ "title": "Contact Sensor",
490
490
  "enum": [
491
491
  3
492
492
  ]
493
493
  },
494
494
  {
495
- "title": "Occupancy Sensor",
495
+ "title": "Switch + Motion Sensor",
496
496
  "enum": [
497
497
  4
498
498
  ]
499
499
  },
500
500
  {
501
- "title": "Contact Sensor",
501
+ "title": "Switch + Occupancy Sensor",
502
502
  "enum": [
503
503
  5
504
504
  ]
505
+ },
506
+ {
507
+ "title": "Switch + Contact Sensor",
508
+ "enum": [
509
+ 6
510
+ ]
505
511
  }
506
512
  ]
507
513
  },
@@ -544,7 +550,7 @@
544
550
  "title": "Display Type",
545
551
  "type": "integer",
546
552
  "minimum": 0,
547
- "maximum": 3,
553
+ "maximum": 6,
548
554
  "default": 0,
549
555
  "description": "Select the characteristic type to be displayed in HomeKit app.",
550
556
  "anyOf": [
@@ -555,22 +561,40 @@
555
561
  ]
556
562
  },
557
563
  {
558
- "title": "Switch + Motion Sensor",
564
+ "title": "Motion Sensor",
559
565
  "enum": [
560
566
  1
561
567
  ]
562
568
  },
563
569
  {
564
- "title": "Switch + Occupancy Sensor",
570
+ "title": "Occupancy Sensor",
565
571
  "enum": [
566
572
  2
567
573
  ]
568
574
  },
569
575
  {
570
- "title": "Switch + Contact Sensor",
576
+ "title": "Contact Sensor",
571
577
  "enum": [
572
578
  3
573
579
  ]
580
+ },
581
+ {
582
+ "title": "Switch + Motion Sensor",
583
+ "enum": [
584
+ 4
585
+ ]
586
+ },
587
+ {
588
+ "title": "Switch + Occupancy Sensor",
589
+ "enum": [
590
+ 5
591
+ ]
592
+ },
593
+ {
594
+ "title": "Switch + Contact Sensor",
595
+ "enum": [
596
+ 6
597
+ ]
574
598
  }
575
599
  ]
576
600
  },
@@ -613,7 +637,7 @@
613
637
  "title": "Display Type",
614
638
  "type": "integer",
615
639
  "minimum": 0,
616
- "maximum": 3,
640
+ "maximum": 6,
617
641
  "default": 0,
618
642
  "description": "Select the characteristic type to be displayed in HomeKit app.",
619
643
  "anyOf": [
@@ -624,22 +648,40 @@
624
648
  ]
625
649
  },
626
650
  {
627
- "title": "Switch + Motion Sensor",
651
+ "title": "Motion Sensor",
628
652
  "enum": [
629
653
  1
630
654
  ]
631
655
  },
632
656
  {
633
- "title": "Switch + Occupancy Sensor",
657
+ "title": "Occupancy Sensor",
634
658
  "enum": [
635
659
  2
636
660
  ]
637
661
  },
638
662
  {
639
- "title": "Switch + Contact Sensor",
663
+ "title": "Contact Sensor",
640
664
  "enum": [
641
665
  3
642
666
  ]
667
+ },
668
+ {
669
+ "title": "Switch + Motion Sensor",
670
+ "enum": [
671
+ 4
672
+ ]
673
+ },
674
+ {
675
+ "title": "Switch + Occupancy Sensor",
676
+ "enum": [
677
+ 5
678
+ ]
679
+ },
680
+ {
681
+ "title": "Switch + Contact Sensor",
682
+ "enum": [
683
+ 6
684
+ ]
643
685
  }
644
686
  ]
645
687
  },
@@ -1238,7 +1280,7 @@
1238
1280
  "title": "Display Type",
1239
1281
  "type": "integer",
1240
1282
  "minimum": 0,
1241
- "maximum": 5,
1283
+ "maximum": 6,
1242
1284
  "default": 0,
1243
1285
  "description": "Select the characteristic type to be displayed in HomeKit app.",
1244
1286
  "anyOf": [
@@ -1249,34 +1291,40 @@
1249
1291
  ]
1250
1292
  },
1251
1293
  {
1252
- "title": "Outlet",
1294
+ "title": "Motion Sensor",
1253
1295
  "enum": [
1254
1296
  1
1255
1297
  ]
1256
1298
  },
1257
1299
  {
1258
- "title": "Switch",
1300
+ "title": "Occupancy Sensor",
1259
1301
  "enum": [
1260
1302
  2
1261
1303
  ]
1262
1304
  },
1263
1305
  {
1264
- "title": "Motion Sensor",
1306
+ "title": "Contact Sensor",
1265
1307
  "enum": [
1266
1308
  3
1267
1309
  ]
1268
1310
  },
1269
1311
  {
1270
- "title": "Occupancy Sensor",
1312
+ "title": "Switch + Motion Sensor",
1271
1313
  "enum": [
1272
1314
  4
1273
1315
  ]
1274
1316
  },
1275
1317
  {
1276
- "title": "Contact Sensor",
1318
+ "title": "Switch + Occupancy Sensor",
1277
1319
  "enum": [
1278
1320
  5
1279
1321
  ]
1322
+ },
1323
+ {
1324
+ "title": "Switch + Contact Sensor",
1325
+ "enum": [
1326
+ 6
1327
+ ]
1280
1328
  }
1281
1329
  ]
1282
1330
  },
@@ -1319,7 +1367,7 @@
1319
1367
  "title": "Display Type",
1320
1368
  "type": "integer",
1321
1369
  "minimum": 0,
1322
- "maximum": 3,
1370
+ "maximum": 6,
1323
1371
  "default": 0,
1324
1372
  "description": "Select the characteristic type to be displayed in HomeKit app.",
1325
1373
  "anyOf": [
@@ -1330,22 +1378,40 @@
1330
1378
  ]
1331
1379
  },
1332
1380
  {
1333
- "title": "Switch + Motion Sensor",
1381
+ "title": "Motion Sensor",
1334
1382
  "enum": [
1335
1383
  1
1336
1384
  ]
1337
1385
  },
1338
1386
  {
1339
- "title": "Switch + Occupancy Sensor",
1387
+ "title": "Occupancy Sensor",
1340
1388
  "enum": [
1341
1389
  2
1342
1390
  ]
1343
1391
  },
1344
1392
  {
1345
- "title": "Switch + Contact Sensor",
1393
+ "title": "Contact Sensor",
1346
1394
  "enum": [
1347
1395
  3
1348
1396
  ]
1397
+ },
1398
+ {
1399
+ "title": "Switch + Motion Sensor",
1400
+ "enum": [
1401
+ 4
1402
+ ]
1403
+ },
1404
+ {
1405
+ "title": "Switch + Occupancy Sensor",
1406
+ "enum": [
1407
+ 5
1408
+ ]
1409
+ },
1410
+ {
1411
+ "title": "Switch + Contact Sensor",
1412
+ "enum": [
1413
+ 6
1414
+ ]
1349
1415
  }
1350
1416
  ]
1351
1417
  },
@@ -1388,7 +1454,7 @@
1388
1454
  "title": "Display Type",
1389
1455
  "type": "integer",
1390
1456
  "minimum": 0,
1391
- "maximum": 3,
1457
+ "maximum": 6,
1392
1458
  "default": 0,
1393
1459
  "description": "Select the characteristic type to be displayed in HomeKit app.",
1394
1460
  "anyOf": [
@@ -1399,22 +1465,40 @@
1399
1465
  ]
1400
1466
  },
1401
1467
  {
1402
- "title": "Switch + Motion Sensor",
1468
+ "title": "Motion Sensor",
1403
1469
  "enum": [
1404
1470
  1
1405
1471
  ]
1406
1472
  },
1407
1473
  {
1408
- "title": "Switch + Occupancy Sensor",
1474
+ "title": "Occupancy Sensor",
1409
1475
  "enum": [
1410
1476
  2
1411
1477
  ]
1412
1478
  },
1413
1479
  {
1414
- "title": "Switch + Contact Sensor",
1480
+ "title": "Contact Sensor",
1415
1481
  "enum": [
1416
1482
  3
1417
1483
  ]
1484
+ },
1485
+ {
1486
+ "title": "Switch + Motion Sensor",
1487
+ "enum": [
1488
+ 4
1489
+ ]
1490
+ },
1491
+ {
1492
+ "title": "Switch + Occupancy Sensor",
1493
+ "enum": [
1494
+ 5
1495
+ ]
1496
+ },
1497
+ {
1498
+ "title": "Switch + Contact Sensor",
1499
+ "enum": [
1500
+ 6
1501
+ ]
1418
1502
  }
1419
1503
  ]
1420
1504
  },
@@ -1792,7 +1876,7 @@
1792
1876
  "title": "Display Type",
1793
1877
  "type": "integer",
1794
1878
  "minimum": 0,
1795
- "maximum": 5,
1879
+ "maximum": 6,
1796
1880
  "default": 0,
1797
1881
  "description": "Select the characteristic type to be displayed in HomeKit app.",
1798
1882
  "anyOf": [
@@ -1803,39 +1887,42 @@
1803
1887
  ]
1804
1888
  },
1805
1889
  {
1806
- "title": "Outlet",
1890
+ "title": "Motion Sensor",
1807
1891
  "enum": [
1808
1892
  1
1809
1893
  ]
1810
1894
  },
1811
1895
  {
1812
- "title": "Switch",
1896
+ "title": "Occupancy Sensor",
1813
1897
  "enum": [
1814
1898
  2
1815
1899
  ]
1816
1900
  },
1817
1901
  {
1818
- "title": "Motion Sensor",
1902
+ "title": "Contact Sensor",
1819
1903
  "enum": [
1820
1904
  3
1821
1905
  ]
1822
1906
  },
1823
1907
  {
1824
- "title": "Occupancy Sensor",
1908
+ "title": "Switch + Motion Sensor",
1825
1909
  "enum": [
1826
1910
  4
1827
1911
  ]
1828
1912
  },
1829
1913
  {
1830
- "title": "Contact Sensor",
1914
+ "title": "Switch + Occupancy Sensor",
1831
1915
  "enum": [
1832
1916
  5
1833
1917
  ]
1918
+ },
1919
+ {
1920
+ "title": "Switch + Contact Sensor",
1921
+ "enum": [
1922
+ 6
1923
+ ]
1834
1924
  }
1835
- ],
1836
- "condition": {
1837
- "functionBody": "return model.accounts[arrayIndices[0]].ervDevices[arrayIndices[1]].presets[arrayIndices[2]].displayType > 0;"
1838
- }
1925
+ ]
1839
1926
  },
1840
1927
  "name": {
1841
1928
  "title": "Name",
@@ -1876,7 +1963,7 @@
1876
1963
  "title": "Display Type",
1877
1964
  "type": "integer",
1878
1965
  "minimum": 0,
1879
- "maximum": 3,
1966
+ "maximum": 6,
1880
1967
  "default": 0,
1881
1968
  "description": "Select the characteristic type to be displayed in HomeKit app.",
1882
1969
  "anyOf": [
@@ -1887,22 +1974,40 @@
1887
1974
  ]
1888
1975
  },
1889
1976
  {
1890
- "title": "Switch + Motion Sensor",
1977
+ "title": "Motion Sensor",
1891
1978
  "enum": [
1892
1979
  1
1893
1980
  ]
1894
1981
  },
1895
1982
  {
1896
- "title": "Switch + Occupancy Sensor",
1983
+ "title": "Occupancy Sensor",
1897
1984
  "enum": [
1898
1985
  2
1899
1986
  ]
1900
1987
  },
1901
1988
  {
1902
- "title": "Switch + Contact Sensor",
1989
+ "title": "Contact Sensor",
1903
1990
  "enum": [
1904
1991
  3
1905
1992
  ]
1993
+ },
1994
+ {
1995
+ "title": "Switch + Motion Sensor",
1996
+ "enum": [
1997
+ 4
1998
+ ]
1999
+ },
2000
+ {
2001
+ "title": "Switch + Occupancy Sensor",
2002
+ "enum": [
2003
+ 5
2004
+ ]
2005
+ },
2006
+ {
2007
+ "title": "Switch + Contact Sensor",
2008
+ "enum": [
2009
+ 6
2010
+ ]
1906
2011
  }
1907
2012
  ]
1908
2013
  },
@@ -1945,7 +2050,7 @@
1945
2050
  "title": "Display Type",
1946
2051
  "type": "integer",
1947
2052
  "minimum": 0,
1948
- "maximum": 3,
2053
+ "maximum": 6,
1949
2054
  "default": 0,
1950
2055
  "description": "Select the characteristic type to be displayed in HomeKit app.",
1951
2056
  "anyOf": [
@@ -1956,22 +2061,40 @@
1956
2061
  ]
1957
2062
  },
1958
2063
  {
1959
- "title": "Switch + Motion Sensor",
2064
+ "title": "Motion Sensor",
1960
2065
  "enum": [
1961
2066
  1
1962
2067
  ]
1963
2068
  },
1964
2069
  {
1965
- "title": "Switch + Occupancy Sensor",
2070
+ "title": "Occupancy Sensor",
1966
2071
  "enum": [
1967
2072
  2
1968
2073
  ]
1969
2074
  },
1970
2075
  {
1971
- "title": "Switch + Contact Sensor",
2076
+ "title": "Contact Sensor",
1972
2077
  "enum": [
1973
2078
  3
1974
2079
  ]
2080
+ },
2081
+ {
2082
+ "title": "Switch + Motion Sensor",
2083
+ "enum": [
2084
+ 4
2085
+ ]
2086
+ },
2087
+ {
2088
+ "title": "Switch + Occupancy Sensor",
2089
+ "enum": [
2090
+ 5
2091
+ ]
2092
+ },
2093
+ {
2094
+ "title": "Switch + Contact Sensor",
2095
+ "enum": [
2096
+ 6
2097
+ ]
1975
2098
  }
1976
2099
  ]
1977
2100
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.2.3-beta.57",
4
+ "version": "4.2.3-beta.58",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
package/src/deviceata.js CHANGED
@@ -56,12 +56,14 @@ class DeviceAta extends EventEmitter {
56
56
  this.restFulConnected = false;
57
57
  this.mqtt = account.mqtt ?? {};
58
58
  this.mqttConnected = false;
59
+ const serviceType = [null, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor];
60
+ const characteristicType = [null, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState];
59
61
 
60
62
  //presets configured
61
63
  for (const preset of this.presets) {
62
64
  preset.name = preset.name;
63
- preset.serviceType = [null, Service.Outlet, Service.Switch, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][preset.displayType];
64
- preset.characteristicType = [null, Characteristic.On, Characteristic.On, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][preset.displayType];
65
+ preset.serviceType = serviceType[preset.displayType];
66
+ preset.characteristicType = characteristicType[preset.displayType];
65
67
  preset.state = false;
66
68
  preset.previousSettings = {};
67
69
  }
@@ -69,16 +71,16 @@ class DeviceAta extends EventEmitter {
69
71
  //schedules configured
70
72
  for (const schedule of this.schedules) {
71
73
  schedule.name = schedule.name;
72
- schedule.serviceType = [null, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][schedule.displayType];
73
- schedule.characteristicType = [null, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][schedule.displayType];
74
+ schedule.serviceType = serviceType[schedule.displayType];
75
+ schedule.characteristicType = characteristicType[schedule.displayType];
74
76
  schedule.state = false;
75
77
  }
76
78
 
77
79
  //scenes configured
78
80
  for (const scene of this.scenes) {
79
81
  scene.name = scene.name;
80
- scene.serviceType = [null, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][scene.displayType];
81
- scene.characteristicType = [null, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][scene.displayType];
82
+ scene.serviceType = serviceType[scene.displayType];
83
+ scene.characteristicType = characteristicType[scene.displayType];
82
84
  scene.state = false;
83
85
  }
84
86
 
@@ -850,7 +852,8 @@ class DeviceAta extends EventEmitter {
850
852
  //presets services
851
853
  if (this.presets.length > 0) {
852
854
  if (this.logDebug) this.emit('debug', `Prepare presets services`);
853
- this.presetsServices = [];
855
+ this.presetControlServices = [];
856
+ this.presetControlSensorServices = [];
854
857
  this.presets.forEach((preset, i) => {
855
858
  const presetData = presetsOnServer.find(p => p.ID === preset.id);
856
859
 
@@ -863,51 +866,68 @@ class DeviceAta extends EventEmitter {
863
866
  const serviceName1 = namePrefix ? `${accessoryName} ${name}` : name;
864
867
  const serviceType = preset.serviceType;
865
868
  const characteristicType = preset.characteristicType;
866
- const presetService = new serviceType(serviceName1, `Preset ${deviceId} ${i}`);
867
- presetService.addOptionalCharacteristic(Characteristic.ConfiguredName);
868
- presetService.setCharacteristic(Characteristic.ConfiguredName, serviceName1);
869
- presetService.getCharacteristic(characteristicType)
869
+
870
+ if (preset.displayType > 3) {
871
+ if (this.logDebug) this.emit('debug', `Prepare preset control ${name} service`);
872
+ const presetControlService = new Service.Switch(serviceName1, `presetControlService${deviceId} ${i}`);
873
+ presetControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
874
+ presetControlService.setCharacteristic(Characteristic.ConfiguredName, serviceName1);
875
+ presetControlService.getCharacteristic(Characteristic.On)
876
+ .onGet(async () => {
877
+ const state = preset.state;
878
+ return state;
879
+ })
880
+ .onSet(async (state) => {
881
+ try {
882
+ switch (state) {
883
+ case true:
884
+ preset.previousSettings = deviceData.Device;
885
+ deviceData.Device.Power = presetData.Power;
886
+ deviceData.Device.OperationMode = presetData.OperationMode;
887
+ deviceData.Device.SetTemperature = presetData.SetTemperature;
888
+ deviceData.Device.VaneHorizontalDirection = presetData.VaneHorizontalDirection;
889
+ deviceData.Device.VaneVerticalDirection = presetData.VaneVerticalDirection;
890
+ deviceData.Device.SetFanSpeed = presetData.SetFanSpeed;
891
+ break;
892
+ case false:
893
+ deviceData.Device.Power = preset.previousSettings.Power;
894
+ deviceData.Device.OperationMode = preset.previousSettings.OperationMode;
895
+ deviceData.Device.SetTemperature = preset.previousSettings.SetTemperature;
896
+ deviceData.Device.VaneHorizontalDirection = preset.previousSettings.VaneHorizontalDirection;
897
+ deviceData.Device.VaneVerticalDirection = preset.previousSettings.VaneVerticalDirection;
898
+ deviceData.Device.SetFanSpeed = preset.previousSettings.SetFanSpeed;
899
+ break;
900
+ };
901
+
902
+ await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.Presets);
903
+ if (this.logInfo) this.emit('info', `Preset ${name}: ${state ? 'Set:' : 'Unset:'} ${name}`);
904
+ } catch (error) {
905
+ if (this.logWarn) this.emit('warn', `Set preset error: ${error}`);
906
+ };
907
+ });
908
+ this.presetControlServices.push(presetControlService);
909
+ accessory.addService(presetControlService);
910
+ }
911
+
912
+ //sensor
913
+ if (this.logDebug) this.emit('debug', `Prepare preset control sensor s${name} ervice`);
914
+ const presetControlSensorService = new serviceType(`${serviceName1} Control`, `presetControlSensorService${deviceId} ${i}`);
915
+ presetControlSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
916
+ presetControlSensorService.setCharacteristic(Characteristic.ConfiguredName, `${serviceName1} Control`);
917
+ presetControlSensorService.getCharacteristic(characteristicType)
870
918
  .onGet(async () => {
871
- const state = preset.state;
919
+ const state = this.accessory.scheduleEnabled;
872
920
  return state;
873
921
  })
874
- .onSet(async (state) => {
875
- try {
876
- switch (state) {
877
- case true:
878
- preset.previousSettings = deviceData.Device;
879
- deviceData.Device.Power = presetData.Power;
880
- deviceData.Device.OperationMode = presetData.OperationMode;
881
- deviceData.Device.SetTemperature = presetData.SetTemperature;
882
- deviceData.Device.VaneHorizontalDirection = presetData.VaneHorizontalDirection;
883
- deviceData.Device.VaneVerticalDirection = presetData.VaneVerticalDirection;
884
- deviceData.Device.SetFanSpeed = presetData.SetFanSpeed;
885
- break;
886
- case false:
887
- deviceData.Device.Power = preset.previousSettings.Power;
888
- deviceData.Device.OperationMode = preset.previousSettings.OperationMode;
889
- deviceData.Device.SetTemperature = preset.previousSettings.SetTemperature;
890
- deviceData.Device.VaneHorizontalDirection = preset.previousSettings.VaneHorizontalDirection;
891
- deviceData.Device.VaneVerticalDirection = preset.previousSettings.VaneVerticalDirection;
892
- deviceData.Device.SetFanSpeed = preset.previousSettings.SetFanSpeed;
893
- break;
894
- };
895
-
896
- await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.Presets);
897
- if (this.logInfo) this.emit('info', `${state ? 'Set:' : 'Unset:'} ${name}`);
898
- } catch (error) {
899
- if (this.logWarn) this.emit('warn', `Set preset error: ${error}`);
900
- };
901
- });
902
- this.presetsServices.push(presetService);
903
- accessory.addService(presetService);
922
+ this.presetControlSensorServices.push(presetControlSensorService);
923
+ accessory.addService(presetControlSensorService);
904
924
  });
905
925
  };
906
926
 
907
927
  //schedules services
908
928
  if (this.schedules.length > 0 && this.accessory.scheduleEnabled !== null) {
909
929
  if (this.logDebug) this.emit('debug', `Prepare schedules services`);
910
- this.schedulesServices = [];
930
+ this.scheduleSensorServices = [];
911
931
  this.schedules.forEach((schedule, i) => {
912
932
  //get preset name
913
933
  const name = schedule.name;
@@ -915,109 +935,114 @@ class DeviceAta extends EventEmitter {
915
935
  //get preset name prefix
916
936
  const namePrefix = schedule.namePrefix;
917
937
 
938
+ //control sensor
939
+ const serviceName1 = namePrefix ? `${accessoryName} ${name}` : name;
940
+ const serviceType = schedule.serviceType;
941
+ const characteristicType = schedule.characteristicType;
942
+
918
943
  //control
919
944
  if (i === 0) {
920
- if (this.logDebug) this.emit('debug', `Prepare schedule control service`);
921
- this.schedulesControlService = new Service.Switch(`${serviceName} Schedule`, `schedulesControlService${deviceId}`);
922
- this.schedulesControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
923
- this.schedulesControlService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Schedule`);
924
- this.schedulesControlService.getCharacteristic(Characteristic.On)
925
- .onGet(async () => {
926
- const state = this.accessory.scheduleEnabled;
927
- return state;
928
- })
929
- .onSet(async (state) => {
930
- try {
931
- deviceData.ScheduleEnabled = state;
932
- await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'schedule');
933
- if (this.logInfo) this.emit('info', `Schedule: ${state ? 'Enabled' : 'Disabled'}`);
934
- } catch (error) {
935
- if (this.logWarn) this.emit('warn', `Set schedule error: ${error}`);
936
- };
937
- });
938
- accessory.addService(this.schedulesControlService);
939
-
940
- if (this.logDebug) this.emit('debug', `Prepare schedule control sensor service`);
941
- this.schedulesControlSensorService = new Service.ContactSensor(`${serviceName} Schedule Control`, `schedulesControlSensorService${deviceId}`);
942
- this.schedulesControlSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
943
- this.schedulesControlSensorService.setCharacteristic(Characteristic.ConfiguredName, `${accessoryName} Schedule Control`);
944
- this.schedulesControlSensorService.getCharacteristic(Characteristic.ContactSensorState)
945
+ if (schedule.displayType > 3) {
946
+ if (this.logDebug) this.emit('debug', `Prepare schedule control ${name} service`);
947
+ this.scheduleControlService = new Service.Switch(`${serviceName1} Control`, `scheduleControlService${deviceId} ${i}`);
948
+ this.scheduleControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
949
+ this.scheduleControlService.setCharacteristic(Characteristic.ConfiguredName, serviceName1);
950
+ this.scheduleControlService.getCharacteristic(Characteristic.On)
951
+ .onGet(async () => {
952
+ const state = this.accessory.scheduleEnabled;
953
+ return state;
954
+ })
955
+ .onSet(async (state) => {
956
+ try {
957
+ deviceData.ScheduleEnabled = state;
958
+ await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'schedule');
959
+ if (this.logInfo) this.emit('info', `Schedule ${name}: ${state ? 'Enabled' : 'Disabled'}`);
960
+ } catch (error) {
961
+ if (this.logWarn) this.emit('warn', `Set schedule error: ${error}`);
962
+ };
963
+ });
964
+ accessory.addService(this.schedulesControlService);
965
+ }
966
+
967
+ //sensor
968
+ if (this.logDebug) this.emit('debug', `Prepare schedule control sensor ${name} service`);
969
+ this.scheduleControlSensorService = new serviceType(`${serviceName1} Control`, `scheduleControlSensorService${deviceId} ${i}`);
970
+ this.scheduleControlSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
971
+ this.scheduleControlSensorService.setCharacteristic(Characteristic.ConfiguredName, `${serviceName1} Control`);
972
+ this.scheduleControlSensorService.getCharacteristic(characteristicType)
945
973
  .onGet(async () => {
946
974
  const state = this.accessory.scheduleEnabled;
947
975
  return state;
948
976
  })
949
- accessory.addService(this.schedulesControlSensorService);
950
977
  }
951
978
 
952
979
  //sensors
953
- const serviceName1 = namePrefix ? `${accessoryName} ${name}` : name;
954
- const serviceType = schedule.serviceType;
955
- const characteristicType = schedule.characteristicType;
956
- const scheduleService = new serviceType(serviceName1, `scheduleService${deviceId} ${i}`);
957
- scheduleService.addOptionalCharacteristic(Characteristic.ConfiguredName);
958
- scheduleService.setCharacteristic(Characteristic.ConfiguredName, serviceName1);
959
- scheduleService.getCharacteristic(characteristicType)
980
+ if (this.logDebug) this.emit('debug', `Prepare schedule sensor ${name} service`);
981
+ const scheduleSensorService = new serviceType(serviceName1, `scheduleSensorService${deviceId} ${i}`);
982
+ scheduleSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
983
+ scheduleSensorService.setCharacteristic(Characteristic.ConfiguredName, serviceName1);
984
+ scheduleSensorService.getCharacteristic(characteristicType)
960
985
  .onGet(async () => {
961
986
  const state = schedule.state;
962
987
  return state;
963
988
  });
964
- this.schedulesServices.push(scheduleService);
965
- accessory.addService(scheduleService);
989
+ this.scheduleSensorServices.push(scheduleSensorService);
990
+ accessory.addService(scheduleSensorService);
966
991
  });
967
992
  };
968
993
 
969
994
  //scenes
970
995
  if (this.scenes.length > 0) {
971
996
  if (this.logDebug) this.emit('debug', `Prepare scenes services`);
972
- this.scenesControlServices = [];
973
- this.scenesControlSensorServices = [];
997
+ this.sceneControlServices = [];
998
+ this.sceneControlSensorServices = [];
974
999
  this.scenes.forEach((scene, i) => {
975
1000
  const sceneData = scenesOnServer.find(s => s.Id === scene.id);
976
1001
 
977
- //get id
978
- const id = scene.id;
979
-
980
1002
  //get preset name
981
1003
  const name = scene.name;
982
1004
 
983
1005
  //get preset name prefix
984
1006
  const namePrefix = scene.namePrefix;
985
1007
 
986
- //control
987
- if (this.logDebug) this.emit('debug', `Prepare scene control service`);
988
1008
  const serviceName1 = namePrefix ? `${accessoryName} ${name}` : name;
989
- const sceneControlService = new Service.Switch(serviceName1, `sceneControlService${id}`);
990
- sceneControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
991
- sceneControlService.setCharacteristic(Characteristic.ConfiguredName, serviceName1);
992
- sceneControlService.getCharacteristic(Characteristic.On)
993
- .onGet(async () => {
994
- const state = scene.state;
995
- return state;
996
- })
997
- .onSet(async (state) => {
998
- try {
999
- sceneData.Enabled = state;
1000
- await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'scene', sceneData);
1001
- if (this.logInfo) this.emit('info', `Scene ${name}: ${state ? 'Enabled' : 'Disabled'}`);
1002
- } catch (error) {
1003
- if (this.logWarn) this.emit('warn', `Set scene error: ${error}`);
1004
- };
1005
- });
1006
- this.scenesControlServices.push(sceneControlService);
1007
- accessory.addService(sceneControlService);
1008
-
1009
- if (this.logDebug) this.emit('debug', `Prepare scene control sensor service`);
1010
1009
  const serviceType = scene.serviceType;
1011
1010
  const characteristicType = scene.characteristicType;
1012
- const sceneControlSensorService = new serviceType(serviceName1, `sceneControlSensorService${id}`);
1011
+
1012
+ //control
1013
+ if (scene.displayType > 3) {
1014
+ if (this.logDebug) this.emit('debug', `Prepare scene control ${name} service`);
1015
+ const sceneControlService = new Service.Switch(serviceName1, `sceneControlService${deviceId} ${i}`);
1016
+ sceneControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
1017
+ sceneControlService.setCharacteristic(Characteristic.ConfiguredName, serviceName1);
1018
+ sceneControlService.getCharacteristic(Characteristic.On)
1019
+ .onGet(async () => {
1020
+ const state = scene.state;
1021
+ return state;
1022
+ })
1023
+ .onSet(async (state) => {
1024
+ try {
1025
+ sceneData.Enabled = state;
1026
+ await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'scene', sceneData);
1027
+ if (this.logInfo) this.emit('info', `Scene ${name}: ${state ? 'Enabled' : 'Disabled'}`);
1028
+ } catch (error) {
1029
+ if (this.logWarn) this.emit('warn', `Set scene error: ${error}`);
1030
+ };
1031
+ });
1032
+ this.sceneControlServices.push(sceneControlService);
1033
+ accessory.addService(sceneControlService);
1034
+ }
1035
+
1036
+ if (this.logDebug) this.emit('debug', `Prepare scene control sensor ${name} service`);
1037
+ const sceneControlSensorService = new serviceType(`${serviceName1} Control`, `sceneControlSensorService${deviceId} ${i}`);
1013
1038
  sceneControlSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
1014
- sceneControlSensorService.setCharacteristic(Characteristic.ConfiguredName, serviceName1);
1039
+ sceneControlSensorService.setCharacteristic(Characteristic.ConfiguredName, `${serviceName1} Control`);
1015
1040
  sceneControlSensorService.getCharacteristic(characteristicType)
1016
1041
  .onGet(async () => {
1017
1042
  const state = scene.state;
1018
1043
  return state;
1019
1044
  })
1020
- this.scenesControlSensorServices.push(sceneControlSensorService);
1045
+ this.sceneControlSensorServices.push(sceneControlSensorService);
1021
1046
  accessory.addService(sceneControlSensorService);
1022
1047
  });
1023
1048
  };
@@ -1614,24 +1639,29 @@ class DeviceAta extends EventEmitter {
1614
1639
  && presetData.FanSpeed === setFanSpeed) : false;
1615
1640
 
1616
1641
  const characteristicType = preset.characteristicType;
1617
- this.presetsServices?.[i]?.updateCharacteristic(characteristicType, preset.state);
1642
+ if (preset.displayType > 3) {
1643
+ this.presetControlServices?.[i]?.updateCharacteristic(Characteristic.On, preset.state);
1644
+ }
1645
+ this.presetControlSensorServices?.[i]?.updateCharacteristic(characteristicType, preset.state);
1618
1646
  });
1619
1647
  };
1620
1648
 
1621
1649
  //schedules
1622
1650
  if (this.schedules.length > 0 && scheduleEnabled !== null) {
1623
1651
  this.schedules.forEach((schedule, i) => {
1652
+ const scheduleData = schedulesOnServer.find(s => s.Id === schedule.id);
1653
+ schedule.state = scheduleEnabled ? scheduleData.Enabled ?? false : false;
1654
+ const characteristicType = schedule.characteristicType;
1655
+
1624
1656
  //control
1625
1657
  if (i === 0) {
1626
- this.schedulesControlService?.updateCharacteristic(Characteristic.On, scheduleEnabled);
1627
- this.schedulesControlSensorService?.updateCharacteristic(Characteristic.ContactSensorState, scheduleEnabled);
1658
+ if (schedule.displayType > 3) {
1659
+ this.scheduleControlService?.updateCharacteristic(Characteristic.On, scheduleEnabled);
1660
+ }
1661
+ this.scheduleControlSensorService?.updateCharacteristic(characteristicType, scheduleEnabled);
1628
1662
  }
1629
1663
 
1630
1664
  //sensors
1631
- const scheduleData = schedulesOnServer.find(s => s.Id === schedule.id);
1632
- schedule.state = scheduleEnabled ? scheduleData.Enabled ?? false : false;
1633
-
1634
- const characteristicType = schedule.characteristicType;
1635
1665
  this.schedulesServices?.[i]?.updateCharacteristic(characteristicType, schedule.state);
1636
1666
  });
1637
1667
  };
@@ -1643,11 +1673,13 @@ class DeviceAta extends EventEmitter {
1643
1673
  scene.state = sceneData.Enabled;
1644
1674
 
1645
1675
  //control
1646
- this.scenesControlServices?.[i]?.updateCharacteristic(Characteristic.On, scene.state);
1676
+ if (scene.displayType > 3) {
1677
+ this.sceneControlServices?.[i]?.updateCharacteristic(Characteristic.On, scene.state);
1678
+ }
1647
1679
 
1648
- //sensors
1680
+ //sensor
1649
1681
  const characteristicType = scene.characteristicType;
1650
- this.scenesControlSensorServices?.[i]?.updateCharacteristic(characteristicType, scene.state);
1682
+ this.sceneControlSensorServices?.[i]?.updateCharacteristic(characteristicType, scene.state);
1651
1683
  });
1652
1684
  };
1653
1685