some time ago I've created a script to retrieve the sunset time from domoticz using JSON, apply some offset and then store the updated time again in domoticz using JSON. I'm using the NGINX webserver and redirect all traffic to HTTPS (as described in https://www.domoticz.com/wiki/Secure_Nginx_Proxy_Setup).
My script used to work just fine until recently I noticed it wasn't updating the variable anymore. The NGINX configuration and script have not been changed. Domoticz and the rPI software however have been update to the latest version (unfortunately I can't check whether the script was already failing before the update).
Retrieving the SunRIse still works fine using the functions below:
Code: Select all
def DomoticzGetSunrise ():
JSON_getSunRise = '/json.htm?type=command¶m=getSunRiseSet'
domoticzurl = domoticzserver+JSON_getSunRise
json_object = json.loads(domoticzrequest(domoticzurl))
if json_object["status"] == "OK":
result = json_object["Sunset"]
return result
return 0
Code: Select all
def domoticzrequest (url):
request = urllib2.Request(url)
request.add_header("Authorization", "Basic %s" % base64string)
response = urllib2.urlopen(request)
print 'response headers: "%s"' % response.info()
return response.read()
Code: Select all
def DomoticzSetVariable (USERVARIABLENAME, USERVARIABLETYPE, USERVARIABLEVALUE):
JSON_setVariable = '/json.htm?type=command¶m=updateuservariable&vname='+USERVARIABLENAME+'&vtype='+USERVARIABLETYPE+'&vvalue='+USERVARIABLEVALUE
domoticzurl = domoticzserver+JSON_setVariable
json_object = json.loads(domoticzrequest(domoticzurl))
if json_object["status"] == "OK":
return 1
return 0
ValueError: No JSON object could be decoded
I did some analysis and the part I find interesting is that the JSON request created as a result of the above functions works perfectly fine when manually entered in the webbrowsers address bar.
Anyone some idea what might be going on? I think it has something to do with using HTTPS (iso HTTP) and the recent update.
Any help is appreciated
