From dbee6b46d4683f71586f7d5caaa1618c5cdd59d8 Mon Sep 17 00:00:00 2001 From: Doug Gallarda Date: Thu, 13 Oct 2022 20:24:30 -0500 Subject: [PATCH] Fixes for [SSL: DH_KEY_TOO_SMALL] and [can only concatenate str (not int) to str] crashes --- greenwavereality/greenwavereality.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/greenwavereality/greenwavereality.py b/greenwavereality/greenwavereality.py index 51e45d2..eac4310 100644 --- a/greenwavereality/greenwavereality.py +++ b/greenwavereality/greenwavereality.py @@ -2,6 +2,7 @@ import xmltodict import urllib3 +requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS += 'HIGH:!DH:!aNULL' def grab_xml(host, token=None): """Grab XML data from Gateway, returned as a dict.""" @@ -28,7 +29,7 @@ def set_brightness(host, did, value, token=None): scheme = "http" token = "1234567890" url = ( - scheme + '://' + host + '/gwr/gop.php?cmd=DeviceSendCommand&data=1' + token + '' + did + '' + str( + scheme + '://' + host + '/gwr/gop.php?cmd=DeviceSendCommand&data=1' + token + '' + str(did) + '' + str( value) + 'level&fmt=xml') response = requests.get(url, verify=False) if response.status_code == '200': @@ -55,7 +56,7 @@ def turn_on(host, did, token=None): scheme = "http" token = "1234567890" url = ( - scheme + '://' + host + '/gwr/gop.php?cmd=DeviceSendCommand&data=1' + token + '' + did + '1&fmt=xml') + scheme + '://' + host + '/gwr/gop.php?cmd=DeviceSendCommand&data=1' + token + '' + str(did) + '1&fmt=xml') response = requests.get(url, verify=False) if response.status_code == '200': return True @@ -72,7 +73,7 @@ def turn_off(host, did, token=None): scheme = "http" token = "1234567890" url = ( - scheme + '://' + host + '/gwr/gop.php?cmd=DeviceSendCommand&data=1' + token + '' + did + '0&fmt=xml') + scheme + '://' + host + '/gwr/gop.php?cmd=DeviceSendCommand&data=1' + token + '' + str(did) + '0&fmt=xml') response = requests.get(url, verify=False) if response.status_code == '200': return True @@ -103,4 +104,4 @@ def grab_bulbs(host, token=None): for room in xml: for device in room['device']: bulbs[int(device['did'])] = device - return bulbs \ No newline at end of file + return bulbs