From c53de4be9adb02bfa38735bad35dbb1a1b74be48 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 16 Sep 2023 08:54:38 -0500 Subject: [PATCH] Remove passive detection of contact sensors We cannot tell these apart from the new Curtain v3 with only passive data so best not to be wrong about what the device is --- switchbot/adv_parser.py | 1 - tests/test_adv_parser.py | 26 ++++---------------------- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/switchbot/adv_parser.py b/switchbot/adv_parser.py index 5605a5b..d0c62ef 100644 --- a/switchbot/adv_parser.py +++ b/switchbot/adv_parser.py @@ -49,7 +49,6 @@ class SwitchbotSupportedType(TypedDict): "modelFriendlyName": "Contact Sensor", "func": process_wocontact, "manufacturer_id": 2409, - "manufacturer_data_length": 13, }, "H": { "modelName": SwitchbotModel.BOT, diff --git a/tests/test_adv_parser.py b/tests/test_adv_parser.py index ed4c403..6fe0b24 100644 --- a/tests/test_adv_parser.py +++ b/tests/test_adv_parser.py @@ -593,28 +593,10 @@ def test_contact_sensor_mfr_no_service_data(): rssi=-70, ) result = parse_advertisement_data(ble_device, adv_data) - assert result == SwitchBotAdvertisement( - address="aa:bb:cc:dd:ee:ff", - data={ - "data": { - "battery": None, - "button_count": 4, - "contact_open": True, - "contact_timeout": True, - "is_light": False, - "motion_detected": False, - "tested": None, - }, - "isEncrypted": False, - "model": "d", - "modelFriendlyName": "Contact Sensor", - "modelName": SwitchbotModel.CONTACT_SENSOR, - "rawAdvData": None, - }, - device=ble_device, - rssi=-70, - active=False, - ) + # Passive detection of contact sensor is not supported + # anymore since the Switchbot Curtain v3 was released + # which uses the heuristics for the contact sensor. + assert result is None def test_contact_sensor_srv():