@@ -964,6 +964,40 @@ def test_wosensor_active_zero_data():
964964 )
965965
966966
967+ def test_wohub2_passive_and_active ():
968+ """Test parsing wosensor as passive with active data as well."""
969+ ble_device = generate_ble_device ("aa:bb:cc:dd:ee:ff" , "any" )
970+ adv_data = generate_advertisement_data (
971+ manufacturer_data = {
972+ 2409 : b"\xaa \xbb \xcc \xdd \xee \xff \x00 \xff fT\x1a \xf1 \x82 \x07 \x9a 2\x00 "
973+ },
974+ service_data = {"0000fd3d-0000-1000-8000-00805f9b34fb" : b"v\x00 " },
975+ tx_power = - 127 ,
976+ rssi = - 50 ,
977+ )
978+ result = parse_advertisement_data (ble_device , adv_data )
979+ assert result == SwitchBotAdvertisement (
980+ address = "aa:bb:cc:dd:ee:ff" ,
981+ data = {
982+ "data" : {
983+ "fahrenheit" : False ,
984+ "humidity" : 50 ,
985+ "lightLevel" : 2 ,
986+ "temp" : {"c" : 26.7 , "f" : 80.06 },
987+ "temperature" : 26.7 ,
988+ },
989+ "isEncrypted" : False ,
990+ "model" : "v" ,
991+ "modelFriendlyName" : "Hub 2" ,
992+ "modelName" : SwitchbotModel .HUB2 ,
993+ "rawAdvData" : b"v\x00 " ,
994+ },
995+ device = ble_device ,
996+ rssi = - 50 ,
997+ active = True ,
998+ )
999+
1000+
9671001def test_woiosensor_passive_and_active ():
9681002 """Test parsing woiosensor as passive with active data as well."""
9691003 ble_device = generate_ble_device ("aa:bb:cc:dd:ee:ff" , "any" )
@@ -1286,43 +1320,6 @@ def test_motion_with_light_detected():
12861320 )
12871321
12881322
1289- def test_motion_sensor_motion_passive ():
1290- """Test parsing motion sensor with motion data."""
1291- ble_device = generate_ble_device ("aa:bb:cc:dd:ee:ff" , "any" )
1292- adv_data = generate_advertisement_data (
1293- manufacturer_data = {2409 : b"\xc0 !\x9a \xe8 \xbc Ii\\ \x00 8" },
1294- service_data = {},
1295- tx_power = - 127 ,
1296- rssi = - 87 ,
1297- )
1298- result = parse_advertisement_data (
1299- ble_device , adv_data , SwitchbotModel .MOTION_SENSOR
1300- )
1301- assert result == SwitchBotAdvertisement (
1302- address = "aa:bb:cc:dd:ee:ff" ,
1303- data = {
1304- "data" : {
1305- "battery" : None ,
1306- "iot" : None ,
1307- "is_light" : False ,
1308- "led" : None ,
1309- "light_intensity" : None ,
1310- "motion_detected" : True ,
1311- "sense_distance" : None ,
1312- "tested" : None ,
1313- },
1314- "isEncrypted" : False ,
1315- "model" : "s" ,
1316- "modelFriendlyName" : "Motion Sensor" ,
1317- "modelName" : SwitchbotModel .MOTION_SENSOR ,
1318- "rawAdvData" : None ,
1319- },
1320- device = ble_device ,
1321- rssi = - 87 ,
1322- active = False ,
1323- )
1324-
1325-
13261323def test_parsing_lock_active ():
13271324 """Test parsing lock with active data."""
13281325 ble_device = generate_ble_device ("aa:bb:cc:dd:ee:ff" , "any" )
0 commit comments