Skip to content

Commit 1a986da

Browse files
authored
Revert "Ignore advertisments from devices with apple manufacturer id" (#309)
Revert "Ignore advertisments from devices with apple manufacturer id (#306)" This reverts commit 6208b78.
1 parent eb262e2 commit 1a986da

File tree

2 files changed

+2
-33
lines changed

2 files changed

+2
-33
lines changed

switchbot/adv_parser.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141
)
4242
MFR_DATA_ORDER = (2409, 741, 89)
4343

44-
APPLE_MANUFACTURER_ID = 76
45-
4644

4745
class SwitchbotSupportedType(TypedDict):
4846
"""Supported type of Switchbot."""
@@ -250,14 +248,10 @@ def parse_advertisement_data(
250248

251249
_mfr_data = None
252250
_mfr_id = None
253-
manufacturer_data = advertisement_data.manufacturer_data
254-
if APPLE_MANUFACTURER_ID in manufacturer_data:
255-
return None
256-
257251
for mfr_id in MFR_DATA_ORDER:
258-
if mfr_id in manufacturer_data:
252+
if mfr_id in advertisement_data.manufacturer_data:
259253
_mfr_id = mfr_id
260-
_mfr_data = manufacturer_data[mfr_id]
254+
_mfr_data = advertisement_data.manufacturer_data[mfr_id]
261255
break
262256

263257
if _mfr_data is None and _service_data is None:

tests/test_adv_parser.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,28 +1970,3 @@ def test_remote_passive() -> None:
19701970
rssi=-97,
19711971
active=False,
19721972
)
1973-
1974-
1975-
def test_parse_advertisement_ignores_devices_with_apple_manufacturer_id():
1976-
"""Test parse_advertisement_data ignores devices with apple manufacturer id."""
1977-
ble_device = generate_ble_device("aa:bb:cc:dd:ee:ff", "any")
1978-
adv_data = generate_advertisement_data(
1979-
local_name="WoCurtain",
1980-
manufacturer_data={
1981-
89: b"\xcc\xf4\xc4\xf9\xacl",
1982-
2409: b"\xcc\xf4\xc4\xf9\xacl\xe2\x0f\x00\x12\x04",
1983-
76: b"\x10",
1984-
},
1985-
service_data={
1986-
"00000d00-0000-1000-8000-00805f9b34fb": b"c\xd0Yd\x11\x04",
1987-
"0000fd3d-0000-1000-8000-00805f9b34fb": b"c\xc0d\x00\x12\x04",
1988-
},
1989-
service_uuids=[
1990-
"00001800-0000-1000-8000-00805f9b34fb",
1991-
"00001801-0000-1000-8000-00805f9b34fb",
1992-
"cba20d00-224d-11e6-9fb8-0002a5d5c51b",
1993-
],
1994-
rssi=-2,
1995-
)
1996-
result = parse_advertisement_data(ble_device, adv_data)
1997-
assert result is None

0 commit comments

Comments
 (0)