v0.7.8 — the lock locks itself when the door shuts
Adds Lockly's native Auto-Lock (Automation) mode, contributed by @Dei381rcr. The deadbolt stays retracted while the door is open and throws the moment the lock's own magnetic sensor sees the door close.
The important part is where this runs. The lock does it, not Home Assistant. HA writes the setting once and then stays out of the way — no door-sensor polling, no timer, and it keeps working while HA is down or the network is out.
Using it
Two new services, both taking lock_id:
lockly.enable_native_auto_locklockly.disable_native_auto_lock
Each fires a bus event (lockly_native_auto_lock_enabled / ..._disabled) carrying lock_id and success.
Three things to know before you try it
It is MQTT-only. A hub-relayed lock will decline and log that it could not get a nonce. If your lock works through a hub, this release changes nothing for you.
It is gated to verified hardware — currently PGK728WRHK (type 105), tested on firmware 3.00.24 and 1.14.31. Other models are refused rather than guessed at. This is the same posture the firmware-gated 0x52 models already get: a command built on an unverified frame layout is worse than no command.
Enabling it while the door is already shut and unlocked does not lock the door. Automation acts on the next door-close transition, not on the current state. This looked like a failure during testing and is not one.
Protocol
Both commands were verified against the decompiled app rather than inferred from behaviour:
0x12carries auto-lock time as an unsigned little-endian 16-bit field —0100selects Auto-Detection,0000disables. A one-byte time field happens to produce the right value for Automation and shifts every field after it, which is the kind of bug that passes a hardware test and fails everything else.- The check-door-sensor byte that follows exists only on models whose capability predicate includes it, and is omitted entirely otherwise.
0x19uses0x80as its query sentinel; bit 3 is the Auto-Lock master switch, and a write serializes only the low nibble, forcing bits 4-7 to zero.
Documented in docs/api.md, with regression vectors in tests/test_frame.py.
Unchanged
No changes to lock, unlock, status parsing, the access log or the MQTT transport. Everything from 0.7.7 behaves identically.