diff --git a/greenwavereality/greenwavereality.py b/greenwavereality/greenwavereality.py
index 51e45d2..4297198 100644
--- a/greenwavereality/greenwavereality.py
+++ b/greenwavereality/greenwavereality.py
@@ -11,9 +11,8 @@ def grab_xml(host, token=None):
if not token:
scheme = "http"
token = "1234567890"
- url = (
- scheme + '://' + host + '/gwr/gop.php?cmd=GWRBatch&data=RoomGetCarousel1' + token + 'name,status&fmt=xml')
- response = requests.get(url, verify=False)
+ url = '{}://{}/gwr/gop.php?cmd=GWRBatch&data=RoomGetCarousel1{}name,status&fmt=xml'.format(scheme, host, token)
+ response = requests.get(url, timeout=10.0, verify=False)
parsed = xmltodict.parse(response.content, force_list={'room', 'device'})
parsed = parsed['gwrcmds']['gwrcmd']['gdata']['gip']['room']
return parsed
@@ -27,10 +26,8 @@ def set_brightness(host, did, value, token=None):
if not token:
scheme = "http"
token = "1234567890"
- url = (
- scheme + '://' + host + '/gwr/gop.php?cmd=DeviceSendCommand&data=1' + token + '' + did + '' + str(
- value) + 'level&fmt=xml')
- response = requests.get(url, verify=False)
+ url = '{}://{}/gwr/gop.php?cmd=DeviceSendCommand&data=1{}{}{}level&fmt=xml'.format(scheme, host, token, did, value)
+ response = requests.get(url, timeout=10.0, verify=False)
if response.status_code == '200':
return True
else:
@@ -54,9 +51,8 @@ def turn_on(host, did, token=None):
if not token:
scheme = "http"
token = "1234567890"
- url = (
- scheme + '://' + host + '/gwr/gop.php?cmd=DeviceSendCommand&data=1' + token + '' + did + '1&fmt=xml')
- response = requests.get(url, verify=False)
+ url = '{}://{}/gwr/gop.php?cmd=DeviceSendCommand&data=1{}{}1&fmt=xml'.format(scheme, host, token, did)
+ response = requests.get(url, timeout=10.0, verify=False)
if response.status_code == '200':
return True
else:
@@ -71,9 +67,8 @@ def turn_off(host, did, token=None):
if not token:
scheme = "http"
token = "1234567890"
- url = (
- scheme + '://' + host + '/gwr/gop.php?cmd=DeviceSendCommand&data=1' + token + '' + did + '0&fmt=xml')
- response = requests.get(url, verify=False)
+ url = '{}://{}/gwr/gop.php?cmd=DeviceSendCommand&data=1{}{}0&fmt=xml'.format(scheme, host, token, did)
+ response = requests.get(url, timeout=10.0, verify=False)
if response.status_code == '200':
return True
else:
@@ -88,8 +83,8 @@ def check_online(device):
def grab_token(host, email, password):
"""Grab token from gateway. Press sync button before running."""
urllib3.disable_warnings()
- url = ('https://' + host + '/gwr/gop.php?cmd=GWRLogin&data=1' + str(email) + '' + str(password) + '&fmt=xml')
- response = requests.get(url, verify=False)
+ url = 'https://{}/gwr/gop.php?cmd=GWRLogin&data=1{}{}&fmt=xml'.format(host, email, password)
+ response = requests.get(url, timeout=10.0, verify=False)
if '404' in response.text:
raise PermissionError('Not In Pairing Mode')
parsed = xmltodict.parse(response.content)