@@ -2887,5 +2887,145 @@ def test_Xiaomi_RTCGQ02LM_timeout_motion():
2887
2887
)
2888
2888
2889
2889
2890
+ def test_Xiaomi_XMPIRO2SXS ():
2891
+ """Test Xiaomi parser for Xiaomi Human Body Sensor 2S XMPIRO2SXS."""
2892
+ data_string = b"HY15\x0b dy\x91 \x17 3\x1e \xf4 \x02 \x00 \x00 \xc5 \xd2 \xf6 \xac "
2893
+ advertisement = bytes_to_service_info (data_string , address = "DC:8E:95:2D:EA:43" )
2894
+ bindkey = "685d647dc5e7bc9bcfcf5a1357bd2114"
2895
+
2896
+ device = XiaomiBluetoothDeviceData (bindkey = bytes .fromhex (bindkey ))
2897
+ assert device .supported (advertisement )
2898
+ assert device .bindkey_verified
2899
+ assert device .update (advertisement ) == SensorUpdate (
2900
+ title = "Motion Sensor EA43 (XMPIRO2SXS)" ,
2901
+ devices = {
2902
+ None : SensorDeviceInfo (
2903
+ name = "Motion Sensor EA43" ,
2904
+ manufacturer = "Xiaomi" ,
2905
+ model = "XMPIRO2SXS" ,
2906
+ hw_version = None ,
2907
+ sw_version = "Xiaomi (MiBeacon V5 encrypted)" ,
2908
+ )
2909
+ },
2910
+ entity_descriptions = {
2911
+ KEY_ILLUMINANCE : SensorDescription (
2912
+ device_key = KEY_ILLUMINANCE ,
2913
+ device_class = DeviceClass .ILLUMINANCE ,
2914
+ native_unit_of_measurement = Units .LIGHT_LUX ,
2915
+ ),
2916
+ KEY_SIGNAL_STRENGTH : SensorDescription (
2917
+ device_key = KEY_SIGNAL_STRENGTH ,
2918
+ device_class = DeviceClass .SIGNAL_STRENGTH ,
2919
+ native_unit_of_measurement = "dBm" ,
2920
+ ),
2921
+ },
2922
+ entity_values = {
2923
+ KEY_ILLUMINANCE : SensorValue (
2924
+ name = "Illuminance" , device_key = KEY_ILLUMINANCE , native_value = 51
2925
+ ),
2926
+ KEY_SIGNAL_STRENGTH : SensorValue (
2927
+ name = "Signal Strength" , device_key = KEY_SIGNAL_STRENGTH , native_value = - 60
2928
+ ),
2929
+ },
2930
+ binary_entity_descriptions = {
2931
+ KEY_BINARY_MOTION : BinarySensorDescription (
2932
+ device_key = KEY_BINARY_MOTION ,
2933
+ device_class = BinarySensorDeviceClass .MOTION ,
2934
+ ),
2935
+ },
2936
+ binary_entity_values = {
2937
+ KEY_BINARY_MOTION : BinarySensorValue (
2938
+ device_key = KEY_BINARY_MOTION , name = "Motion" , native_value = True
2939
+ ),
2940
+ },
2941
+ )
2942
+
2943
+
2944
+ def test_Xiaomi_PTX_press ():
2945
+ """Test Xiaomi parser for Xiaomi PTX."""
2946
+ bindkey = "a74510b40386d35ae6227a7451efc76e"
2947
+ data_string = b"XY\xbb 8\x04 \xad \xb9 \xa5 8\xc1 \xa4 \xdc \x10 \xb5 \x04 \x00 \x00 ,\x12 /\xb6 "
2948
+ advertisement = bytes_to_service_info (data_string , address = "A4:C1:38:A5:B9:AD" )
2949
+
2950
+ device = XiaomiBluetoothDeviceData (bindkey = bytes .fromhex (bindkey ))
2951
+ assert device .supported (advertisement )
2952
+ assert device .bindkey_verified
2953
+ assert device .update (advertisement ) == SensorUpdate (
2954
+ title = "Wireless Switch B9AD (PTX)" ,
2955
+ devices = {
2956
+ None : SensorDeviceInfo (
2957
+ name = "Wireless Switch B9AD" ,
2958
+ manufacturer = "Xiaomi" ,
2959
+ model = "PTX" ,
2960
+ hw_version = None ,
2961
+ sw_version = "Xiaomi (MiBeacon V5 encrypted)" ,
2962
+ )
2963
+ },
2964
+ entity_descriptions = {
2965
+ KEY_SIGNAL_STRENGTH : SensorDescription (
2966
+ device_key = KEY_SIGNAL_STRENGTH ,
2967
+ device_class = DeviceClass .SIGNAL_STRENGTH ,
2968
+ native_unit_of_measurement = "dBm" ,
2969
+ ),
2970
+ },
2971
+ entity_values = {
2972
+ KEY_SIGNAL_STRENGTH : SensorValue (
2973
+ name = "Signal Strength" , device_key = KEY_SIGNAL_STRENGTH , native_value = - 60
2974
+ ),
2975
+ },
2976
+ events = {
2977
+ KEY_EVENT_BUTTON : Event (
2978
+ device_key = KEY_EVENT_BUTTON ,
2979
+ name = "Button" ,
2980
+ event_type = "press" ,
2981
+ event_properties = None ,
2982
+ ),
2983
+ },
2984
+ )
2985
+
2986
+
2987
+ def test_Xiaomi_XMWXKG01LM_press ():
2988
+ """Test Xiaomi parser for Xiaomi XMWXKG01LM ."""
2989
+ bindkey = "7202a2d4201bbf82ea5bb3705657c32a"
2990
+ data_string = b"XY\x87 #5\x05 7$<\xc2 \x18 \xd6 w\x94 \x02 \x00 \x00 \xcb -\xe3 \t "
2991
+ advertisement = bytes_to_service_info (data_string , address = "18:C2:3C:24:37:05" )
2992
+
2993
+ device = XiaomiBluetoothDeviceData (bindkey = bytes .fromhex (bindkey ))
2994
+ assert device .supported (advertisement )
2995
+ assert device .bindkey_verified
2996
+ assert device .update (advertisement ) == SensorUpdate (
2997
+ title = "Button 3705 (XMWXKG01LM)" ,
2998
+ devices = {
2999
+ None : SensorDeviceInfo (
3000
+ name = "Button 3705" ,
3001
+ manufacturer = "Xiaomi" ,
3002
+ model = "XMWXKG01LM" ,
3003
+ hw_version = None ,
3004
+ sw_version = "Xiaomi (MiBeacon V5 encrypted)" ,
3005
+ )
3006
+ },
3007
+ entity_descriptions = {
3008
+ KEY_SIGNAL_STRENGTH : SensorDescription (
3009
+ device_key = KEY_SIGNAL_STRENGTH ,
3010
+ device_class = DeviceClass .SIGNAL_STRENGTH ,
3011
+ native_unit_of_measurement = "dBm" ,
3012
+ ),
3013
+ },
3014
+ entity_values = {
3015
+ KEY_SIGNAL_STRENGTH : SensorValue (
3016
+ name = "Signal Strength" , device_key = KEY_SIGNAL_STRENGTH , native_value = - 60
3017
+ ),
3018
+ },
3019
+ events = {
3020
+ KEY_EVENT_BUTTON : Event (
3021
+ device_key = KEY_EVENT_BUTTON ,
3022
+ name = "Button" ,
3023
+ event_type = "press" ,
3024
+ event_properties = None ,
3025
+ ),
3026
+ },
3027
+ )
3028
+
3029
+
2890
3030
def test_can_create ():
2891
3031
XiaomiBluetoothDeviceData ()
0 commit comments