@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.
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +6 -3
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +245 -167
- package/dist/device/bot.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +10 -6
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +6 -3
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +10 -3
- package/dist/device/device.js.map +1 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +15 -9
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +5 -3
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +10 -6
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +11 -7
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +10 -6
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +10 -6
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +5 -3
- package/dist/device/motion.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +5 -3
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +40 -20
- package/dist/irdevice/other.js.map +1 -1
- package/package.json +1 -1
- package/src/device/blindtilt.ts +6 -3
- package/src/device/bot.ts +322 -244
- package/src/device/contact.ts +10 -6
- package/src/device/curtain.ts +6 -3
- package/src/device/device.ts +10 -3
- package/src/device/hub.ts +15 -9
- package/src/device/humidifier.ts +5 -3
- package/src/device/iosensor.ts +10 -6
- package/src/device/lock.ts +11 -7
- package/src/device/meter.ts +10 -6
- package/src/device/meterplus.ts +10 -6
- package/src/device/motion.ts +5 -3
- package/src/device/waterdetector.ts +5 -3
- package/src/irdevice/other.ts +60 -40
package/dist/device/bot.js
CHANGED
|
@@ -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
|
|
655
|
+
this.Switch?.Service.getCharacteristic(this.hap.Characteristic.On).updateValue(On);
|
|
656
656
|
}
|
|
657
657
|
else {
|
|
658
|
-
this.Outlet
|
|
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
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
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
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
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
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
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
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
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
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
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
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
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
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
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
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
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
|
-
|
|
875
|
-
|
|
876
|
-
|
|
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
|
|
893
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.GarageDoor
|
|
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
|
|
910
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Garage Door On: ${this.GarageDoor
|
|
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
|
|
914
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Door
|
|
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
|
|
933
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Door On: ${this.Door
|
|
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
|
|
937
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Window
|
|
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
|
|
956
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Window On: ${this.Window
|
|
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
|
|
960
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.WindowCovering
|
|
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
|
|
979
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Window Covering On: ${this.WindowCovering
|
|
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
|
|
983
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.LockMechanism
|
|
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
|
|
1000
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Lock On: ${this.LockMechanism
|
|
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
|
|
1004
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Faucet
|
|
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
|
|
1017
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Faucet On: ${this.Faucet
|
|
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
|
|
1021
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Fan
|
|
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
|
|
1034
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Fan On: ${this.Fan
|
|
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
|
|
1038
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.StatefulProgrammableSwitch
|
|
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
|
|
1055
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatefulProgrammableSwitch On: ${this.StatefulProgrammableSwitch
|
|
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
|
|
1059
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Switch
|
|
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
|
|
1069
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Outlet
|
|
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
|
|
1199
|
+
On = this.GarageDoor?.On ? true : false;
|
|
1182
1200
|
}
|
|
1183
1201
|
else if (this.botDeviceType === 'door') {
|
|
1184
|
-
On = this.Door
|
|
1202
|
+
On = this.Door?.On ? true : false;
|
|
1185
1203
|
}
|
|
1186
1204
|
else if (this.botDeviceType === 'window') {
|
|
1187
|
-
On = this.Window
|
|
1205
|
+
On = this.Window?.On ? true : false;
|
|
1188
1206
|
}
|
|
1189
1207
|
else if (this.botDeviceType === 'windowcovering') {
|
|
1190
|
-
On = this.WindowCovering
|
|
1208
|
+
On = this.WindowCovering?.On ? true : false;
|
|
1191
1209
|
}
|
|
1192
1210
|
else if (this.botDeviceType === 'lock') {
|
|
1193
|
-
On = this.LockMechanism
|
|
1211
|
+
On = this.LockMechanism?.On ? true : false;
|
|
1194
1212
|
}
|
|
1195
1213
|
else if (this.botDeviceType === 'faucet') {
|
|
1196
|
-
On = this.Faucet
|
|
1214
|
+
On = this.Faucet?.On ? true : false;
|
|
1197
1215
|
}
|
|
1198
1216
|
else if (this.botDeviceType === 'fan') {
|
|
1199
|
-
On = this.Fan
|
|
1217
|
+
On = this.Fan?.On ? true : false;
|
|
1200
1218
|
}
|
|
1201
1219
|
else if (this.botDeviceType === 'stateful') {
|
|
1202
|
-
On = this.StatefulProgrammableSwitch
|
|
1220
|
+
On = this.StatefulProgrammableSwitch?.On ? true : false;
|
|
1203
1221
|
}
|
|
1204
1222
|
else if (this.botDeviceType === 'switch') {
|
|
1205
|
-
On = this.Switch
|
|
1223
|
+
On = this.Switch?.On ? true : false;
|
|
1206
1224
|
}
|
|
1207
1225
|
else {
|
|
1208
|
-
On = this.Outlet
|
|
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
|
|
1232
|
+
if (this.GarageDoor) {
|
|
1233
|
+
this.GarageDoor.On = On;
|
|
1234
|
+
}
|
|
1215
1235
|
}
|
|
1216
1236
|
else if (this.botDeviceType === 'door') {
|
|
1217
|
-
this.Door
|
|
1237
|
+
if (this.Door) {
|
|
1238
|
+
this.Door.On = On;
|
|
1239
|
+
}
|
|
1218
1240
|
}
|
|
1219
1241
|
else if (this.botDeviceType === 'window') {
|
|
1220
|
-
this.Window
|
|
1242
|
+
if (this.Window) {
|
|
1243
|
+
this.Window.On = On;
|
|
1244
|
+
}
|
|
1221
1245
|
}
|
|
1222
1246
|
else if (this.botDeviceType === 'windowcovering') {
|
|
1223
|
-
this.WindowCovering
|
|
1247
|
+
if (this.WindowCovering) {
|
|
1248
|
+
this.WindowCovering.On = On;
|
|
1249
|
+
}
|
|
1224
1250
|
}
|
|
1225
1251
|
else if (this.botDeviceType === 'lock') {
|
|
1226
|
-
this.LockMechanism
|
|
1252
|
+
if (this.LockMechanism) {
|
|
1253
|
+
this.LockMechanism.On = On;
|
|
1254
|
+
}
|
|
1227
1255
|
}
|
|
1228
1256
|
else if (this.botDeviceType === 'faucet') {
|
|
1229
|
-
this.Faucet
|
|
1257
|
+
if (this.Faucet) {
|
|
1258
|
+
this.Faucet.On = On;
|
|
1259
|
+
}
|
|
1230
1260
|
}
|
|
1231
1261
|
else if (this.botDeviceType === 'fan') {
|
|
1232
|
-
this.Fan
|
|
1262
|
+
if (this.Fan) {
|
|
1263
|
+
this.Fan.On = On;
|
|
1264
|
+
}
|
|
1233
1265
|
}
|
|
1234
1266
|
else if (this.botDeviceType === 'stateful') {
|
|
1235
|
-
this.StatefulProgrammableSwitch
|
|
1267
|
+
if (this.StatefulProgrammableSwitch) {
|
|
1268
|
+
this.StatefulProgrammableSwitch.On = On;
|
|
1269
|
+
}
|
|
1236
1270
|
}
|
|
1237
1271
|
else if (this.botDeviceType === 'switch') {
|
|
1238
|
-
this.Switch
|
|
1272
|
+
if (this.Switch) {
|
|
1273
|
+
this.Switch.On = On;
|
|
1274
|
+
}
|
|
1239
1275
|
}
|
|
1240
1276
|
else {
|
|
1241
|
-
this.Outlet
|
|
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
|
|
1328
|
-
|
|
1329
|
-
|
|
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
|
|
1333
|
-
|
|
1334
|
-
|
|
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
|
|
1338
|
-
|
|
1339
|
-
|
|
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
|
|
1343
|
-
|
|
1344
|
-
|
|
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
|
-
|
|
1348
|
-
|
|
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
|
|
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
|
|
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
|
|
1358
|
-
|
|
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
|
|
1415
|
+
if (this.Switch) {
|
|
1416
|
+
this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, false);
|
|
1417
|
+
}
|
|
1362
1418
|
}
|
|
1363
1419
|
else {
|
|
1364
|
-
this.Outlet
|
|
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
|
|
1371
|
-
|
|
1372
|
-
|
|
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
|
|
1376
|
-
|
|
1377
|
-
|
|
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
|
|
1381
|
-
|
|
1382
|
-
|
|
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
|
|
1386
|
-
|
|
1387
|
-
|
|
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
|
-
|
|
1391
|
-
|
|
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
|
|
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
|
|
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
|
|
1401
|
-
|
|
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
|
|
1478
|
+
if (this.Switch) {
|
|
1479
|
+
this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
1480
|
+
}
|
|
1405
1481
|
}
|
|
1406
1482
|
else {
|
|
1407
|
-
this.Outlet
|
|
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);
|