diff --git a/tools/decode-status.py b/tools/decode-status.py index bdffa4ba3..e6e4138bd 100755 --- a/tools/decode-status.py +++ b/tools/decode-status.py @@ -20,7 +20,7 @@ Requirements: - Python - - pip json pycurl + - pip json requests Instructions: Execute command with option -d to retrieve status report from device or @@ -42,11 +42,10 @@ Example: import io import os.path import json -import pycurl -import urllib2 +import requests +import urllib from sys import exit from optparse import OptionParser -from StringIO import StringIO a_on_off = ["OFF","ON "] @@ -146,11 +145,14 @@ a_setoption = [[ "Distinct MQTT topics per device for Zigbee", "Disable non-json MQTT response", "Enable light fading at start/power on", - "Set PWM Mode from regular PWM to ColorTemp control","", + "Set PWM Mode from regular PWM to ColorTemp control", "Keep uncompressed rules in memory to avoid CPU load of uncompressing at each tick", "Implement simpler MAX6675 protocol instead of MAX31855", - "","", - "","","","", + "Enable Wifi", + "Enable Ethernet (ESP32)", + "Set Baud rate for TuyaMCU serial communication (0 = 9600 or 1 = 115200)", + "Rotary encoder uses rules instead of light control", + "","","", "","","","", "","","","", "","","","" @@ -225,25 +227,19 @@ parser.add_option("-f", "--file", metavar="FILE", (options, args) = parser.parse_args() if (options.device): - buffer = StringIO() loginstr = "" if options.password is not None: - loginstr = "user={}&password={}&".format(urllib2.quote(options.username), urllib2.quote(options.password)) + loginstr = "user={}&password={}&".format(urllib.parse.quote(options.username), urllib.parse.quote(options.password)) url = str("http://{}/cm?{}cmnd=status%200".format(options.device, loginstr)) - c = pycurl.Curl() - c.setopt(c.URL, url) - c.setopt(c.WRITEDATA, buffer) - c.perform() - c.close() - body = buffer.getvalue() - obj = json.loads(body) + res = requests.get(url) + obj = json.loads(res.content) else: jsonfile = options.jsonfile with open(jsonfile, "r") as fp: obj = json.load(fp) def StartDecode(): - print ("\n*** decode-status.py v20200627 by Theo Arends and Jacek Ziolkowski ***") + print ("\n*** decode-status.py v20200704 by Theo Arends and Jacek Ziolkowski ***") # print("Decoding\n{}".format(obj))