From cb192c5c2d87aa0ae804b3376068a40e44d6f1d7 Mon Sep 17 00:00:00 2001 From: Theo Arends Date: Wed, 25 Jul 2018 12:42:53 +0200 Subject: [PATCH] Update decode-status.py Update decode-status.py --- sonoff/sonoff.ino | 4 ++-- tools/decode-status.py | 47 ++++++++++++++++++++++++++++++++---------- 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index 593ee1d92..7b63160fb 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -1371,8 +1371,8 @@ void PublishStatus(uint8_t payload) } if ((0 == payload) || (3 == payload)) { - snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_STATUS D_STATUS3_LOGGING "\":{\"" D_CMND_SERIALLOG "\":%d,\"" D_CMND_WEBLOG "\":%d,\"" D_CMND_SYSLOG "\":%d,\"" D_CMND_LOGHOST "\":\"%s\",\"" D_CMND_LOGPORT "\":%d,\"" D_CMND_SSID "\":[\"%s\",\"%s\"],\"" D_CMND_TELEPERIOD "\":%d,\"" D_CMND_SETOPTION "\":[\"%08X\",\"%08X\"]}}"), - Settings.seriallog_level, Settings.weblog_level, Settings.syslog_level, Settings.syslog_host, Settings.syslog_port, Settings.sta_ssid[0], Settings.sta_ssid[1], Settings.tele_period, Settings.flag.data, Settings.flag2.data); + snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_STATUS D_STATUS3_LOGGING "\":{\"" D_CMND_SERIALLOG "\":%d,\"" D_CMND_WEBLOG "\":%d,\"" D_CMND_SYSLOG "\":%d,\"" D_CMND_LOGHOST "\":\"%s\",\"" D_CMND_LOGPORT "\":%d,\"" D_CMND_SSID "\":[\"%s\",\"%s\"],\"" D_CMND_TELEPERIOD "\":%d,\"" D_CMND_SETOPTION "\":[\"%08X\",\"%08X\",\"%08X\"]}}"), + Settings.seriallog_level, Settings.weblog_level, Settings.syslog_level, Settings.syslog_host, Settings.syslog_port, Settings.sta_ssid[0], Settings.sta_ssid[1], Settings.tele_period, Settings.flag.data, Settings.flag2.data, Settings.flag3.data); MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "3")); } diff --git a/tools/decode-status.py b/tools/decode-status.py index 3adc8e707..7fc7ba4e1 100644 --- a/tools/decode-status.py +++ b/tools/decode-status.py @@ -48,11 +48,11 @@ from StringIO import StringIO a_on_off = ["OFF","ON "] -a_setoption = [ +a_setoption = [[ "Save power state and use after restart", "Restrict button actions to single, double and hold", "Show value units in JSON messages", - "MQTT", + "MQTT enabled", "Respond as Command topic instead of RESULT", "MQTT retain on Power", "MQTT retain on Button", @@ -74,13 +74,24 @@ a_setoption = [ "MQTT serial", "Rules until 5.14.0b", "Rules once mode until 5.14.0b", - "KNX", + "KNX enabled", "Use Power device index on single relay devices", "KNX enhancement", "RF receive decimal", "IR receive decimal", "Enforce HASS light group", - "Do not show Wifi and Mqtt state using Led"] + "Do not show Wifi and Mqtt state using Led" + ],[ + "Timers enabled", + "","","", + "","","","", + "","","","", + "","","","", + "","","","", + "","","","", + "","","","", + "","","","" + ]] a_features = [[ "","","USE_I2C","USE_SPI", @@ -144,6 +155,8 @@ else: fp.close() def StartDecode(): + print ("\n*** decode-status.py v20180725 by Theo Arends ***") + # print("Decoding\n{}".format(obj)) if ("StatusSNS" in obj): @@ -152,17 +165,29 @@ def StartDecode(): if ("Status" in obj): if ("FriendlyName" in obj["Status"]): - print("\nDecoding information for device {}{}".format(obj["Status"]["FriendlyName"][0], time)) + print("Decoding information for device {}{}".format(obj["Status"]["FriendlyName"][0], time)) if ("StatusLOG" in obj): if ("SetOption" in obj["StatusLOG"]): options = [] - option = obj["StatusLOG"]["SetOption"][0] - i_option = int(option,16) - for i in range(len(a_setoption)): - if (a_setoption[i]): - state = (i_option >> i) & 1 - options.append(str("{0:2d} ({1}) {2}".format(i, a_on_off[state], a_setoption[i]))) + o = 0 + p = 0 + + r = 1 + if (len(obj["StatusLOG"]["SetOption"]) == 3): + r = 2 + + for f in range(r): + if (f == 1): + o = 2 + p = 50 + + option = obj["StatusLOG"]["SetOption"][o] + i_option = int(option,16) + for i in range(len(a_setoption[f])): + if (a_setoption[f][i]): + state = (i_option >> i) & 1 + options.append(str("{0:2d} ({1}) {2}".format(i + p, a_on_off[state], a_setoption[f][i]))) print("\nOptions") for i in range(len(options)):