fix: keep the lock state when the operation-log read fails - #75
Merged
Conversation
The operation log feeds the event entity only, but a failure while reading it aborted the whole poll, discarding the state and battery the same poll had already read. The coordinator then published a null state, so the entity kept whatever Home Assistant last wrote optimistically. With the default one-hour scan interval that is the only channel that refreshes the entity from the device, so anything done outside Home Assistant — keypad, fingerprint, card, the vendor app — stayed invisible indefinitely. A confidently wrong `locked` is worse than an unavailable entity: a state condition reads the stale value and the automation silently does nothing. Two layers were involved. `async_get_operation_log` documents that it returns an empty list on failure, but only caught `TTLockError`, while the SDK's log path reaches `aes_decrypt` unwrapped and raises `ValueError` on a garbled frame. The coordinator, in turn, had no guard of its own, so it depended on that discipline holding. Also pins the SDK to 0.1.11, which fixes the framing bug that made this reproduce permanently on affected locks, and adds a test asserting the manifest and the tested pin name the same release. Fixes #74
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The operation log feeds the event entity only, but a failure while reading it aborted the whole poll and discarded the state and battery that same poll had already read. The coordinator then published a null state, so the entity kept whatever Home Assistant last wrote optimistically.
With the default one-hour scan interval that is the only channel refreshing the entity from the device, so anything done outside Home Assistant stayed invisible indefinitely. A confidently wrong
lockedis worse than an unavailable entity: a state condition reads the stale value and the automation silently does nothing.Two layers were involved:
async_get_operation_logdocuments that it returns an empty list on failure, but only caughtTTLockError. The SDK's log path reachesaes_decryptunwrapped and raisesValueErroron a garbled frame, which is the reported failure.Also pins
ttlock-bleto 0.1.11, which fixes the framing bug that made this reproduce permanently on affected locks, and adds a test asserting the manifest pin and the tested pin name the same release.Fixes #74