Skip to content

Commit b8667a1

Browse files
authored
Fix missing id for motion sensors in adv parser (#159)
1 parent 046abe7 commit b8667a1

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

switchbot/adv_parser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class SwitchbotSupportedType(TypedDict):
5959
"modelName": SwitchbotModel.MOTION_SENSOR,
6060
"modelFriendlyName": "Motion Sensor",
6161
"func": process_wopresence,
62+
"manufacturer_id": 2409,
6263
"manufacturer_data_length": 10,
6364
},
6465
"r": {

tests/test_adv_parser.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,3 +1020,37 @@ def test_motion_with_light_detected():
10201020
device=ble_device,
10211021
rssi=-84,
10221022
)
1023+
1024+
1025+
def test_motion_sensor_motion_passive():
1026+
"""Test parsing motion sensor with motion data."""
1027+
ble_device = BLEDevice("aa:bb:cc:dd:ee:ff", "any")
1028+
adv_data = generate_advertisement_data(
1029+
manufacturer_data={2409: b"\xc0!\x9a\xe8\xbcIi\\\x008"},
1030+
service_data={},
1031+
tx_power=-127,
1032+
rssi=-87,
1033+
)
1034+
result = parse_advertisement_data(ble_device, adv_data)
1035+
assert result == SwitchBotAdvertisement(
1036+
address="aa:bb:cc:dd:ee:ff",
1037+
data={
1038+
"data": {
1039+
"battery": None,
1040+
"iot": None,
1041+
"is_light": False,
1042+
"led": None,
1043+
"light_intensity": None,
1044+
"motion_detected": True,
1045+
"sense_distance": None,
1046+
"tested": None,
1047+
},
1048+
"isEncrypted": False,
1049+
"model": "s",
1050+
"modelFriendlyName": "Motion Sensor",
1051+
"modelName": SwitchbotModel.MOTION_SENSOR,
1052+
"rawAdvData": None,
1053+
},
1054+
device=ble_device,
1055+
rssi=-87,
1056+
)

0 commit comments

Comments
 (0)