homebridge-melcloud-control 4.2.5-beta.0 → 4.2.5-beta.3

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/src/deviceerv.js CHANGED
@@ -82,8 +82,8 @@ class DeviceErv extends EventEmitter {
82
82
  //buttons configured
83
83
  for (const button of this.buttons) {
84
84
  button.name = button.name || 'Button'
85
- button.serviceType = [null, Service.Outlet, Service.Switch, Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][button.displayType];
86
- button.characteristicType = [null, Characteristic.On, Characteristic.On, Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][button.displayType];
85
+ button.serviceType = serviceType[button.displayType];
86
+ button.characteristicType = characteristicType[button.displayType];
87
87
  button.state = false;
88
88
  button.previousValue = null;
89
89
  }
@@ -320,8 +320,8 @@ class DeviceErv extends EventEmitter {
320
320
  .onSet(async (state) => {
321
321
  try {
322
322
  deviceData.Device.Power = state ? true : false;
323
- await this.melCloudErv.send(this.accountType, this.displayType, deviceData, Ventilation.EffectiveFlags.Power);
324
323
  if (this.logInfo) this.emit('info', `Set power: ${state ? 'On' : 'Off'}`);
324
+ await this.melCloudErv.send(this.accountType, this.displayType, deviceData, Ventilation.EffectiveFlags.Power);
325
325
  } catch (error) {
326
326
  if (this.logWarn) this.emit('warn', `Set power error: ${error}`);
327
327
  };
@@ -355,9 +355,8 @@ class DeviceErv extends EventEmitter {
355
355
  break;
356
356
  };
357
357
 
358
+ if (this.logInfo) this.emit('info', `Set operation mode: ${Ventilation.VentilationModeMapEnumToString[deviceData.Device.VentilationMode]}`);
358
359
  await this.melCloudErv.send(this.accountType, this.displayType, deviceData, Ventilation.EffectiveFlags.VentilationMode);
359
- const operationModeText = Ventilation.VentilationModeMapEnumToString[deviceData.Device.VentilationMode];
360
- if (this.logInfo) this.emit('info', `Set operation mode: ${operationModeText}`);
361
360
  } catch (error) {
362
361
  if (this.logWarn) this.emit('warn', `Set operation mode error: ${error}`);
363
362
  };
@@ -395,9 +394,9 @@ class DeviceErv extends EventEmitter {
395
394
  break;;
396
395
  };
397
396
 
398
- deviceData.Device.SetFanSpeed = value
399
- await this.melCloudErv.send(this.accountType, this.displayType, deviceData, Ventilation.EffectiveFlags.SetFanSpeed);
397
+ deviceData.Device.SetFanSpeed = value;
400
398
  if (this.logInfo) this.emit('info', `Set fan speed mode: ${Ventilation.FanSpeedMapEnumToString[value]}`);
399
+ await this.melCloudErv.send(this.accountType, this.displayType, deviceData, Ventilation.EffectiveFlags.SetFanSpeed);
401
400
  } catch (error) {
402
401
  if (this.logWarn) this.emit('warn', `Set fan speed mode error: ${error}`);
403
402
  };
@@ -418,8 +417,8 @@ class DeviceErv extends EventEmitter {
418
417
  .onSet(async (value) => {
419
418
  try {
420
419
  deviceData.Device.DefaultCoolingSetTemperature = value;
421
- await this.melCloudErv.send(this.accountType, this.displayType, deviceData, Ventilation.EffectiveFlags.SetTemperature);
422
420
  if (this.logInfo) this.emit('info', `Set cooling threshold temperature: ${value}${this.accessory.temperatureUnit}`);
421
+ await this.melCloudErv.send(this.accountType, this.displayType, deviceData, Ventilation.EffectiveFlags.SetTemperature);
423
422
  } catch (error) {
424
423
  if (this.logWarn) this.emit('warn', `Set cooling threshold temperature error: ${error}`);
425
424
  };
@@ -440,29 +439,13 @@ class DeviceErv extends EventEmitter {
440
439
  .onSet(async (value) => {
441
440
  try {
442
441
  deviceData.Device.DefaultHeatingSetTemperature = value;
443
- await this.melCloudErv.send(this.accountType, this.displayType, deviceData, Ventilation.EffectiveFlags.SetTemperature);
444
442
  if (this.logInfo) this.emit('info', `Set heating threshold temperature: ${value}${this.accessory.temperatureUnit}`);
443
+ await this.melCloudErv.send(this.accountType, this.displayType, deviceData, Ventilation.EffectiveFlags.SetTemperature);
445
444
  } catch (error) {
446
445
  if (this.logWarn) this.emit('warn', `Set heating threshold temperature error: ${error}`);
447
446
  };
448
447
  });
449
448
  };
450
- //this.melCloudService.getCharacteristic(Characteristic.LockPhysicalControls)
451
- // .onGet(async () => {
452
- // const value = this.accessory.lockPhysicalControl;
453
- // if (this.logInfo) this.emit('info', `Lock physical controls: ${value ? 'LOCKED' : 'UNLOCKED'}`);
454
- // return value;
455
- // })
456
- // .onSet(async (value) => {
457
- // try {
458
- // value = value ? true : false;
459
- // deviceData.Device = deviceData.Device;
460
- // await this.melCloudErv.send(this.accountType, this.displayType, deviceData, Ventilation.EffectiveFlags.Prohibit);
461
- // if (this.logInfo) this.emit('info', `Set local physical controls: ${value ? 'LOCK' : 'UNLOCK'}`);
462
- // } catch (error) {
463
- // if (this.logWarn) this.emit('warn', `Set lock physical controls error: ${error}`);
464
- // };
465
- // });
466
449
  this.melCloudService.getCharacteristic(Characteristic.TemperatureDisplayUnits)
467
450
  .onGet(async () => {
468
451
  const value = this.accessory.useFahrenheit;
@@ -474,8 +457,8 @@ class DeviceErv extends EventEmitter {
474
457
  try {
475
458
  value = [false, true][value];
476
459
  this.accessory.useFahrenheit = value;
477
- this.emit('melCloud', 'UseFahrenheit', value);
478
460
  if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
461
+ this.emit('melCloud', 'UseFahrenheit', value);
479
462
  } catch (error) {
480
463
  if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
481
464
  };
@@ -526,9 +509,8 @@ class DeviceErv extends EventEmitter {
526
509
  break;
527
510
  };
528
511
 
512
+ if (this.logInfo) this.emit('info', `Set operation mode: ${Ventilation.VentilationModeMapEnumToString[deviceData.Device.VentilationMode]}`);
529
513
  await this.melCloudErv.send(this.accountType, this.displayType, deviceData, flag);
530
- const operationModeText = Ventilation.VentilationModeMapEnumToString[deviceData.Device.VentilationMode];
531
- if (this.logInfo) this.emit('info', `Set operation mode: ${operationModeText}`);
532
514
  } catch (error) {
533
515
  if (this.logWarn) this.emit('warn', `Set operation mode error: ${error}`);
534
516
  };
@@ -551,8 +533,8 @@ class DeviceErv extends EventEmitter {
551
533
  .onSet(async (value) => {
552
534
  try {
553
535
  deviceData.Device.SetTemperature = value;
554
- await this.melCloudErv.send(this.accountType, this.displayType, deviceData, Ventilation.EffectiveFlags.SetTemperature);
555
536
  if (this.logInfo) this.emit('info', `Set temperature: ${value}${this.accessory.temperatureUnit}`);
537
+ await this.melCloudErv.send(this.accountType, this.displayType, deviceData, Ventilation.EffectiveFlags.SetTemperature);
556
538
  } catch (error) {
557
539
  if (this.logWarn) this.emit('warn', `Set temperature error: ${error}`);
558
540
  };
@@ -568,8 +550,8 @@ class DeviceErv extends EventEmitter {
568
550
  try {
569
551
  value = [false, true][value];
570
552
  this.accessory.useFahrenheit = value;
571
- this.emit('melCloud', 'UseFahrenheit', value);
572
553
  if (this.logInfo) this.emit('info', `Set temperature display unit: ${TemperatureDisplayUnits[value]}`);
554
+ this.emit('melCloud', 'UseFahrenheit', value);
573
555
  } catch (error) {
574
556
  if (this.logWarn) this.emit('warn', `Set temperature display unit error: ${error}`);
575
557
  };
@@ -759,8 +741,8 @@ class DeviceErv extends EventEmitter {
759
741
  .onSet(async (state) => {
760
742
  try {
761
743
  deviceData.HolidayMode.Enabled = state;
762
- await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'holidaymode');
763
- if (this.logInfo) this.emit('info', `Holiday mode: ${state ? 'Enabled' : 'Disabled'}`);
744
+ if (this.logInfo) this.emit('info', `Holiday mode: ${state ? 'Enable' : 'Disable'}`);
745
+ await this.melCloudErv.send(this.accountType, this.displayType, deviceData, 'holidaymode');
764
746
  } catch (error) {
765
747
  if (this.logWarn) this.emit('warn', `Set holiday mode error: ${error}`);
766
748
  };
@@ -841,8 +823,8 @@ class DeviceErv extends EventEmitter {
841
823
  break;
842
824
  };
843
825
 
844
- await this.melCloudAta.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.Presets);
845
- if (this.logInfo) this.emit('info', `Preset ${name}: ${state ? 'Set:' : 'Unset:'} ${name}`);
826
+ if (this.logInfo) this.emit('info', `Preset ${name}: ${state ? 'Set:' : 'Unset:'}`);
827
+ await this.melCloudErv.send(this.accountType, this.displayType, deviceData, AirConditioner.EffectiveFlags.Presets);
846
828
  } catch (error) {
847
829
  if (this.logWarn) this.emit('warn', `Set preset error: ${error}`);
848
830
  };
@@ -898,10 +880,10 @@ class DeviceErv extends EventEmitter {
898
880
  .onSet(async (state) => {
899
881
  try {
900
882
  deviceData.ScheduleEnabled = state;
901
- await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'schedule');
902
- if (this.logInfo) this.emit('info', `Schedule ${name}: ${state ? 'Enabled' : 'Disabled'}`);
883
+ if (this.logInfo) this.emit('info', `Schedules: ${state ? 'Enable' : 'Disable'}`);
884
+ await this.melCloudErv.send(this.accountType, this.displayType, deviceData, 'schedule');
903
885
  } catch (error) {
904
- if (this.logWarn) this.emit('warn', `Set schedule error: ${error}`);
886
+ if (this.logWarn) this.emit('warn', `Set schedule serror: ${error}`);
905
887
  };
906
888
  });
907
889
  accessory.addService(this.scheduleControlService);
@@ -967,8 +949,8 @@ class DeviceErv extends EventEmitter {
967
949
  .onSet(async (state) => {
968
950
  try {
969
951
  sceneData.Enabled = state;
970
- await this.melCloudAta.send(this.accountType, this.displayType, deviceData, 'scene', sceneData);
971
- if (this.logInfo) this.emit('info', `Scene ${name}: ${state ? 'Enabled' : 'Disabled'}`);
952
+ if (this.logInfo) this.emit('info', `Scene ${name}: ${state ? 'Enable' : 'Disable'}`);
953
+ await this.melCloudErv.send(this.accountType, this.displayType, deviceData, 'scene', sceneData);
972
954
  } catch (error) {
973
955
  if (this.logWarn) this.emit('warn', `Set scene error: ${error}`);
974
956
  };
@@ -993,8 +975,9 @@ class DeviceErv extends EventEmitter {
993
975
 
994
976
  //buttons services
995
977
  if (this.buttons.length > 0) {
996
- if (this.logDebug) this.emit('debug', `Prepare buttons services`);
997
- this.buttonsServices = [];
978
+ if (this.logDebug) this.emit('debug', `Prepare buttons / sensors services`);
979
+ this.buttonControlServices = [];
980
+ this.buttonControlSensorServices = [];
998
981
  this.buttons.forEach((button, i) => {
999
982
  //get button mode
1000
983
  const mode = button.mode;
@@ -1008,101 +991,119 @@ class DeviceErv extends EventEmitter {
1008
991
  const serviceName1 = namePrefix ? `${accessoryName} ${buttonName}` : buttonName;
1009
992
  const serviceType = button.serviceType;
1010
993
  const characteristicType = button.characteristicType;
1011
- const buttonService = new serviceType(serviceName1, `Button ${deviceId} ${i}`);
1012
- buttonService.addOptionalCharacteristic(Characteristic.ConfiguredName);
1013
- buttonService.setCharacteristic(Characteristic.ConfiguredName, serviceName1);
1014
- buttonService.getCharacteristic(characteristicType)
994
+
995
+ //control
996
+ if (button.displayType > 3) {
997
+ if (this.logDebug) this.emit('debug', `Prepare button control ${name} service`);
998
+ const buttonControlService = new serviceType(serviceName1, `buttonControlService${deviceId} ${i}`);
999
+ buttonControlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
1000
+ buttonControlService.setCharacteristic(Characteristic.ConfiguredName, serviceName1);
1001
+ buttonControlService.getCharacteristic(Characteristic.On)
1002
+ .onGet(async () => {
1003
+ const state = button.state;
1004
+ return state;
1005
+ })
1006
+ .onSet(async (state) => {
1007
+ try {
1008
+ let flag = null;
1009
+ switch (mode) {
1010
+ case 0: //POWER ON,OFF
1011
+ deviceData.Device.Power = state;
1012
+ flag = Ventilation.EffectiveFlags.Power;
1013
+ break;
1014
+ case 1: //OPERATING MODE RECOVERY
1015
+ button.previousValue = state ? deviceData.Device.VentilationMode : button.previousValue ?? deviceData.Device.VentilationMode;
1016
+ deviceData.Device.Power = true;
1017
+ deviceData.Device.VentilationMode = state ? 0 : button.previousValue;
1018
+ flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
1019
+ break;
1020
+ case 2: //OPERATING MODE BYPASS
1021
+ button.previousValue = state ? deviceData.Device.VentilationMode : button.previousValue ?? deviceData.Device.VentilationMode;
1022
+ deviceData.Device.Power = true;
1023
+ deviceData.Device.VentilationMode = state ? 1 : button.previousValue;
1024
+ flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
1025
+ break
1026
+ case 3: //OPERATING MODE AUTO
1027
+ button.previousValue = state ? deviceData.Device.VentilationMode : button.previousValue ?? deviceData.Device.VentilationMode;
1028
+ deviceData.Device.Power = true;
1029
+ deviceData.Device.VentilationMode = state ? 2 : button.previousValue;
1030
+ flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
1031
+ break;
1032
+ case 4: //NIGHT PURGE MODE
1033
+ deviceData.Device.Power = true;
1034
+ deviceData.Device.NightPurgeMode = state;
1035
+ flag = Ventilation.EffectiveFlags.Power
1036
+ break;
1037
+ case 10: //FAN SPEED MODE AUTO
1038
+ button.previousValue = state ? deviceData.Device.SetFanSpeed : button.previousValue ?? deviceData.Device.SetFanSpeed;
1039
+ deviceData.Device.Power = true;
1040
+ deviceData.Device.SetFanSpeed = state ? 0 : button.previousValue;
1041
+ flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
1042
+ break;
1043
+ case 11: //FAN SPEED MODE 1
1044
+ button.previousValue = state ? deviceData.Device.SetFanSpeed : button.previousValue ?? deviceData.Device.SetFanSpeed;
1045
+ deviceData.Device.Power = true;
1046
+ deviceData.Device.SetFanSpeed = state ? 1 : button.previousValue;
1047
+ flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
1048
+ break;
1049
+ case 12: //FAN SPEED MODE 2
1050
+ button.previousValue = state ? deviceData.Device.SetFanSpeed : button.previousValue ?? deviceData.Device.SetFanSpeed;
1051
+ deviceData.Device.Power = true;
1052
+ deviceData.Device.SetFanSpeed = state ? 2 : button.previousValue;
1053
+ flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
1054
+ break;
1055
+ case 13: //FAN SPEED MODE 3
1056
+ button.previousValue = state ? deviceData.Device.SetFanSpeed : button.previousValue ?? deviceData.Device.SetFanSpeed;
1057
+ deviceData.Device.Power = true;
1058
+ deviceData.Device.SetFanSpeed = state ? 3 : button.previousValue;
1059
+ flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
1060
+ break;
1061
+ case 14: //FAN MODE 4
1062
+ button.previousValue = state ? deviceData.Device.SetFanSpeed : button.previousValue ?? deviceData.Device.SetFanSpeed;
1063
+ deviceData.Device.Power = true;
1064
+ deviceData.Device.SetFanSpeed = state ? 4 : button.previousValue;
1065
+ flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
1066
+ break;
1067
+ case 15: //PHYSICAL LOCK CONTROLS
1068
+ deviceData.Device = deviceData.Device;
1069
+ flag = Ventilation.EffectiveFlags.Prohibit;
1070
+ break;
1071
+ case 16: //ROOM TEMP HIDE
1072
+ deviceData.HideRoomTemperature = state;
1073
+ break;
1074
+ case 17: //SUPPLY TEMP HIDE
1075
+ deviceData.HideSupplyTemperature = state;
1076
+ break;
1077
+ case 18: //OUTDOOR EMP HIDE
1078
+ deviceData.hideOutdoorTemperature = state;
1079
+ break;
1080
+ default:
1081
+ if (this.logWarn) this.emit('warn', `Unknown button mode: ${mode}`);
1082
+ break;
1083
+ };
1084
+
1085
+ if (this.logInfo) this.emit('info', `${state ? `Set: ${buttonName}` : `Unset: ${buttonName}, Set: ${button.previousValue}`}`);
1086
+ await this.melCloudErv.send(this.accountType, this.displayType, deviceData, flag);
1087
+ } catch (error) {
1088
+ if (this.logWarn) this.emit('warn', `Set button error: ${error}`);
1089
+ };
1090
+ });
1091
+ this.buttonControlServices.push(buttonControlService);
1092
+ accessory.addService(buttonControlService);
1093
+ }
1094
+
1095
+ //sensor
1096
+ if (this.logDebug) this.emit('debug', `Prepare button control sensor ${name} service`);
1097
+ const buttonControlSensorService = new serviceType(serviceName, `buttonControlSensorService${deviceId} ${i}`);
1098
+ buttonControlSensorService.addOptionalCharacteristic(Characteristic.ConfiguredName);
1099
+ buttonControlSensorService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
1100
+ buttonControlSensorService.getCharacteristic(characteristicType)
1015
1101
  .onGet(async () => {
1016
1102
  const state = button.state;
1017
1103
  return state;
1018
1104
  })
1019
- .onSet(async (state) => {
1020
- try {
1021
- let flag = null;
1022
- switch (mode) {
1023
- case 0: //POWER ON,OFF
1024
- deviceData.Device.Power = state;
1025
- flag = Ventilation.EffectiveFlags.Power;
1026
- break;
1027
- case 1: //OPERATING MODE RECOVERY
1028
- button.previousValue = state ? deviceData.Device.VentilationMode : button.previousValue ?? deviceData.Device.VentilationMode;
1029
- deviceData.Device.Power = true;
1030
- deviceData.Device.VentilationMode = state ? 0 : button.previousValue;
1031
- flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
1032
- break;
1033
- case 2: //OPERATING MODE BYPASS
1034
- button.previousValue = state ? deviceData.Device.VentilationMode : button.previousValue ?? deviceData.Device.VentilationMode;
1035
- deviceData.Device.Power = true;
1036
- deviceData.Device.VentilationMode = state ? 1 : button.previousValue;
1037
- flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
1038
- break
1039
- case 3: //OPERATING MODE AUTO
1040
- button.previousValue = state ? deviceData.Device.VentilationMode : button.previousValue ?? deviceData.Device.VentilationMode;
1041
- deviceData.Device.Power = true;
1042
- deviceData.Device.VentilationMode = state ? 2 : button.previousValue;
1043
- flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.VentilationMode;
1044
- break;
1045
- case 4: //NIGHT PURGE MODE
1046
- deviceData.Device.Power = true;
1047
- deviceData.Device.NightPurgeMode = state;
1048
- flag = Ventilation.EffectiveFlags.Power
1049
- break;
1050
- case 10: //FAN SPEED MODE AUTO
1051
- button.previousValue = state ? deviceData.Device.SetFanSpeed : button.previousValue ?? deviceData.Device.SetFanSpeed;
1052
- deviceData.Device.Power = true;
1053
- deviceData.Device.SetFanSpeed = state ? 0 : button.previousValue;
1054
- flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
1055
- break;
1056
- case 11: //FAN SPEED MODE 1
1057
- button.previousValue = state ? deviceData.Device.SetFanSpeed : button.previousValue ?? deviceData.Device.SetFanSpeed;
1058
- deviceData.Device.Power = true;
1059
- deviceData.Device.SetFanSpeed = state ? 1 : button.previousValue;
1060
- flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
1061
- break;
1062
- case 12: //FAN SPEED MODE 2
1063
- button.previousValue = state ? deviceData.Device.SetFanSpeed : button.previousValue ?? deviceData.Device.SetFanSpeed;
1064
- deviceData.Device.Power = true;
1065
- deviceData.Device.SetFanSpeed = state ? 2 : button.previousValue;
1066
- flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
1067
- break;
1068
- case 13: //FAN SPEED MODE 3
1069
- button.previousValue = state ? deviceData.Device.SetFanSpeed : button.previousValue ?? deviceData.Device.SetFanSpeed;
1070
- deviceData.Device.Power = true;
1071
- deviceData.Device.SetFanSpeed = state ? 3 : button.previousValue;
1072
- flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
1073
- break;
1074
- case 14: //FAN MODE 4
1075
- button.previousValue = state ? deviceData.Device.SetFanSpeed : button.previousValue ?? deviceData.Device.SetFanSpeed;
1076
- deviceData.Device.Power = true;
1077
- deviceData.Device.SetFanSpeed = state ? 4 : button.previousValue;
1078
- flag = Ventilation.EffectiveFlags.Power + Ventilation.EffectiveFlags.SetFanSpeed;
1079
- break;
1080
- case 15: //PHYSICAL LOCK CONTROLS
1081
- deviceData.Device = deviceData.Device;
1082
- flag = Ventilation.EffectiveFlags.Prohibit;
1083
- break;
1084
- case 16: //ROOM TEMP HIDE
1085
- deviceData.HideRoomTemperature = state;
1086
- break;
1087
- case 17: //SUPPLY TEMP HIDE
1088
- deviceData.HideSupplyTemperature = state;
1089
- break;
1090
- case 18: //OUTDOOR EMP HIDE
1091
- deviceData.hideOutdoorTemperature = state;
1092
- break;
1093
- default:
1094
- if (this.logWarn) this.emit('warn', `Unknown button mode: ${mode}`);
1095
- break;
1096
- };
1097
-
1098
- await this.melCloudErv.send(this.accountType, this.displayType, deviceData, flag);
1099
- if (this.logInfo) this.emit('info', `${state ? `Set: ${buttonName}` : `Unset: ${buttonName}, Set: ${button.previousValue}`}`);
1100
- } catch (error) {
1101
- if (this.logWarn) this.emit('warn', `Set button error: ${error}`);
1102
- };
1103
- });
1104
- this.buttonsServices.push(buttonService);
1105
- accessory.addService(buttonService);
1105
+ this.buttonControlSensorServices.push(buttonControlSensorService);
1106
+ accessory.addService(buttonControlSensorService);
1106
1107
  });
1107
1108
  };
1108
1109
 
@@ -1518,9 +1519,14 @@ class DeviceErv extends EventEmitter {
1518
1519
  break;
1519
1520
  };
1520
1521
 
1521
- //update services
1522
- const characteristicType = button.characteristicType;
1523
- this.buttonsServices?.[i]?.updateCharacteristic(characteristicType, button.state);
1522
+ //control
1523
+ if (button.displayType > 3) {
1524
+ this.buttonControlServices?.[i]?.updateCharacteristic(Characteristic.On, button.state);
1525
+ }
1526
+
1527
+ //sensor
1528
+ const characteristicType = scene.characteristicType;
1529
+ this.buttonControlSensorServices?.[i]?.updateCharacteristic(characteristicType, button.state);
1524
1530
  });
1525
1531
  };
1526
1532