Repository navigation
Handle Hikvision AX HOME quirks: truncated ciphertext → NAK, accept O block, opt-in minute-precision timestamps - #94
Open
4gnus wants to merge 1 commit into
Conversation
- decrypt_content: a ciphertext that is not hex or not a multiple of the AES block size raises EventFormatError instead of ValueError, so the server answers NAK (and the panel resends) instead of dropping the connection. - SIA content regex: accept the DC-03 old event block "O" next to "N"; O is only taken as the block when two letters follow, so codes such as OP still parse when a sender omits the block letter. - SIAAccount.timestamp_minute_precision (default False): check the timestamp window with minute precision for panels that send HH:MM:MM. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes #93.
A Hikvision AX HOME hub (encrypted SIA DC-09) loses about 1 event in 5 with 3.2.2. The details and a reproduction are in the issue. This PR:
decrypt_content()raisesEventFormatErrorwhen the ciphertext is not hex or not a multiple of the AES block size.parse_and_check_event()already answersEventFormatErrorwith NAK, so the panel resends. Before,AES.decrypt()raisedValueError, which escapedhandle_line()and closed the connection without a reply.O. The panel resends with|Ori…instead of|Nri…. The regex tookOras the code and the receiver answered DUH.Onow counts as the block only when two letters follow, soOPand otherO…codes still parse when a sender leaves the block letter out (regression test added).SIAAccount.timestamp_minute_precision(defaultFalse) for panels whose seconds field is unreliable (this one sends HH:MM:MM). When set, an event passes if any second of its minute falls inside the allowed band, so replay protection stays on. That is safer thanallowed_timeband=None.Tests: new cases for all three (truncated at 8/10/38/43 bytes, non-hex,
Oblock encrypted and unencrypted, timestamp window with a frozen clock), and a guard forO…codes without a block. 211 passed and 13 skipped on Python 3.13 (190/13 onmaster), run withpytest<9, as #92 notes. Merges cleanly with #87, #89, #90 and #92.Validated on a live Home Assistant 2026.5.4 install with an equivalent local patch (same NAK and
Ohandling; the timestamp check there is always on rather than a flag): arm, disarm, bypass and periodic tests arrive. Cut frames get NAK, and the panel's resend is ACKed within about 1 s.🤖 Generated with Claude Code