Skip to content

Commit

Permalink
disable detection of night latch for lock pro (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal4K authored Aug 22, 2024
1 parent 29216b5 commit ed36fe4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
3 changes: 2 additions & 1 deletion switchbot/adv_parsers/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
33 changes: 33 additions & 0 deletions tests/test_adv_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit ed36fe4

Please sign in to comment.