@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/src/device/bot.ts
CHANGED
|
@@ -744,9 +744,9 @@ export class Bot extends deviceBase {
|
|
|
744
744
|
this.accessory.context.On = On;
|
|
745
745
|
setTimeout(() => {
|
|
746
746
|
if (this.botDeviceType === 'switch') {
|
|
747
|
-
this.Switch
|
|
747
|
+
this.Switch?.Service.getCharacteristic(this.hap.Characteristic.On).updateValue(On);
|
|
748
748
|
} else {
|
|
749
|
-
this.Outlet
|
|
749
|
+
this.Outlet?.Service.getCharacteristic(this.hap.Characteristic.On).updateValue(On);
|
|
750
750
|
}
|
|
751
751
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${On}, Switch Timeout`);
|
|
752
752
|
}, 500);
|
|
@@ -868,81 +868,99 @@ export class Bot extends deviceBase {
|
|
|
868
868
|
*/
|
|
869
869
|
async OnSet(value: CharacteristicValue): Promise<void> {
|
|
870
870
|
if (this.botDeviceType === 'garagedoor') {
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
871
|
+
if (this.GarageDoor) {
|
|
872
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set TargetDoorState: ${value}`);
|
|
873
|
+
if (value === this.hap.Characteristic.TargetDoorState.CLOSED) {
|
|
874
|
+
await this.setOn(false);
|
|
875
|
+
this.GarageDoor.On = false;
|
|
876
|
+
} else {
|
|
877
|
+
await this.setOn(true);
|
|
878
|
+
this.GarageDoor.On = true;
|
|
879
|
+
}
|
|
878
880
|
}
|
|
879
881
|
} else if (this.botDeviceType === 'door') {
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
882
|
+
if (this.Door) {
|
|
883
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set TargetPosition: ${value}`);
|
|
884
|
+
if (value === 0) {
|
|
885
|
+
await this.setOn(false);
|
|
886
|
+
this.Door.On = false;
|
|
887
|
+
} else {
|
|
888
|
+
await this.setOn(true);
|
|
889
|
+
this.Door.On = true;
|
|
890
|
+
}
|
|
887
891
|
}
|
|
888
892
|
} else if (this.botDeviceType === 'window') {
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
893
|
+
if (this.Window) {
|
|
894
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set TargetPosition: ${value}`);
|
|
895
|
+
if (value === 0) {
|
|
896
|
+
await this.setOn(false);
|
|
897
|
+
this.Window.On = false;
|
|
898
|
+
} else {
|
|
899
|
+
await this.setOn(true);
|
|
900
|
+
this.Window.On = true;
|
|
901
|
+
}
|
|
896
902
|
}
|
|
897
903
|
} else if (this.botDeviceType === 'windowcovering') {
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
904
|
+
if (this.WindowCovering) {
|
|
905
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set TargetPosition: ${value}`);
|
|
906
|
+
if (value === 0) {
|
|
907
|
+
await this.setOn(false);
|
|
908
|
+
this.WindowCovering.On = false;
|
|
909
|
+
} else {
|
|
910
|
+
await this.setOn(true);
|
|
911
|
+
this.WindowCovering.On = true;
|
|
912
|
+
}
|
|
905
913
|
}
|
|
906
914
|
} else if (this.botDeviceType === 'lock') {
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
915
|
+
if (this.LockMechanism) {
|
|
916
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set LockTargetState: ${value}`);
|
|
917
|
+
if (value === this.hap.Characteristic.LockTargetState.SECURED) {
|
|
918
|
+
await this.setOn(false);
|
|
919
|
+
this.LockMechanism.On = false;
|
|
920
|
+
} else {
|
|
921
|
+
await this.setOn(true);
|
|
922
|
+
this.LockMechanism.On = true;
|
|
923
|
+
}
|
|
914
924
|
}
|
|
915
925
|
} else if (this.botDeviceType === 'faucet') {
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
926
|
+
if (this.Faucet) {
|
|
927
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Active: ${value}`);
|
|
928
|
+
if (value === this.hap.Characteristic.Active.INACTIVE) {
|
|
929
|
+
await this.setOn(false);
|
|
930
|
+
this.Faucet.On = false;
|
|
931
|
+
} else {
|
|
932
|
+
await this.setOn(true);
|
|
933
|
+
this.Faucet.On = true;
|
|
934
|
+
}
|
|
923
935
|
}
|
|
924
936
|
} else if (this.botDeviceType === 'stateful') {
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
937
|
+
if (this.StatefulProgrammableSwitch) {
|
|
938
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set ProgrammableSwitchOutputState: ${value}`);
|
|
939
|
+
if (value === 0) {
|
|
940
|
+
await this.setOn(false);
|
|
941
|
+
this.StatefulProgrammableSwitch.On = false;
|
|
942
|
+
} else {
|
|
943
|
+
await this.setOn(true);
|
|
944
|
+
this.StatefulProgrammableSwitch.On = true;
|
|
945
|
+
}
|
|
932
946
|
}
|
|
933
947
|
} else if (this.botDeviceType === 'switch') {
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
948
|
+
if (this.Switch) {
|
|
949
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set ProgrammableSwitchOutputState: ${value}`);
|
|
950
|
+
if (value === 0) {
|
|
951
|
+
await this.setOn(false);
|
|
952
|
+
this.Switch.On = false;
|
|
953
|
+
} else {
|
|
954
|
+
await this.setOn(true);
|
|
955
|
+
this.Switch.On = true;
|
|
956
|
+
}
|
|
941
957
|
}
|
|
942
958
|
} else {
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
959
|
+
if (this.Outlet) {
|
|
960
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set On: ${value}`);
|
|
961
|
+
await this.setOn(Boolean(value));
|
|
962
|
+
this.Outlet.On = value;
|
|
963
|
+
}
|
|
946
964
|
}
|
|
947
965
|
if (this.device.bot?.mode === 'multipress') {
|
|
948
966
|
if (value === true) {
|
|
@@ -959,177 +977,177 @@ export class Bot extends deviceBase {
|
|
|
959
977
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
960
978
|
// State
|
|
961
979
|
if (this.botDeviceType === 'garagedoor') {
|
|
962
|
-
if (this.GarageDoor
|
|
963
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.GarageDoor
|
|
980
|
+
if (this.GarageDoor?.On === undefined) {
|
|
981
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.GarageDoor?.On}`);
|
|
964
982
|
} else {
|
|
965
|
-
if (this.GarageDoor
|
|
966
|
-
this.GarageDoor
|
|
967
|
-
this.GarageDoor
|
|
983
|
+
if (this.GarageDoor.On) {
|
|
984
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, this.hap.Characteristic.TargetDoorState.OPEN);
|
|
985
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, this.hap.Characteristic.CurrentDoorState.OPEN);
|
|
968
986
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
969
|
-
+ ` TargetDoorState: Open, CurrentDoorState: Open (${this.GarageDoor
|
|
987
|
+
+ ` TargetDoorState: Open, CurrentDoorState: Open (${this.GarageDoor.On})`);
|
|
970
988
|
} else {
|
|
971
|
-
this.GarageDoor
|
|
972
|
-
this.GarageDoor
|
|
989
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, this.hap.Characteristic.TargetDoorState.CLOSED);
|
|
990
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, this.hap.Characteristic.CurrentDoorState.CLOSED);
|
|
973
991
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristicc`
|
|
974
|
-
+ ` TargetDoorState: Open, CurrentDoorState: Open (${this.GarageDoor
|
|
992
|
+
+ ` TargetDoorState: Open, CurrentDoorState: Open (${this.GarageDoor.On})`);
|
|
975
993
|
}
|
|
976
994
|
}
|
|
977
|
-
await this.setOn(Boolean(this.GarageDoor
|
|
978
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Garage Door On: ${this.GarageDoor
|
|
995
|
+
await this.setOn(Boolean(this.GarageDoor?.On));
|
|
996
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Garage Door On: ${this.GarageDoor?.On}`);
|
|
979
997
|
} else if (this.botDeviceType === 'door') {
|
|
980
|
-
if (this.Door
|
|
981
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Door
|
|
998
|
+
if (this.Door?.On === undefined) {
|
|
999
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Door?.On}`);
|
|
982
1000
|
} else {
|
|
983
|
-
if (this.Door
|
|
984
|
-
this.Door
|
|
985
|
-
this.Door
|
|
986
|
-
this.Door
|
|
1001
|
+
if (this.Door.On) {
|
|
1002
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
|
|
1003
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
|
|
1004
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
987
1005
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristicc`
|
|
988
|
-
+ ` TargetPosition: 100, CurrentPosition: 100 (${this.Door
|
|
1006
|
+
+ ` TargetPosition: 100, CurrentPosition: 100 (${this.Door.On})`);
|
|
989
1007
|
} else {
|
|
990
|
-
this.Door
|
|
991
|
-
this.Door
|
|
992
|
-
this.Door
|
|
1008
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
1009
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
1010
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
993
1011
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristicc`
|
|
994
|
-
+ ` TargetPosition: 0, CurrentPosition: 0 (${this.Door
|
|
1012
|
+
+ ` TargetPosition: 0, CurrentPosition: 0 (${this.Door.On})`);
|
|
995
1013
|
}
|
|
996
1014
|
}
|
|
997
|
-
await this.setOn(Boolean(this.Door
|
|
998
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Door On: ${this.Door
|
|
1015
|
+
await this.setOn(Boolean(this.Door?.On));
|
|
1016
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Door On: ${this.Door?.On}`);
|
|
999
1017
|
} else if (this.botDeviceType === 'window') {
|
|
1000
|
-
if (this.Window
|
|
1001
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Window
|
|
1018
|
+
if (this.Window?.On === undefined) {
|
|
1019
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Window?.On}`);
|
|
1002
1020
|
} else {
|
|
1003
|
-
if (this.Window
|
|
1004
|
-
this.Window
|
|
1005
|
-
this.Window
|
|
1006
|
-
this.Window
|
|
1021
|
+
if (this.Window.On) {
|
|
1022
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
|
|
1023
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
|
|
1024
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
1007
1025
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristicc`
|
|
1008
|
-
+ ` TargetPosition: 100, CurrentPosition: 100 (${this.Window
|
|
1026
|
+
+ ` TargetPosition: 100, CurrentPosition: 100 (${this.Window.On})`);
|
|
1009
1027
|
} else {
|
|
1010
|
-
this.Window
|
|
1011
|
-
this.Window
|
|
1012
|
-
this.Window
|
|
1028
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
1029
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
1030
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
1013
1031
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristicc`
|
|
1014
|
-
+ ` TargetPosition: 0, CurrentPosition: 0 (${this.Window
|
|
1032
|
+
+ ` TargetPosition: 0, CurrentPosition: 0 (${this.Window.On})`);
|
|
1015
1033
|
}
|
|
1016
1034
|
}
|
|
1017
|
-
await this.setOn(Boolean(this.Window
|
|
1018
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Window On: ${this.Window
|
|
1035
|
+
await this.setOn(Boolean(this.Window?.On));
|
|
1036
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Window On: ${this.Window?.On}`);
|
|
1019
1037
|
} else if (this.botDeviceType === 'windowcovering') {
|
|
1020
|
-
if (this.WindowCovering
|
|
1021
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.WindowCovering
|
|
1038
|
+
if (this.WindowCovering?.On === undefined) {
|
|
1039
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.WindowCovering?.On}`);
|
|
1022
1040
|
} else {
|
|
1023
|
-
if (this.WindowCovering
|
|
1024
|
-
this.WindowCovering
|
|
1025
|
-
this.WindowCovering
|
|
1026
|
-
this.WindowCovering
|
|
1041
|
+
if (this.WindowCovering.On) {
|
|
1042
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
|
|
1043
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
|
|
1044
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
1027
1045
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristicc`
|
|
1028
|
-
+ ` TargetPosition: 100, CurrentPosition: 100 (${this.WindowCovering
|
|
1046
|
+
+ ` TargetPosition: 100, CurrentPosition: 100 (${this.WindowCovering.On})`);
|
|
1029
1047
|
} else {
|
|
1030
|
-
this.WindowCovering
|
|
1031
|
-
this.WindowCovering
|
|
1032
|
-
this.WindowCovering
|
|
1048
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
1049
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
1050
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
1033
1051
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristicc`
|
|
1034
|
-
+ ` TargetPosition: 0, CurrentPosition: 0 (${this.WindowCovering
|
|
1052
|
+
+ ` TargetPosition: 0, CurrentPosition: 0 (${this.WindowCovering.On})`);
|
|
1035
1053
|
}
|
|
1036
1054
|
}
|
|
1037
|
-
await this.setOn(Boolean(this.WindowCovering
|
|
1038
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Window Covering On: ${this.WindowCovering
|
|
1055
|
+
await this.setOn(Boolean(this.WindowCovering?.On));
|
|
1056
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Window Covering On: ${this.WindowCovering?.On}`);
|
|
1039
1057
|
} else if (this.botDeviceType === 'lock') {
|
|
1040
|
-
if (this.LockMechanism
|
|
1041
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.LockMechanism
|
|
1058
|
+
if (this.LockMechanism?.On === undefined) {
|
|
1059
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.LockMechanism?.On}`);
|
|
1042
1060
|
} else {
|
|
1043
|
-
if (this.LockMechanism
|
|
1044
|
-
this.LockMechanism
|
|
1061
|
+
if (this.LockMechanism.On) {
|
|
1062
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState,
|
|
1045
1063
|
this.hap.Characteristic.LockTargetState.UNSECURED);
|
|
1046
|
-
this.LockMechanism
|
|
1064
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState,
|
|
1047
1065
|
this.hap.Characteristic.LockCurrentState.UNSECURED);
|
|
1048
1066
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristicc`
|
|
1049
|
-
+ ` LockTargetState: UNSECURED, LockCurrentState: UNSECURED (${this.LockMechanism
|
|
1067
|
+
+ ` LockTargetState: UNSECURED, LockCurrentState: UNSECURED (${this.LockMechanism.On})`);
|
|
1050
1068
|
} else {
|
|
1051
|
-
this.LockMechanism
|
|
1069
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState,
|
|
1052
1070
|
this.hap.Characteristic.LockTargetState.SECURED);
|
|
1053
|
-
this.LockMechanism
|
|
1071
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState,
|
|
1054
1072
|
this.hap.Characteristic.LockCurrentState.SECURED);
|
|
1055
1073
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
1056
|
-
+ ` LockTargetState: SECURED, LockCurrentState: SECURED (${this.LockMechanism
|
|
1074
|
+
+ ` LockTargetState: SECURED, LockCurrentState: SECURED (${this.LockMechanism.On})`);
|
|
1057
1075
|
}
|
|
1058
1076
|
}
|
|
1059
|
-
await this.setOn(Boolean(this.LockMechanism
|
|
1060
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Lock On: ${this.LockMechanism
|
|
1077
|
+
await this.setOn(Boolean(this.LockMechanism?.On));
|
|
1078
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Lock On: ${this.LockMechanism?.On}`);
|
|
1061
1079
|
} else if (this.botDeviceType === 'faucet') {
|
|
1062
|
-
if (this.Faucet
|
|
1063
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Faucet
|
|
1080
|
+
if (this.Faucet?.On === undefined) {
|
|
1081
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Faucet?.On}`);
|
|
1064
1082
|
} else {
|
|
1065
|
-
if (this.Faucet
|
|
1066
|
-
this.Faucet
|
|
1067
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Faucet
|
|
1083
|
+
if (this.Faucet.On) {
|
|
1084
|
+
this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.ACTIVE);
|
|
1085
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Faucet.On}`);
|
|
1068
1086
|
} else {
|
|
1069
|
-
this.Faucet
|
|
1070
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Faucet
|
|
1087
|
+
this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.INACTIVE);
|
|
1088
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Faucet.On}`);
|
|
1071
1089
|
}
|
|
1072
1090
|
}
|
|
1073
|
-
await this.setOn(Boolean(this.Faucet
|
|
1074
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Faucet On: ${this.Faucet
|
|
1091
|
+
await this.setOn(Boolean(this.Faucet?.On));
|
|
1092
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Faucet On: ${this.Faucet?.On}`);
|
|
1075
1093
|
} else if (this.botDeviceType === 'fan') {
|
|
1076
|
-
if (this.Fan
|
|
1077
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Fan
|
|
1094
|
+
if (this.Fan?.On === undefined) {
|
|
1095
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Fan?.On}`);
|
|
1078
1096
|
} else {
|
|
1079
|
-
if (this.Fan
|
|
1080
|
-
this.Fan
|
|
1081
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.Fan
|
|
1097
|
+
if (this.Fan.On) {
|
|
1098
|
+
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.On, this.Fan.On);
|
|
1099
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.Fan.On}`);
|
|
1082
1100
|
} else {
|
|
1083
|
-
this.Fan
|
|
1084
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.Fan
|
|
1101
|
+
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.On, this.Fan.On);
|
|
1102
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.Fan.On}`);
|
|
1085
1103
|
}
|
|
1086
1104
|
}
|
|
1087
|
-
await this.setOn(Boolean(this.Fan
|
|
1088
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Fan On: ${this.Fan
|
|
1105
|
+
await this.setOn(Boolean(this.Fan?.On));
|
|
1106
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Fan On: ${this.Fan?.On}`);
|
|
1089
1107
|
} else if (this.botDeviceType === 'stateful') {
|
|
1090
|
-
if (this.StatefulProgrammableSwitch
|
|
1091
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.StatefulProgrammableSwitch
|
|
1108
|
+
if (this.StatefulProgrammableSwitch?.On === undefined) {
|
|
1109
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.StatefulProgrammableSwitch?.On}`);
|
|
1092
1110
|
} else {
|
|
1093
|
-
if (this.StatefulProgrammableSwitch
|
|
1094
|
-
this.StatefulProgrammableSwitch
|
|
1111
|
+
if (this.StatefulProgrammableSwitch.On) {
|
|
1112
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent,
|
|
1095
1113
|
this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
|
|
1096
|
-
this.StatefulProgrammableSwitch
|
|
1114
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, 1);
|
|
1097
1115
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
1098
|
-
+ ` ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 1 (${this.StatefulProgrammableSwitch
|
|
1116
|
+
+ ` ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 1 (${this.StatefulProgrammableSwitch.On})`);
|
|
1099
1117
|
} else {
|
|
1100
|
-
this.StatefulProgrammableSwitch
|
|
1118
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent,
|
|
1101
1119
|
this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
|
|
1102
|
-
this.StatefulProgrammableSwitch
|
|
1120
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, 0);
|
|
1103
1121
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
1104
|
-
+ ` ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 0 (${this.StatefulProgrammableSwitch
|
|
1122
|
+
+ ` ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 0 (${this.StatefulProgrammableSwitch.On})`);
|
|
1105
1123
|
}
|
|
1106
1124
|
}
|
|
1107
|
-
await this.setOn(Boolean(this.StatefulProgrammableSwitch
|
|
1108
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatefulProgrammableSwitch On: ${this.StatefulProgrammableSwitch
|
|
1125
|
+
await this.setOn(Boolean(this.StatefulProgrammableSwitch?.On));
|
|
1126
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatefulProgrammableSwitch On: ${this.StatefulProgrammableSwitch?.On}`);
|
|
1109
1127
|
} else if (this.botDeviceType === 'switch') {
|
|
1110
|
-
if (this.Switch
|
|
1111
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Switch
|
|
1128
|
+
if (this.Switch?.On === undefined) {
|
|
1129
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Switch?.On}`);
|
|
1112
1130
|
} else {
|
|
1113
|
-
this.Switch
|
|
1114
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.Switch
|
|
1115
|
-
await this.setOn(Boolean(this.Switch!.On));
|
|
1131
|
+
this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, this.Switch.On);
|
|
1132
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.Switch.On}`);
|
|
1116
1133
|
}
|
|
1134
|
+
await this.setOn(Boolean(this.Switch?.On));
|
|
1117
1135
|
} else {
|
|
1118
|
-
if (this.Outlet
|
|
1119
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Outlet
|
|
1136
|
+
if (this.Outlet?.On === undefined) {
|
|
1137
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.Outlet?.On}`);
|
|
1120
1138
|
} else {
|
|
1121
|
-
this.Outlet
|
|
1122
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.Outlet
|
|
1139
|
+
this.Outlet.Service.updateCharacteristic(this.hap.Characteristic.On, this.Outlet.On);
|
|
1140
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.Outlet.On}`);
|
|
1123
1141
|
}
|
|
1142
|
+
await this.setOn(Boolean(this.Outlet?.On));
|
|
1124
1143
|
}
|
|
1125
|
-
await this.setOn(Boolean(this.Outlet!.On));
|
|
1126
1144
|
this.accessory.context.On = await this.getOn();
|
|
1127
1145
|
// BatteryLevel
|
|
1128
1146
|
if (this.Battery.BatteryLevel === undefined) {
|
|
1129
1147
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.Battery.BatteryLevel}`);
|
|
1130
1148
|
} else {
|
|
1131
1149
|
this.accessory.context.BatteryLevel = this.Battery.BatteryLevel;
|
|
1132
|
-
this.Battery
|
|
1150
|
+
this.Battery.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, this.Battery.BatteryLevel);
|
|
1133
1151
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.Battery.BatteryLevel}`);
|
|
1134
1152
|
}
|
|
1135
1153
|
// StatusLowBattery
|
|
@@ -1137,7 +1155,7 @@ export class Bot extends deviceBase {
|
|
|
1137
1155
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatusLowBattery: ${this.Battery.StatusLowBattery}`);
|
|
1138
1156
|
} else {
|
|
1139
1157
|
this.accessory.context.StatusLowBattery = this.Battery.StatusLowBattery;
|
|
1140
|
-
this.Battery
|
|
1158
|
+
this.Battery.Service.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, this.Battery.StatusLowBattery);
|
|
1141
1159
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
1142
1160
|
+ ` StatusLowBattery: ${this.Battery.StatusLowBattery}`);
|
|
1143
1161
|
}
|
|
@@ -1146,140 +1164,160 @@ export class Bot extends deviceBase {
|
|
|
1146
1164
|
async removeOutletService(accessory: PlatformAccessory): Promise<void> {
|
|
1147
1165
|
// If outletService still present, then remove first
|
|
1148
1166
|
if (this.Outlet?.Service) {
|
|
1149
|
-
this.Outlet
|
|
1167
|
+
this.Outlet.Service = this.accessory.getService(this.hap.Service.Outlet) as Service;
|
|
1150
1168
|
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Outlet Service`);
|
|
1151
|
-
accessory.removeService(this.Outlet
|
|
1169
|
+
accessory.removeService(this.Outlet.Service);
|
|
1152
1170
|
}
|
|
1153
1171
|
}
|
|
1154
1172
|
|
|
1155
1173
|
async removeGarageDoorService(accessory: PlatformAccessory): Promise<void> {
|
|
1156
1174
|
// If garageDoorService still present, then remove first
|
|
1157
1175
|
if (this.GarageDoor?.Service) {
|
|
1158
|
-
this.GarageDoor
|
|
1176
|
+
this.GarageDoor.Service = this.accessory.getService(this.hap.Service.GarageDoorOpener) as Service;
|
|
1159
1177
|
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Garage Door Service`);
|
|
1160
|
-
accessory.removeService(this.GarageDoor
|
|
1178
|
+
accessory.removeService(this.GarageDoor.Service);
|
|
1161
1179
|
}
|
|
1162
1180
|
}
|
|
1163
1181
|
|
|
1164
1182
|
async removeDoorService(accessory: PlatformAccessory): Promise<void> {
|
|
1165
1183
|
// If doorService still present, then remove first
|
|
1166
1184
|
if (this.Door?.Service) {
|
|
1167
|
-
this.Door
|
|
1185
|
+
this.Door.Service = this.accessory.getService(this.hap.Service.Door) as Service;
|
|
1168
1186
|
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Door Service`);
|
|
1169
|
-
accessory.removeService(this.Door
|
|
1187
|
+
accessory.removeService(this.Door.Service);
|
|
1170
1188
|
}
|
|
1171
1189
|
}
|
|
1172
1190
|
|
|
1173
1191
|
async removeLockService(accessory: PlatformAccessory): Promise<void> {
|
|
1174
1192
|
// If lockService still present, then remove first
|
|
1175
1193
|
if (this.LockMechanism?.Service) {
|
|
1176
|
-
this.LockMechanism
|
|
1194
|
+
this.LockMechanism.Service = this.accessory.getService(this.hap.Service.LockMechanism) as Service;
|
|
1177
1195
|
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Lock Service`);
|
|
1178
|
-
accessory.removeService(this.LockMechanism
|
|
1196
|
+
accessory.removeService(this.LockMechanism.Service);
|
|
1179
1197
|
}
|
|
1180
1198
|
}
|
|
1181
1199
|
|
|
1182
1200
|
async removeFaucetService(accessory: PlatformAccessory): Promise<void> {
|
|
1183
1201
|
// If faucetService still present, then remove first
|
|
1184
1202
|
if (this.Faucet?.Service) {
|
|
1185
|
-
this.Faucet
|
|
1203
|
+
this.Faucet.Service = this.accessory.getService(this.hap.Service.Faucet) as Service;
|
|
1186
1204
|
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Faucet Service`);
|
|
1187
|
-
accessory.removeService(this.Faucet
|
|
1205
|
+
accessory.removeService(this.Faucet.Service);
|
|
1188
1206
|
}
|
|
1189
1207
|
}
|
|
1190
1208
|
|
|
1191
1209
|
async removeFanService(accessory: PlatformAccessory): Promise<void> {
|
|
1192
1210
|
// If fanService still present, then remove first
|
|
1193
1211
|
if (this.Fan?.Service) {
|
|
1194
|
-
this.Fan
|
|
1212
|
+
this.Fan.Service = this.accessory.getService(this.hap.Service.Fanv2) as Service;
|
|
1195
1213
|
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Fan Service`);
|
|
1196
|
-
accessory.removeService(this.Fan
|
|
1214
|
+
accessory.removeService(this.Fan.Service);
|
|
1197
1215
|
}
|
|
1198
1216
|
}
|
|
1199
1217
|
|
|
1200
1218
|
async removeWindowService(accessory: PlatformAccessory): Promise<void> {
|
|
1201
1219
|
// If windowService still present, then remove first
|
|
1202
1220
|
if (this.Window?.Service) {
|
|
1203
|
-
this.Window
|
|
1221
|
+
this.Window.Service = this.accessory.getService(this.hap.Service.Window) as Service;
|
|
1204
1222
|
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Window Service`);
|
|
1205
|
-
accessory.removeService(this.Window
|
|
1223
|
+
accessory.removeService(this.Window.Service);
|
|
1206
1224
|
}
|
|
1207
1225
|
}
|
|
1208
1226
|
|
|
1209
1227
|
async removeWindowCoveringService(accessory: PlatformAccessory): Promise<void> {
|
|
1210
1228
|
// If windowCoveringService still present, then remove first
|
|
1211
1229
|
if (this.WindowCovering?.Service) {
|
|
1212
|
-
this.WindowCovering
|
|
1230
|
+
this.WindowCovering.Service = this.accessory.getService(this.hap.Service.WindowCovering) as Service;
|
|
1213
1231
|
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Window Covering Service`);
|
|
1214
|
-
accessory.removeService(this.WindowCovering
|
|
1232
|
+
accessory.removeService(this.WindowCovering.Service);
|
|
1215
1233
|
}
|
|
1216
1234
|
}
|
|
1217
1235
|
|
|
1218
1236
|
async removeStatefulProgrammableSwitchService(accessory: PlatformAccessory): Promise<void> {
|
|
1219
1237
|
// If statefulProgrammableSwitchService still present, then remove first
|
|
1220
1238
|
if (this.StatefulProgrammableSwitch?.Service) {
|
|
1221
|
-
this.StatefulProgrammableSwitch
|
|
1239
|
+
this.StatefulProgrammableSwitch.Service = this.accessory.getService(this.hap.Service.StatefulProgrammableSwitch) as Service;
|
|
1222
1240
|
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
|
|
1223
|
-
accessory.removeService(this.StatefulProgrammableSwitch
|
|
1241
|
+
accessory.removeService(this.StatefulProgrammableSwitch.Service);
|
|
1224
1242
|
}
|
|
1225
1243
|
}
|
|
1226
1244
|
|
|
1227
1245
|
async removeSwitchService(accessory: PlatformAccessory): Promise<void> {
|
|
1228
1246
|
// If switchService still present, then remove first
|
|
1229
1247
|
if (this.Switch?.Service) {
|
|
1230
|
-
this.Switch
|
|
1248
|
+
this.Switch.Service = this.accessory.getService(this.hap.Service.Switch) as Service;
|
|
1231
1249
|
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Switch Service`);
|
|
1232
|
-
accessory.removeService(this.Switch
|
|
1250
|
+
accessory.removeService(this.Switch.Service);
|
|
1233
1251
|
}
|
|
1234
1252
|
}
|
|
1235
1253
|
|
|
1236
1254
|
async getOn(): Promise<boolean> {
|
|
1237
1255
|
let On: boolean;
|
|
1238
1256
|
if (this.botDeviceType === 'garagedoor') {
|
|
1239
|
-
On = this.GarageDoor
|
|
1257
|
+
On = this.GarageDoor?.On ? true : false;
|
|
1240
1258
|
} else if (this.botDeviceType === 'door') {
|
|
1241
|
-
On = this.Door
|
|
1259
|
+
On = this.Door?.On ? true : false;
|
|
1242
1260
|
} else if (this.botDeviceType === 'window') {
|
|
1243
|
-
On = this.Window
|
|
1261
|
+
On = this.Window?.On ? true : false;
|
|
1244
1262
|
} else if (this.botDeviceType === 'windowcovering') {
|
|
1245
|
-
On = this.WindowCovering
|
|
1263
|
+
On = this.WindowCovering?.On ? true : false;
|
|
1246
1264
|
} else if (this.botDeviceType === 'lock') {
|
|
1247
|
-
On = this.LockMechanism
|
|
1265
|
+
On = this.LockMechanism?.On ? true : false;
|
|
1248
1266
|
} else if (this.botDeviceType === 'faucet') {
|
|
1249
|
-
On = this.Faucet
|
|
1267
|
+
On = this.Faucet?.On ? true : false;
|
|
1250
1268
|
} else if (this.botDeviceType === 'fan') {
|
|
1251
|
-
On = this.Fan
|
|
1269
|
+
On = this.Fan?.On ? true : false;
|
|
1252
1270
|
} else if (this.botDeviceType === 'stateful') {
|
|
1253
|
-
On = this.StatefulProgrammableSwitch
|
|
1271
|
+
On = this.StatefulProgrammableSwitch?.On ? true : false;
|
|
1254
1272
|
} else if (this.botDeviceType === 'switch') {
|
|
1255
|
-
On = this.Switch
|
|
1273
|
+
On = this.Switch?.On ? true : false;
|
|
1256
1274
|
} else {
|
|
1257
|
-
On = this.Outlet
|
|
1275
|
+
On = this.Outlet?.On ? true : false;
|
|
1258
1276
|
}
|
|
1259
1277
|
return On;
|
|
1260
1278
|
}
|
|
1261
1279
|
|
|
1262
1280
|
async setOn(On: boolean): Promise<void> {
|
|
1263
1281
|
if (this.botDeviceType === 'garagedoor') {
|
|
1264
|
-
this.GarageDoor
|
|
1282
|
+
if (this.GarageDoor) {
|
|
1283
|
+
this.GarageDoor.On = On;
|
|
1284
|
+
}
|
|
1265
1285
|
} else if (this.botDeviceType === 'door') {
|
|
1266
|
-
this.Door
|
|
1286
|
+
if (this.Door) {
|
|
1287
|
+
this.Door.On = On;
|
|
1288
|
+
}
|
|
1267
1289
|
} else if (this.botDeviceType === 'window') {
|
|
1268
|
-
this.Window
|
|
1290
|
+
if (this.Window) {
|
|
1291
|
+
this.Window.On = On;
|
|
1292
|
+
}
|
|
1269
1293
|
} else if (this.botDeviceType === 'windowcovering') {
|
|
1270
|
-
this.WindowCovering
|
|
1294
|
+
if (this.WindowCovering) {
|
|
1295
|
+
this.WindowCovering.On = On;
|
|
1296
|
+
}
|
|
1271
1297
|
} else if (this.botDeviceType === 'lock') {
|
|
1272
|
-
this.LockMechanism
|
|
1298
|
+
if (this.LockMechanism) {
|
|
1299
|
+
this.LockMechanism.On = On;
|
|
1300
|
+
}
|
|
1273
1301
|
} else if (this.botDeviceType === 'faucet') {
|
|
1274
|
-
this.Faucet
|
|
1302
|
+
if (this.Faucet) {
|
|
1303
|
+
this.Faucet.On = On;
|
|
1304
|
+
}
|
|
1275
1305
|
} else if (this.botDeviceType === 'fan') {
|
|
1276
|
-
this.Fan
|
|
1306
|
+
if (this.Fan) {
|
|
1307
|
+
this.Fan.On = On;
|
|
1308
|
+
}
|
|
1277
1309
|
} else if (this.botDeviceType === 'stateful') {
|
|
1278
|
-
this.StatefulProgrammableSwitch
|
|
1310
|
+
if (this.StatefulProgrammableSwitch) {
|
|
1311
|
+
this.StatefulProgrammableSwitch.On = On;
|
|
1312
|
+
}
|
|
1279
1313
|
} else if (this.botDeviceType === 'switch') {
|
|
1280
|
-
this.Switch
|
|
1314
|
+
if (this.Switch) {
|
|
1315
|
+
this.Switch.On = On;
|
|
1316
|
+
}
|
|
1281
1317
|
} else {
|
|
1282
|
-
this.Outlet
|
|
1318
|
+
if (this.Outlet) {
|
|
1319
|
+
this.Outlet.On = On;
|
|
1320
|
+
}
|
|
1283
1321
|
}
|
|
1284
1322
|
}
|
|
1285
1323
|
|
|
@@ -1363,71 +1401,111 @@ export class Bot extends deviceBase {
|
|
|
1363
1401
|
async offlineOff(): Promise<void> {
|
|
1364
1402
|
if (this.device.offline) {
|
|
1365
1403
|
if (this.botDeviceType === 'garagedoor') {
|
|
1366
|
-
this.GarageDoor
|
|
1367
|
-
|
|
1368
|
-
|
|
1404
|
+
if (this.GarageDoor) {
|
|
1405
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, this.hap.Characteristic.TargetDoorState.CLOSED);
|
|
1406
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, this.hap.Characteristic.CurrentDoorState.CLOSED);
|
|
1407
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.ObstructionDetected, false);
|
|
1408
|
+
}
|
|
1369
1409
|
} else if (this.botDeviceType === 'door') {
|
|
1370
|
-
this.Door
|
|
1371
|
-
|
|
1372
|
-
|
|
1410
|
+
if (this.Door) {
|
|
1411
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
1412
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
1413
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
1414
|
+
}
|
|
1373
1415
|
} else if (this.botDeviceType === 'window') {
|
|
1374
|
-
this.Window
|
|
1375
|
-
|
|
1376
|
-
|
|
1416
|
+
if (this.Window) {
|
|
1417
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
1418
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
1419
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
1420
|
+
}
|
|
1377
1421
|
} else if (this.botDeviceType === 'windowcovering') {
|
|
1378
|
-
this.WindowCovering
|
|
1379
|
-
|
|
1380
|
-
|
|
1422
|
+
if (this.WindowCovering) {
|
|
1423
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
1424
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
1425
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
1426
|
+
}
|
|
1381
1427
|
} else if (this.botDeviceType === 'lock') {
|
|
1382
|
-
|
|
1383
|
-
|
|
1428
|
+
if (this.LockMechanism) {
|
|
1429
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.SECURED);
|
|
1430
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.SECURED);
|
|
1431
|
+
}
|
|
1384
1432
|
} else if (this.botDeviceType === 'faucet') {
|
|
1385
|
-
this.Faucet
|
|
1433
|
+
if (this.Faucet) {
|
|
1434
|
+
this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.INACTIVE);
|
|
1435
|
+
}
|
|
1386
1436
|
} else if (this.botDeviceType === 'fan') {
|
|
1387
|
-
this.Fan
|
|
1437
|
+
if (this.Fan) {
|
|
1438
|
+
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.On, false);
|
|
1439
|
+
}
|
|
1388
1440
|
} else if (this.botDeviceType === 'stateful') {
|
|
1389
|
-
this.StatefulProgrammableSwitch
|
|
1390
|
-
this.hap.Characteristic.ProgrammableSwitchEvent
|
|
1391
|
-
|
|
1441
|
+
if (this.StatefulProgrammableSwitch) {
|
|
1442
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent,
|
|
1443
|
+
this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
|
|
1444
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, 0);
|
|
1445
|
+
}
|
|
1392
1446
|
} else if (this.botDeviceType === 'switch') {
|
|
1393
|
-
this.Switch
|
|
1447
|
+
if (this.Switch) {
|
|
1448
|
+
this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, false);
|
|
1449
|
+
}
|
|
1394
1450
|
} else {
|
|
1395
|
-
this.Outlet
|
|
1451
|
+
if (this.Outlet) {
|
|
1452
|
+
this.Outlet.Service.updateCharacteristic(this.hap.Characteristic.On, false);
|
|
1453
|
+
}
|
|
1396
1454
|
}
|
|
1397
1455
|
}
|
|
1398
1456
|
}
|
|
1399
1457
|
|
|
1400
1458
|
async apiError(e: any): Promise<void> {
|
|
1401
1459
|
if (this.botDeviceType === 'garagedoor') {
|
|
1402
|
-
this.GarageDoor
|
|
1403
|
-
|
|
1404
|
-
|
|
1460
|
+
if (this.GarageDoor) {
|
|
1461
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, e);
|
|
1462
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, e);
|
|
1463
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.ObstructionDetected, e);
|
|
1464
|
+
}
|
|
1405
1465
|
} else if (this.botDeviceType === 'door') {
|
|
1406
|
-
this.Door
|
|
1407
|
-
|
|
1408
|
-
|
|
1466
|
+
if (this.Door) {
|
|
1467
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e);
|
|
1468
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e);
|
|
1469
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e);
|
|
1470
|
+
}
|
|
1409
1471
|
} else if (this.botDeviceType === 'window') {
|
|
1410
|
-
this.Window
|
|
1411
|
-
|
|
1412
|
-
|
|
1472
|
+
if (this.Window) {
|
|
1473
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e);
|
|
1474
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e);
|
|
1475
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e);
|
|
1476
|
+
}
|
|
1413
1477
|
} else if (this.botDeviceType === 'windowcovering') {
|
|
1414
|
-
this.WindowCovering
|
|
1415
|
-
|
|
1416
|
-
|
|
1478
|
+
if (this.WindowCovering) {
|
|
1479
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e);
|
|
1480
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e);
|
|
1481
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e);
|
|
1482
|
+
}
|
|
1417
1483
|
} else if (this.botDeviceType === 'lock') {
|
|
1418
|
-
|
|
1419
|
-
|
|
1484
|
+
if (this.LockMechanism) {
|
|
1485
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, e);
|
|
1486
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, e);
|
|
1487
|
+
}
|
|
1420
1488
|
} else if (this.botDeviceType === 'faucet') {
|
|
1421
|
-
this.Faucet
|
|
1489
|
+
if (this.Faucet) {
|
|
1490
|
+
this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, e);
|
|
1491
|
+
}
|
|
1422
1492
|
} else if (this.botDeviceType === 'fan') {
|
|
1423
|
-
this.Fan
|
|
1493
|
+
if (this.Fan) {
|
|
1494
|
+
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
1495
|
+
}
|
|
1424
1496
|
} else if (this.botDeviceType === 'stateful') {
|
|
1425
|
-
this.StatefulProgrammableSwitch
|
|
1426
|
-
|
|
1497
|
+
if (this.StatefulProgrammableSwitch) {
|
|
1498
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, e);
|
|
1499
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, e);
|
|
1500
|
+
}
|
|
1427
1501
|
} else if (this.botDeviceType === 'switch') {
|
|
1428
|
-
this.Switch
|
|
1502
|
+
if (this.Switch) {
|
|
1503
|
+
this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
1504
|
+
}
|
|
1429
1505
|
} else {
|
|
1430
|
-
this.Outlet
|
|
1506
|
+
if (this.Outlet) {
|
|
1507
|
+
this.Outlet.Service.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
1508
|
+
}
|
|
1431
1509
|
}
|
|
1432
1510
|
this.Battery.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, e);
|
|
1433
1511
|
this.Battery.Service.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, e);
|