From 638e60532cb4a9eea5a908868740d5e72880da5c Mon Sep 17 00:00:00 2001 From: Brian Harrison Date: Thu, 2 Apr 2026 03:36:25 -0400 Subject: [PATCH] protocol: tighten compliance config dedup to exact byte content MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Old key was (page_key, chunk_len) which would incorrectly drop a second config section that has the same length as the first (e.g. current-config vs event-time-config when settings haven't changed). New key is the full chunk bytes — only truly byte-identical chunks are dropped. Different data that happens to share page_key and length now comes through correctly. Co-Authored-By: Claude Sonnet 4.6 --- minimateplus/protocol.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/minimateplus/protocol.py b/minimateplus/protocol.py index ad5fdff..5857191 100644 --- a/minimateplus/protocol.py +++ b/minimateplus/protocol.py @@ -500,12 +500,8 @@ class MiniMateProtocol: ("D", 0x002A, _DATA_PARAMS), # _DATA_PARAMS built above ] - config = bytearray() - # Track (page_key, chunk_size) pairs to detect when frame D returns the - # same page/size as frame B — observed on BE11529 when the device is - # busy or connection state is fresh. Duplicate chunks inflate the cfg - # and mis-align field offsets, so we drop them. - seen_chunks: set[tuple[int, int]] = set() + config = bytearray() + seen_bytes: set[bytes] = set() # exact-content dedup (not page_key+len) for step_name, step_offset, step_params in _STEPS: log.debug( @@ -526,17 +522,16 @@ class MiniMateProtocol: chunk = data_rsp.data[11:] page = data_rsp.page_key - key = (page, len(chunk)) - if key in seen_chunks: + if chunk in seen_bytes: log.warning( "read_compliance_config: frame %s page=0x%04X data=%d " - "cfg_chunk=%d DUPLICATE — skipping", + "cfg_chunk=%d BYTE-IDENTICAL DUPLICATE — skipping", step_name, page, len(data_rsp.data), len(chunk), ) continue - seen_chunks.add(key) + seen_bytes.add(bytes(chunk)) log.warning( "read_compliance_config: frame %s page=0x%04X data=%d " "cfg_chunk=%d running_total=%d",