@switchbot/homebridge-switchbot 3.5.0-beta.68 → 3.5.0-beta.69

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.
Files changed (57) hide show
  1. package/dist/device/blindtilt.d.ts.map +1 -1
  2. package/dist/device/blindtilt.js +6 -3
  3. package/dist/device/blindtilt.js.map +1 -1
  4. package/dist/device/bot.d.ts.map +1 -1
  5. package/dist/device/bot.js +245 -167
  6. package/dist/device/bot.js.map +1 -1
  7. package/dist/device/contact.d.ts.map +1 -1
  8. package/dist/device/contact.js +10 -6
  9. package/dist/device/contact.js.map +1 -1
  10. package/dist/device/curtain.d.ts.map +1 -1
  11. package/dist/device/curtain.js +6 -3
  12. package/dist/device/curtain.js.map +1 -1
  13. package/dist/device/device.d.ts.map +1 -1
  14. package/dist/device/device.js +10 -3
  15. package/dist/device/device.js.map +1 -1
  16. package/dist/device/hub.d.ts.map +1 -1
  17. package/dist/device/hub.js +15 -9
  18. package/dist/device/hub.js.map +1 -1
  19. package/dist/device/humidifier.d.ts.map +1 -1
  20. package/dist/device/humidifier.js +5 -3
  21. package/dist/device/humidifier.js.map +1 -1
  22. package/dist/device/iosensor.d.ts.map +1 -1
  23. package/dist/device/iosensor.js +10 -6
  24. package/dist/device/iosensor.js.map +1 -1
  25. package/dist/device/lock.d.ts.map +1 -1
  26. package/dist/device/lock.js +11 -7
  27. package/dist/device/lock.js.map +1 -1
  28. package/dist/device/meter.d.ts.map +1 -1
  29. package/dist/device/meter.js +10 -6
  30. package/dist/device/meter.js.map +1 -1
  31. package/dist/device/meterplus.d.ts.map +1 -1
  32. package/dist/device/meterplus.js +10 -6
  33. package/dist/device/meterplus.js.map +1 -1
  34. package/dist/device/motion.d.ts.map +1 -1
  35. package/dist/device/motion.js +5 -3
  36. package/dist/device/motion.js.map +1 -1
  37. package/dist/device/waterdetector.d.ts.map +1 -1
  38. package/dist/device/waterdetector.js +5 -3
  39. package/dist/device/waterdetector.js.map +1 -1
  40. package/dist/irdevice/other.d.ts.map +1 -1
  41. package/dist/irdevice/other.js +40 -20
  42. package/dist/irdevice/other.js.map +1 -1
  43. package/package.json +1 -1
  44. package/src/device/blindtilt.ts +6 -3
  45. package/src/device/bot.ts +322 -244
  46. package/src/device/contact.ts +10 -6
  47. package/src/device/curtain.ts +6 -3
  48. package/src/device/device.ts +10 -3
  49. package/src/device/hub.ts +15 -9
  50. package/src/device/humidifier.ts +5 -3
  51. package/src/device/iosensor.ts +10 -6
  52. package/src/device/lock.ts +11 -7
  53. package/src/device/meter.ts +10 -6
  54. package/src/device/meterplus.ts +10 -6
  55. package/src/device/motion.ts +5 -3
  56. package/src/device/waterdetector.ts +5 -3
  57. package/src/irdevice/other.ts +60 -40
@@ -652,10 +652,10 @@ export class Bot extends deviceBase {
652
652
  this.accessory.context.On = On;
653
653
  setTimeout(() => {
654
654
  if (this.botDeviceType === 'switch') {
655
- this.Switch.Service.getCharacteristic(this.hap.Characteristic.On).updateValue(On);
655
+ this.Switch?.Service.getCharacteristic(this.hap.Characteristic.On).updateValue(On);
656
656
  }
657
657
  else {
658
- this.Outlet.Service.getCharacteristic(this.hap.Characteristic.On).updateValue(On);
658
+ this.Outlet?.Service.getCharacteristic(this.hap.Characteristic.On).updateValue(On);
659
659
  }
660
660
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${On}, Switch Timeout`);
661
661
  }, 500);
@@ -783,97 +783,115 @@ export class Bot extends deviceBase {
783
783
  */
784
784
  async OnSet(value) {
785
785
  if (this.botDeviceType === 'garagedoor') {
786
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set TargetDoorState: ${value}`);
787
- if (value === this.hap.Characteristic.TargetDoorState.CLOSED) {
788
- await this.setOn(false);
789
- this.GarageDoor.On = false;
790
- }
791
- else {
792
- await this.setOn(true);
793
- this.GarageDoor.On = true;
786
+ if (this.GarageDoor) {
787
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set TargetDoorState: ${value}`);
788
+ if (value === this.hap.Characteristic.TargetDoorState.CLOSED) {
789
+ await this.setOn(false);
790
+ this.GarageDoor.On = false;
791
+ }
792
+ else {
793
+ await this.setOn(true);
794
+ this.GarageDoor.On = true;
795
+ }
794
796
  }
795
797
  }
796
798
  else if (this.botDeviceType === 'door') {
797
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set TargetPosition: ${value}`);
798
- if (value === 0) {
799
- await this.setOn(false);
800
- this.Door.On = false;
801
- }
802
- else {
803
- await this.setOn(true);
804
- this.Door.On = true;
799
+ if (this.Door) {
800
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set TargetPosition: ${value}`);
801
+ if (value === 0) {
802
+ await this.setOn(false);
803
+ this.Door.On = false;
804
+ }
805
+ else {
806
+ await this.setOn(true);
807
+ this.Door.On = true;
808
+ }
805
809
  }
806
810
  }
807
811
  else if (this.botDeviceType === 'window') {
808
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set TargetPosition: ${value}`);
809
- if (value === 0) {
810
- await this.setOn(false);
811
- this.Window.On = false;
812
- }
813
- else {
814
- await this.setOn(true);
815
- this.Window.On = true;
812
+ if (this.Window) {
813
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set TargetPosition: ${value}`);
814
+ if (value === 0) {
815
+ await this.setOn(false);
816
+ this.Window.On = false;
817
+ }
818
+ else {
819
+ await this.setOn(true);
820
+ this.Window.On = true;
821
+ }
816
822
  }
817
823
  }
818
824
  else if (this.botDeviceType === 'windowcovering') {
819
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set TargetPosition: ${value}`);
820
- if (value === 0) {
821
- await this.setOn(false);
822
- this.WindowCovering.On = false;
823
- }
824
- else {
825
- await this.setOn(true);
826
- this.WindowCovering.On = true;
825
+ if (this.WindowCovering) {
826
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set TargetPosition: ${value}`);
827
+ if (value === 0) {
828
+ await this.setOn(false);
829
+ this.WindowCovering.On = false;
830
+ }
831
+ else {
832
+ await this.setOn(true);
833
+ this.WindowCovering.On = true;
834
+ }
827
835
  }
828
836
  }
829
837
  else if (this.botDeviceType === 'lock') {
830
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set LockTargetState: ${value}`);
831
- if (value === this.hap.Characteristic.LockTargetState.SECURED) {
832
- await this.setOn(false);
833
- this.LockMechanism.On = false;
834
- }
835
- else {
836
- await this.setOn(true);
837
- this.LockMechanism.On = true;
838
+ if (this.LockMechanism) {
839
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set LockTargetState: ${value}`);
840
+ if (value === this.hap.Characteristic.LockTargetState.SECURED) {
841
+ await this.setOn(false);
842
+ this.LockMechanism.On = false;
843
+ }
844
+ else {
845
+ await this.setOn(true);
846
+ this.LockMechanism.On = true;
847
+ }
838
848
  }
839
849
  }
840
850
  else if (this.botDeviceType === 'faucet') {
841
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Active: ${value}`);
842
- if (value === this.hap.Characteristic.Active.INACTIVE) {
843
- await this.setOn(false);
844
- this.Faucet.On = false;
845
- }
846
- else {
847
- await this.setOn(true);
848
- this.Faucet.On = true;
851
+ if (this.Faucet) {
852
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Active: ${value}`);
853
+ if (value === this.hap.Characteristic.Active.INACTIVE) {
854
+ await this.setOn(false);
855
+ this.Faucet.On = false;
856
+ }
857
+ else {
858
+ await this.setOn(true);
859
+ this.Faucet.On = true;
860
+ }
849
861
  }
850
862
  }
851
863
  else if (this.botDeviceType === 'stateful') {
852
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set ProgrammableSwitchOutputState: ${value}`);
853
- if (value === 0) {
854
- await this.setOn(false);
855
- this.StatefulProgrammableSwitch.On = false;
856
- }
857
- else {
858
- await this.setOn(true);
859
- this.StatefulProgrammableSwitch.On = true;
864
+ if (this.StatefulProgrammableSwitch) {
865
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set ProgrammableSwitchOutputState: ${value}`);
866
+ if (value === 0) {
867
+ await this.setOn(false);
868
+ this.StatefulProgrammableSwitch.On = false;
869
+ }
870
+ else {
871
+ await this.setOn(true);
872
+ this.StatefulProgrammableSwitch.On = true;
873
+ }
860
874
  }
861
875
  }
862
876
  else if (this.botDeviceType === 'switch') {
863
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set ProgrammableSwitchOutputState: ${value}`);
864
- if (value === 0) {
865
- await this.setOn(false);
866
- this.Switch.On = false;
867
- }
868
- else {
869
- await this.setOn(true);
870
- this.Switch.On = true;
877
+ if (this.Switch) {
878
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set ProgrammableSwitchOutputState: ${value}`);
879
+ if (value === 0) {
880
+ await this.setOn(false);
881
+ this.Switch.On = false;
882
+ }
883
+ else {
884
+ await this.setOn(true);
885
+ this.Switch.On = true;
886
+ }
871
887
  }
872
888
  }
873
889
  else {
874
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set On: ${value}`);
875
- await this.setOn(Boolean(value));
876
- this.Outlet.On = value;
890
+ if (this.Outlet) {
891
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set On: ${value}`);
892
+ await this.setOn(Boolean(value));
893
+ this.Outlet.On = value;
894
+ }
877
895
  }
878
896
  if (this.device.bot?.mode === 'multipress') {
879
897
  if (value === true) {
@@ -889,8 +907,8 @@ export class Bot extends deviceBase {
889
907
  async updateHomeKitCharacteristics() {
890
908
  // State
891
909
  if (this.botDeviceType === 'garagedoor') {
892
- if (this.GarageDoor.On === undefined) {
893
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.GarageDoor.On}`);
910
+ if (this.GarageDoor?.On === undefined) {
911
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.GarageDoor?.On}`);
894
912
  }
895
913
  else {
896
914
  if (this.GarageDoor.On) {
@@ -906,12 +924,12 @@ export class Bot extends deviceBase {
906
924
  + ` TargetDoorState: Open, CurrentDoorState: Open (${this.GarageDoor.On})`);
907
925
  }
908
926
  }
909
- await this.setOn(Boolean(this.GarageDoor.On));
910
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Garage Door On: ${this.GarageDoor.On}`);
927
+ await this.setOn(Boolean(this.GarageDoor?.On));
928
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Garage Door On: ${this.GarageDoor?.On}`);
911
929
  }
912
930
  else if (this.botDeviceType === 'door') {
913
- if (this.Door.On === undefined) {
914
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Door.On}`);
931
+ if (this.Door?.On === undefined) {
932
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Door?.On}`);
915
933
  }
916
934
  else {
917
935
  if (this.Door.On) {
@@ -929,12 +947,12 @@ export class Bot extends deviceBase {
929
947
  + ` TargetPosition: 0, CurrentPosition: 0 (${this.Door.On})`);
930
948
  }
931
949
  }
932
- await this.setOn(Boolean(this.Door.On));
933
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Door On: ${this.Door.On}`);
950
+ await this.setOn(Boolean(this.Door?.On));
951
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Door On: ${this.Door?.On}`);
934
952
  }
935
953
  else if (this.botDeviceType === 'window') {
936
- if (this.Window.On === undefined) {
937
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Window.On}`);
954
+ if (this.Window?.On === undefined) {
955
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Window?.On}`);
938
956
  }
939
957
  else {
940
958
  if (this.Window.On) {
@@ -952,12 +970,12 @@ export class Bot extends deviceBase {
952
970
  + ` TargetPosition: 0, CurrentPosition: 0 (${this.Window.On})`);
953
971
  }
954
972
  }
955
- await this.setOn(Boolean(this.Window.On));
956
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Window On: ${this.Window.On}`);
973
+ await this.setOn(Boolean(this.Window?.On));
974
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Window On: ${this.Window?.On}`);
957
975
  }
958
976
  else if (this.botDeviceType === 'windowcovering') {
959
- if (this.WindowCovering.On === undefined) {
960
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.WindowCovering.On}`);
977
+ if (this.WindowCovering?.On === undefined) {
978
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.WindowCovering?.On}`);
961
979
  }
962
980
  else {
963
981
  if (this.WindowCovering.On) {
@@ -975,12 +993,12 @@ export class Bot extends deviceBase {
975
993
  + ` TargetPosition: 0, CurrentPosition: 0 (${this.WindowCovering.On})`);
976
994
  }
977
995
  }
978
- await this.setOn(Boolean(this.WindowCovering.On));
979
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Window Covering On: ${this.WindowCovering.On}`);
996
+ await this.setOn(Boolean(this.WindowCovering?.On));
997
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Window Covering On: ${this.WindowCovering?.On}`);
980
998
  }
981
999
  else if (this.botDeviceType === 'lock') {
982
- if (this.LockMechanism.On === undefined) {
983
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.LockMechanism.On}`);
1000
+ if (this.LockMechanism?.On === undefined) {
1001
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.LockMechanism?.On}`);
984
1002
  }
985
1003
  else {
986
1004
  if (this.LockMechanism.On) {
@@ -996,12 +1014,12 @@ export class Bot extends deviceBase {
996
1014
  + ` LockTargetState: SECURED, LockCurrentState: SECURED (${this.LockMechanism.On})`);
997
1015
  }
998
1016
  }
999
- await this.setOn(Boolean(this.LockMechanism.On));
1000
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Lock On: ${this.LockMechanism.On}`);
1017
+ await this.setOn(Boolean(this.LockMechanism?.On));
1018
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Lock On: ${this.LockMechanism?.On}`);
1001
1019
  }
1002
1020
  else if (this.botDeviceType === 'faucet') {
1003
- if (this.Faucet.On === undefined) {
1004
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Faucet.On}`);
1021
+ if (this.Faucet?.On === undefined) {
1022
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Faucet?.On}`);
1005
1023
  }
1006
1024
  else {
1007
1025
  if (this.Faucet.On) {
@@ -1013,12 +1031,12 @@ export class Bot extends deviceBase {
1013
1031
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Faucet.On}`);
1014
1032
  }
1015
1033
  }
1016
- await this.setOn(Boolean(this.Faucet.On));
1017
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Faucet On: ${this.Faucet.On}`);
1034
+ await this.setOn(Boolean(this.Faucet?.On));
1035
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Faucet On: ${this.Faucet?.On}`);
1018
1036
  }
1019
1037
  else if (this.botDeviceType === 'fan') {
1020
- if (this.Fan.On === undefined) {
1021
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Fan.On}`);
1038
+ if (this.Fan?.On === undefined) {
1039
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Fan?.On}`);
1022
1040
  }
1023
1041
  else {
1024
1042
  if (this.Fan.On) {
@@ -1030,12 +1048,12 @@ export class Bot extends deviceBase {
1030
1048
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.Fan.On}`);
1031
1049
  }
1032
1050
  }
1033
- await this.setOn(Boolean(this.Fan.On));
1034
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Fan On: ${this.Fan.On}`);
1051
+ await this.setOn(Boolean(this.Fan?.On));
1052
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Fan On: ${this.Fan?.On}`);
1035
1053
  }
1036
1054
  else if (this.botDeviceType === 'stateful') {
1037
- if (this.StatefulProgrammableSwitch.On === undefined) {
1038
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.StatefulProgrammableSwitch.On}`);
1055
+ if (this.StatefulProgrammableSwitch?.On === undefined) {
1056
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.StatefulProgrammableSwitch?.On}`);
1039
1057
  }
1040
1058
  else {
1041
1059
  if (this.StatefulProgrammableSwitch.On) {
@@ -1051,29 +1069,29 @@ export class Bot extends deviceBase {
1051
1069
  + ` ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 0 (${this.StatefulProgrammableSwitch.On})`);
1052
1070
  }
1053
1071
  }
1054
- await this.setOn(Boolean(this.StatefulProgrammableSwitch.On));
1055
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatefulProgrammableSwitch On: ${this.StatefulProgrammableSwitch.On}`);
1072
+ await this.setOn(Boolean(this.StatefulProgrammableSwitch?.On));
1073
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatefulProgrammableSwitch On: ${this.StatefulProgrammableSwitch?.On}`);
1056
1074
  }
1057
1075
  else if (this.botDeviceType === 'switch') {
1058
- if (this.Switch.On === undefined) {
1059
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Switch.On}`);
1076
+ if (this.Switch?.On === undefined) {
1077
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Switch?.On}`);
1060
1078
  }
1061
1079
  else {
1062
1080
  this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, this.Switch.On);
1063
1081
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.Switch.On}`);
1064
- await this.setOn(Boolean(this.Switch.On));
1065
1082
  }
1083
+ await this.setOn(Boolean(this.Switch?.On));
1066
1084
  }
1067
1085
  else {
1068
- if (this.Outlet.On === undefined) {
1069
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Outlet.On}`);
1086
+ if (this.Outlet?.On === undefined) {
1087
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Outlet?.On}`);
1070
1088
  }
1071
1089
  else {
1072
1090
  this.Outlet.Service.updateCharacteristic(this.hap.Characteristic.On, this.Outlet.On);
1073
1091
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.Outlet.On}`);
1074
1092
  }
1093
+ await this.setOn(Boolean(this.Outlet?.On));
1075
1094
  }
1076
- await this.setOn(Boolean(this.Outlet.On));
1077
1095
  this.accessory.context.On = await this.getOn();
1078
1096
  // BatteryLevel
1079
1097
  if (this.Battery.BatteryLevel === undefined) {
@@ -1178,67 +1196,87 @@ export class Bot extends deviceBase {
1178
1196
  async getOn() {
1179
1197
  let On;
1180
1198
  if (this.botDeviceType === 'garagedoor') {
1181
- On = this.GarageDoor.On ? true : false;
1199
+ On = this.GarageDoor?.On ? true : false;
1182
1200
  }
1183
1201
  else if (this.botDeviceType === 'door') {
1184
- On = this.Door.On ? true : false;
1202
+ On = this.Door?.On ? true : false;
1185
1203
  }
1186
1204
  else if (this.botDeviceType === 'window') {
1187
- On = this.Window.On ? true : false;
1205
+ On = this.Window?.On ? true : false;
1188
1206
  }
1189
1207
  else if (this.botDeviceType === 'windowcovering') {
1190
- On = this.WindowCovering.On ? true : false;
1208
+ On = this.WindowCovering?.On ? true : false;
1191
1209
  }
1192
1210
  else if (this.botDeviceType === 'lock') {
1193
- On = this.LockMechanism.On ? true : false;
1211
+ On = this.LockMechanism?.On ? true : false;
1194
1212
  }
1195
1213
  else if (this.botDeviceType === 'faucet') {
1196
- On = this.Faucet.On ? true : false;
1214
+ On = this.Faucet?.On ? true : false;
1197
1215
  }
1198
1216
  else if (this.botDeviceType === 'fan') {
1199
- On = this.Fan.On ? true : false;
1217
+ On = this.Fan?.On ? true : false;
1200
1218
  }
1201
1219
  else if (this.botDeviceType === 'stateful') {
1202
- On = this.StatefulProgrammableSwitch.On ? true : false;
1220
+ On = this.StatefulProgrammableSwitch?.On ? true : false;
1203
1221
  }
1204
1222
  else if (this.botDeviceType === 'switch') {
1205
- On = this.Switch.On ? true : false;
1223
+ On = this.Switch?.On ? true : false;
1206
1224
  }
1207
1225
  else {
1208
- On = this.Outlet.On ? true : false;
1226
+ On = this.Outlet?.On ? true : false;
1209
1227
  }
1210
1228
  return On;
1211
1229
  }
1212
1230
  async setOn(On) {
1213
1231
  if (this.botDeviceType === 'garagedoor') {
1214
- this.GarageDoor.On = On;
1232
+ if (this.GarageDoor) {
1233
+ this.GarageDoor.On = On;
1234
+ }
1215
1235
  }
1216
1236
  else if (this.botDeviceType === 'door') {
1217
- this.Door.On = On;
1237
+ if (this.Door) {
1238
+ this.Door.On = On;
1239
+ }
1218
1240
  }
1219
1241
  else if (this.botDeviceType === 'window') {
1220
- this.Window.On = On;
1242
+ if (this.Window) {
1243
+ this.Window.On = On;
1244
+ }
1221
1245
  }
1222
1246
  else if (this.botDeviceType === 'windowcovering') {
1223
- this.WindowCovering.On = On;
1247
+ if (this.WindowCovering) {
1248
+ this.WindowCovering.On = On;
1249
+ }
1224
1250
  }
1225
1251
  else if (this.botDeviceType === 'lock') {
1226
- this.LockMechanism.On = On;
1252
+ if (this.LockMechanism) {
1253
+ this.LockMechanism.On = On;
1254
+ }
1227
1255
  }
1228
1256
  else if (this.botDeviceType === 'faucet') {
1229
- this.Faucet.On = On;
1257
+ if (this.Faucet) {
1258
+ this.Faucet.On = On;
1259
+ }
1230
1260
  }
1231
1261
  else if (this.botDeviceType === 'fan') {
1232
- this.Fan.On = On;
1262
+ if (this.Fan) {
1263
+ this.Fan.On = On;
1264
+ }
1233
1265
  }
1234
1266
  else if (this.botDeviceType === 'stateful') {
1235
- this.StatefulProgrammableSwitch.On = On;
1267
+ if (this.StatefulProgrammableSwitch) {
1268
+ this.StatefulProgrammableSwitch.On = On;
1269
+ }
1236
1270
  }
1237
1271
  else if (this.botDeviceType === 'switch') {
1238
- this.Switch.On = On;
1272
+ if (this.Switch) {
1273
+ this.Switch.On = On;
1274
+ }
1239
1275
  }
1240
1276
  else {
1241
- this.Outlet.On = On;
1277
+ if (this.Outlet) {
1278
+ this.Outlet.On = On;
1279
+ }
1242
1280
  }
1243
1281
  }
1244
1282
  async getBotConfigSettings(device) {
@@ -1324,87 +1362,127 @@ export class Bot extends deviceBase {
1324
1362
  async offlineOff() {
1325
1363
  if (this.device.offline) {
1326
1364
  if (this.botDeviceType === 'garagedoor') {
1327
- this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, this.hap.Characteristic.TargetDoorState.CLOSED);
1328
- this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, this.hap.Characteristic.CurrentDoorState.CLOSED);
1329
- this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.ObstructionDetected, false);
1365
+ if (this.GarageDoor) {
1366
+ this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, this.hap.Characteristic.TargetDoorState.CLOSED);
1367
+ this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, this.hap.Characteristic.CurrentDoorState.CLOSED);
1368
+ this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.ObstructionDetected, false);
1369
+ }
1330
1370
  }
1331
1371
  else if (this.botDeviceType === 'door') {
1332
- this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
1333
- this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
1334
- this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
1372
+ if (this.Door) {
1373
+ this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
1374
+ this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
1375
+ this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
1376
+ }
1335
1377
  }
1336
1378
  else if (this.botDeviceType === 'window') {
1337
- this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
1338
- this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
1339
- this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
1379
+ if (this.Window) {
1380
+ this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
1381
+ this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
1382
+ this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
1383
+ }
1340
1384
  }
1341
1385
  else if (this.botDeviceType === 'windowcovering') {
1342
- this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
1343
- this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
1344
- this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
1386
+ if (this.WindowCovering) {
1387
+ this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
1388
+ this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
1389
+ this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
1390
+ }
1345
1391
  }
1346
1392
  else if (this.botDeviceType === 'lock') {
1347
- this.Door.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.SECURED);
1348
- this.Door.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.SECURED);
1393
+ if (this.LockMechanism) {
1394
+ this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.SECURED);
1395
+ this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.SECURED);
1396
+ }
1349
1397
  }
1350
1398
  else if (this.botDeviceType === 'faucet') {
1351
- this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.INACTIVE);
1399
+ if (this.Faucet) {
1400
+ this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.INACTIVE);
1401
+ }
1352
1402
  }
1353
1403
  else if (this.botDeviceType === 'fan') {
1354
- this.Fan.Service.updateCharacteristic(this.hap.Characteristic.On, false);
1404
+ if (this.Fan) {
1405
+ this.Fan.Service.updateCharacteristic(this.hap.Characteristic.On, false);
1406
+ }
1355
1407
  }
1356
1408
  else if (this.botDeviceType === 'stateful') {
1357
- this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
1358
- this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, 0);
1409
+ if (this.StatefulProgrammableSwitch) {
1410
+ this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
1411
+ this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, 0);
1412
+ }
1359
1413
  }
1360
1414
  else if (this.botDeviceType === 'switch') {
1361
- this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, false);
1415
+ if (this.Switch) {
1416
+ this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, false);
1417
+ }
1362
1418
  }
1363
1419
  else {
1364
- this.Outlet.Service.updateCharacteristic(this.hap.Characteristic.On, false);
1420
+ if (this.Outlet) {
1421
+ this.Outlet.Service.updateCharacteristic(this.hap.Characteristic.On, false);
1422
+ }
1365
1423
  }
1366
1424
  }
1367
1425
  }
1368
1426
  async apiError(e) {
1369
1427
  if (this.botDeviceType === 'garagedoor') {
1370
- this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, e);
1371
- this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, e);
1372
- this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.ObstructionDetected, e);
1428
+ if (this.GarageDoor) {
1429
+ this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, e);
1430
+ this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, e);
1431
+ this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.ObstructionDetected, e);
1432
+ }
1373
1433
  }
1374
1434
  else if (this.botDeviceType === 'door') {
1375
- this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e);
1376
- this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e);
1377
- this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e);
1435
+ if (this.Door) {
1436
+ this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e);
1437
+ this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e);
1438
+ this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e);
1439
+ }
1378
1440
  }
1379
1441
  else if (this.botDeviceType === 'window') {
1380
- this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e);
1381
- this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e);
1382
- this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e);
1442
+ if (this.Window) {
1443
+ this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e);
1444
+ this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e);
1445
+ this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e);
1446
+ }
1383
1447
  }
1384
1448
  else if (this.botDeviceType === 'windowcovering') {
1385
- this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e);
1386
- this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e);
1387
- this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e);
1449
+ if (this.WindowCovering) {
1450
+ this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e);
1451
+ this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e);
1452
+ this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e);
1453
+ }
1388
1454
  }
1389
1455
  else if (this.botDeviceType === 'lock') {
1390
- this.Door.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, e);
1391
- this.Door.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, e);
1456
+ if (this.LockMechanism) {
1457
+ this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, e);
1458
+ this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, e);
1459
+ }
1392
1460
  }
1393
1461
  else if (this.botDeviceType === 'faucet') {
1394
- this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, e);
1462
+ if (this.Faucet) {
1463
+ this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, e);
1464
+ }
1395
1465
  }
1396
1466
  else if (this.botDeviceType === 'fan') {
1397
- this.Fan.Service.updateCharacteristic(this.hap.Characteristic.On, e);
1467
+ if (this.Fan) {
1468
+ this.Fan.Service.updateCharacteristic(this.hap.Characteristic.On, e);
1469
+ }
1398
1470
  }
1399
1471
  else if (this.botDeviceType === 'stateful') {
1400
- this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, e);
1401
- this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, e);
1472
+ if (this.StatefulProgrammableSwitch) {
1473
+ this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, e);
1474
+ this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, e);
1475
+ }
1402
1476
  }
1403
1477
  else if (this.botDeviceType === 'switch') {
1404
- this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, e);
1478
+ if (this.Switch) {
1479
+ this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, e);
1480
+ }
1405
1481
  }
1406
1482
  else {
1407
- this.Outlet.Service.updateCharacteristic(this.hap.Characteristic.On, e);
1483
+ if (this.Outlet) {
1484
+ this.Outlet.Service.updateCharacteristic(this.hap.Characteristic.On, e);
1485
+ }
1408
1486
  }
1409
1487
  this.Battery.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, e);
1410
1488
  this.Battery.Service.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, e);