Skip to content

Commit ed36fe4

Browse files
authored
disable detection of night latch for lock pro (#247)
1 parent 29216b5 commit ed36fe4

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

switchbot/adv_parsers/lock.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ def process_wolock_pro(
4949
"unclosed_alarm": bool(mfr_data[11] & 0b10000000),
5050
"unlocked_alarm": bool(mfr_data[11] & 0b01000000),
5151
"auto_lock_paused": bool(mfr_data[8] & 0b100000),
52-
"night_latch": bool(mfr_data[9] & 0b00000001),
52+
# Looks like night latch bit is not anymore in ADV
53+
"night_latch": False,
5354
}
5455
_LOGGER.debug(res)
5556
return res

tests/test_adv_parser.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,6 +1459,39 @@ def test_parsing_lock_pro_passive():
14591459
)
14601460

14611461

1462+
def test_parsing_lock_pro_passive_nightlatch_disabled():
1463+
ble_device = generate_ble_device("aa:bb:cc:dd:ee:ff", "any")
1464+
adv_data = generate_advertisement_data(
1465+
manufacturer_data={2409: bytes.fromhex("aabbccddeeff0a8200630000")}, rssi=-67
1466+
)
1467+
result = parse_advertisement_data(ble_device, adv_data, SwitchbotModel.LOCK_PRO)
1468+
assert result == SwitchBotAdvertisement(
1469+
address="aa:bb:cc:dd:ee:ff",
1470+
data={
1471+
"data": {
1472+
"battery": None,
1473+
"calibration": True,
1474+
"status": LockStatus.LOCKED,
1475+
"update_from_secondary_lock": False,
1476+
"door_open": False,
1477+
"double_lock_mode": False,
1478+
"unclosed_alarm": False,
1479+
"unlocked_alarm": False,
1480+
"auto_lock_paused": False,
1481+
"night_latch": False,
1482+
},
1483+
"model": "$",
1484+
"isEncrypted": False,
1485+
"modelFriendlyName": "Lock Pro",
1486+
"modelName": SwitchbotModel.LOCK_PRO,
1487+
"rawAdvData": None,
1488+
},
1489+
device=ble_device,
1490+
rssi=-67,
1491+
active=False,
1492+
)
1493+
1494+
14621495
def test_parsing_lock_active_old_firmware():
14631496
"""Test parsing lock with active data. Old firmware."""
14641497
ble_device = generate_ble_device("aa:bb:cc:dd:ee:ff", "any")

0 commit comments

Comments
 (0)