From 728a891e6cb95bff50d05825b29bbfa00a93d96e Mon Sep 17 00:00:00 2001 From: Dan Davies <242855381+daviesjamesdaniel@users.noreply.github.com> Date: Sun, 23 Aug 2026 13:03:13 +0100 Subject: [PATCH] Fix KeyError in MQTT publish handler dropping whole status update _on_publish_received() indexes appliance.attributes["parameters"] directly by parName when applying an incoming appliancestatus push: appliance.attributes["parameters"][parameter["parName"]].update(parameter) If the payload contains a parName that hasn't been seen/initialized locally yet, this raises KeyError before self._hon.notify() is reached, so the entire push message (not just that one parameter) is silently dropped for that appliance. In practice this reproduced reliably on a Haier washing machine (HW90-B14959U1-UK) at end-of-cycle, where the push includes a "programStats" parameter: Exception ignored in: Traceback (most recent call last): File ".../awscrt/mqtt5.py", line 1540, in _on_publish self._on_publish_cb(publish_data) File ".../pyhon/connection/mqtt.py", line 109, in _on_publish_received appliance.attributes["parameters"][parameter["parName"]].update( KeyError: 'programStats' Because the exception is swallowed by the underlying MQTT client as "Exception ignored in", it fails silently with no log entry pointing at the cause - the visible symptom is just that dependent entities (e.g. door-open state bundled in the same push) never update. Fix: use setdefault() instead of a raw index so an unseen parName initializes its entry instead of raising. --- pyhon/connection/mqtt.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyhon/connection/mqtt.py b/pyhon/connection/mqtt.py index 7c60a53..5e8dc2f 100644 --- a/pyhon/connection/mqtt.py +++ b/pyhon/connection/mqtt.py @@ -86,9 +86,9 @@ class MQTTClient: ) if topic and "appliancestatus" in topic: for parameter in payload["parameters"]: - appliance.attributes["parameters"][parameter["parName"]].update( - parameter - ) + appliance.attributes["parameters"].setdefault( + parameter["parName"], {} + ).update(parameter) appliance.sync_params_to_command("settings") elif topic and "disconnected" in topic: _LOGGER.info(