From 0abe64bf6370a6805e574cbb76933c381e34e87b Mon Sep 17 00:00:00 2001 From: Martin Schwan Date: Fri, 31 Jul 2026 12:08:18 +0200 Subject: [PATCH] Handle nonexistent fw_size attribute fw_size may not be present, when issuing an OTA update with a direct URL instead of a filename/blob. Use a sane default of zero bytes for the firmware size, as we are just transferring a URL. This fixes a KeyError exception. Signed-off-by: Martin Schwan --- tb_device_mqtt.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tb_device_mqtt.py b/tb_device_mqtt.py index 50c4f50..6bc9e30 100644 --- a/tb_device_mqtt.py +++ b/tb_device_mqtt.py @@ -781,9 +781,9 @@ def _on_decoded_message(self, content, message): sleep(1) self.__firmware_request_id = self.__firmware_request_id + 1 - self.__target_firmware_length = self.firmware_info[FW_SIZE_ATTR] + self.__target_firmware_length = self.firmware_info.get(FW_SIZE_ATTR, 0) self.__chunk_count = 0 if not self.__chunk_size else ceil( - self.firmware_info[FW_SIZE_ATTR] / self.__chunk_size) + self.firmware_info.get(FW_SIZE_ATTR, 0) / self.__chunk_size) self.__get_firmware() def __process_firmware(self):