From 52974cf176522c52fe4c4d3df069773d99a94fef Mon Sep 17 00:00:00 2001 From: Taiyu Xu Date: Sun, 22 Mar 2026 15:23:38 +0900 Subject: [PATCH] fix(xiaomi): guard malformed 0x4851/0x4852 duration payloads --- .../ble_monitor/ble_parser/xiaomi.py | 6 ++++++ .../ble_monitor/test/test_xiaomi_parser.py | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/custom_components/ble_monitor/ble_parser/xiaomi.py b/custom_components/ble_monitor/ble_parser/xiaomi.py index 1eeb49d2..1fb39cb0 100755 --- a/custom_components/ble_monitor/ble_parser/xiaomi.py +++ b/custom_components/ble_monitor/ble_parser/xiaomi.py @@ -858,12 +858,18 @@ def obj4850(xobj): def obj4851(xobj): """From miot-spec: has-someone-duration: uint8: 2 - 2 minutes, 5 - 5 minutes (not used)""" + if len(xobj) != 4: + return {} + (duration,) = struct.unpack("