From 63f133429621047bf6a087af87fd2691dcdc2de9 Mon Sep 17 00:00:00 2001 From: sfromis <47082390+sfromis@users.noreply.github.com> Date: Wed, 12 May 2021 18:44:13 +0200 Subject: [PATCH] Expand decode-status to support all feature bits Output of decode-status.py lacks information about the latest two new sets of feature bits, due to the constant for array size not being updated when the array was expanded. Code changed to avoid this magical number, but instead check size of array with texts, and array with features from the JSON format in Status 4, using the lowest number to provide as many bits as both Tasmota version and Python code supports. A warning is printed if the number of feature bits from Tasmota is higher than supported in the current iteration of Python code. Based on history, I'm assuming that updates are first done in arendst/Tasmota development, later replicated to tasmota/Tasmota-decode-status. If wrong, I can move the change there. --- tools/decode-status.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/decode-status.py b/tools/decode-status.py index 5690fca53..87c08aa9c 100755 --- a/tools/decode-status.py +++ b/tools/decode-status.py @@ -337,7 +337,11 @@ def StartDecode(): if "StatusMEM" in obj: if "Features" in obj["StatusMEM"]: features = [] - for f in range(7): + maxfeatures = len(obj["StatusMEM"]["Features"]) + if maxfeatures > len(a_features): + print("decode-status.py too old, does not support all feature bits") + maxfeatures = min(maxfeatures, len(a_features)) + for f in range(maxfeatures + 1): feature = obj["StatusMEM"]["Features"][f] i_feature = int(feature,16) if f == 0: