mirror of https://github.com/arendst/Tasmota.git
decode-status.py update to 6.4.1.14
This commit is contained in:
parent
6ee3d1abc6
commit
b39adddf0c
|
@ -84,6 +84,13 @@ a_setoption = [[
|
||||||
"Enforce HASS light group",
|
"Enforce HASS light group",
|
||||||
"Do not show Wifi and Mqtt state using Led"
|
"Do not show Wifi and Mqtt state using Led"
|
||||||
],[
|
],[
|
||||||
|
"Key hold time (ms)",
|
||||||
|
"Sonoff POW Max_Power_Retry",
|
||||||
|
"Tuya dimmer device id",
|
||||||
|
"","","",
|
||||||
|
"","","","","","",
|
||||||
|
"","","","","","",
|
||||||
|
],[
|
||||||
"Timers enabled",
|
"Timers enabled",
|
||||||
"Generic ESP8285 GPIO enabled",
|
"Generic ESP8285 GPIO enabled",
|
||||||
"Add UTC time offset to JSON message",
|
"Add UTC time offset to JSON message",
|
||||||
|
@ -168,66 +175,73 @@ if (options.device):
|
||||||
obj = json.loads(body)
|
obj = json.loads(body)
|
||||||
else:
|
else:
|
||||||
jsonfile = options.jsonfile
|
jsonfile = options.jsonfile
|
||||||
fp = open(jsonfile, "r")
|
with open(jsonfile, "r") as fp:
|
||||||
obj = json.load(fp)
|
obj = json.load(fp)
|
||||||
fp.close()
|
|
||||||
|
|
||||||
def StartDecode():
|
def StartDecode():
|
||||||
print ("\n*** decode-status.py v20180730 by Theo Arends ***")
|
print ("\n*** decode-status.py v20180730 by Theo Arends ***")
|
||||||
|
|
||||||
# print("Decoding\n{}".format(obj))
|
# print("Decoding\n{}".format(obj))
|
||||||
|
|
||||||
if ("StatusSNS" in obj):
|
if "StatusSNS" in obj:
|
||||||
if ("Time" in obj["StatusSNS"]):
|
if "Time" in obj["StatusSNS"]:
|
||||||
time = str(" from status report taken at {}".format(obj["StatusSNS"]["Time"]))
|
time = str(" from status report taken at {}".format(obj["StatusSNS"]["Time"]))
|
||||||
|
|
||||||
if ("Status" in obj):
|
if "Status" in obj:
|
||||||
if ("FriendlyName" in obj["Status"]):
|
if "FriendlyName" in obj["Status"]:
|
||||||
print("Decoding 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 "StatusLOG" in obj:
|
||||||
if ("SetOption" in obj["StatusLOG"]):
|
if "SetOption" in obj["StatusLOG"]:
|
||||||
options = []
|
options = []
|
||||||
o = 0
|
|
||||||
p = 0
|
i = 0
|
||||||
|
for r,opt_group in enumerate(a_setoption):
|
||||||
r = 1
|
register = obj["StatusLOG"]["SetOption"][r]
|
||||||
if (len(obj["StatusLOG"]["SetOption"]) == 3):
|
|
||||||
r = 2
|
if r > 0 and len(obj["StatusLOG"]["SetOption"]) == 2: # old firmware: array consisted only of SetOptions 0..31 and resolution
|
||||||
|
break
|
||||||
for f in range(r):
|
|
||||||
if (f == 1):
|
if r == 1:
|
||||||
o = 2
|
if len(register) == 8: # pre 6.1.1.14: array consisted of SetOptions 0..31, resolution, and SetOptions 50..81
|
||||||
p = 50
|
i += 18 # adjust option index and skip 2nd register
|
||||||
|
continue
|
||||||
option = obj["StatusLOG"]["SetOption"][o]
|
|
||||||
i_option = int(option,16)
|
elif len(register) == 36: # 6.1.1.14: array consists of SetOptions 0..31, SetOptions 32..49, and SetOptions 50..81
|
||||||
for i in range(len(a_setoption[f])):
|
split_register = [int(register[opt*2:opt*2+2],16) for opt in range(18)] # split register into 18 values
|
||||||
if (a_setoption[f][i]):
|
|
||||||
state = (i_option >> i) & 1
|
for opt_idx, option in enumerate(opt_group):
|
||||||
options.append(str("{0:2d} ({1}) {2}".format(i + p, a_on_off[state], a_setoption[f][i])))
|
options.append(str("{0:2d} ({1:3d}) {2}".format(i, split_register[opt_idx], option)))
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
if r in (0, 2): #registers 1 and 3 hold binary values
|
||||||
|
for opt_idx, option in enumerate(opt_group):
|
||||||
|
i_register = int(register,16)
|
||||||
|
state = (i_register >> opt_idx) & 1
|
||||||
|
options.append(str("{0:2d} ({1}) {2}".format(i, a_on_off[state], option)))
|
||||||
|
i += 1
|
||||||
|
|
||||||
print("\nOptions")
|
print("\nOptions")
|
||||||
for i in range(len(options)):
|
for o in options:
|
||||||
print(" {}".format(options[i]))
|
print(" {}".format(o))
|
||||||
|
|
||||||
if ("StatusMEM" in obj):
|
if "StatusMEM" in obj:
|
||||||
if ("Features" in obj["StatusMEM"]):
|
if "Features" in obj["StatusMEM"]:
|
||||||
features = []
|
features = []
|
||||||
for f in range(5):
|
for f in range(5):
|
||||||
feature = obj["StatusMEM"]["Features"][f]
|
feature = obj["StatusMEM"]["Features"][f]
|
||||||
i_feature = int(feature,16)
|
i_feature = int(feature,16)
|
||||||
if (f == 0):
|
if f == 0:
|
||||||
features.append(str("Language LCID = {}".format(i_feature & 0xFFFF)))
|
features.append(str("Language LCID = {}".format(i_feature & 0xFFFF)))
|
||||||
else:
|
else:
|
||||||
for i in range(len(a_features[f -1])):
|
for i in range(len(a_features[f -1])):
|
||||||
if ((i_feature >> i) & 1):
|
if (i_feature >> i) & 1:
|
||||||
features.append(a_features[f -1][i])
|
features.append(a_features[f -1][i])
|
||||||
|
|
||||||
features.sort()
|
features.sort()
|
||||||
print("\nFeatures")
|
print("\nFeatures")
|
||||||
for i in range(len(features)):
|
for f in features:
|
||||||
print(" {}".format(features[i]))
|
print(" {}".format(f))
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue