From ed36fe47d77fec477f473d47f4a74ac2f4596413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20J=C3=A1l?= Date: Fri, 23 Aug 2024 00:05:27 +0200 Subject: [PATCH] disable detection of night latch for lock pro (#247) --- switchbot/adv_parsers/lock.py | 3 ++- tests/test_adv_parser.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/switchbot/adv_parsers/lock.py b/switchbot/adv_parsers/lock.py index 1ce35ac..30f9964 100644 --- a/switchbot/adv_parsers/lock.py +++ b/switchbot/adv_parsers/lock.py @@ -49,7 +49,8 @@ def process_wolock_pro( "unclosed_alarm": bool(mfr_data[11] & 0b10000000), "unlocked_alarm": bool(mfr_data[11] & 0b01000000), "auto_lock_paused": bool(mfr_data[8] & 0b100000), - "night_latch": bool(mfr_data[9] & 0b00000001), + # Looks like night latch bit is not anymore in ADV + "night_latch": False, } _LOGGER.debug(res) return res diff --git a/tests/test_adv_parser.py b/tests/test_adv_parser.py index 684aa43..76c2efb 100644 --- a/tests/test_adv_parser.py +++ b/tests/test_adv_parser.py @@ -1459,6 +1459,39 @@ def test_parsing_lock_pro_passive(): ) +def test_parsing_lock_pro_passive_nightlatch_disabled(): + ble_device = generate_ble_device("aa:bb:cc:dd:ee:ff", "any") + adv_data = generate_advertisement_data( + manufacturer_data={2409: bytes.fromhex("aabbccddeeff0a8200630000")}, rssi=-67 + ) + result = parse_advertisement_data(ble_device, adv_data, SwitchbotModel.LOCK_PRO) + assert result == SwitchBotAdvertisement( + address="aa:bb:cc:dd:ee:ff", + data={ + "data": { + "battery": None, + "calibration": True, + "status": LockStatus.LOCKED, + "update_from_secondary_lock": False, + "door_open": False, + "double_lock_mode": False, + "unclosed_alarm": False, + "unlocked_alarm": False, + "auto_lock_paused": False, + "night_latch": False, + }, + "model": "$", + "isEncrypted": False, + "modelFriendlyName": "Lock Pro", + "modelName": SwitchbotModel.LOCK_PRO, + "rawAdvData": None, + }, + device=ble_device, + rssi=-67, + active=False, + ) + + def test_parsing_lock_active_old_firmware(): """Test parsing lock with active data. Old firmware.""" ble_device = generate_ble_device("aa:bb:cc:dd:ee:ff", "any")