Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
watchforstock authored Dec 7, 2020
2 parents 6157dec + 9471c81 commit 9f5889b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
15 changes: 9 additions & 6 deletions evohomeclient2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def __init__(
refresh_token=None,
access_token=None,
access_token_expires=None,
timeout=30,
): # pylint: disable=too-many-arguments
"""Construct the EvohomeClient object."""
if debug is True:
Expand All @@ -81,6 +82,8 @@ def __init__(
self.access_token = access_token
self.access_token_expires = access_token_expires

self.timeout = timeout

self.account_info = None
self.locations = None
self.installation_info = None
Expand Down Expand Up @@ -167,7 +170,7 @@ def _obtain_access_token(self, credentials):
}
payload.update(credentials) # merge the credentials into the payload

response = requests.post(url, data=payload, headers=HEADER_BASIC_AUTH)
response = requests.post(url, data=payload, headers=HEADER_BASIC_AUTH, timeout=self.timeout)

try:
response.raise_for_status()
Expand Down Expand Up @@ -225,7 +228,7 @@ def user_account(self):

url = "https://tccna.honeywell.com/WebAPI/emea/api/v1/userAccount"

response = requests.get(url, headers=self._headers())
response = requests.get(url, headers=self._headers(), timeout=self.timeout)
response.raise_for_status()

self.account_info = response.json()
Expand All @@ -241,7 +244,7 @@ def installation(self):
% self.account_info["userId"]
)

response = requests.get(url, headers=self._headers())
response = requests.get(url, headers=self._headers(), timeout=self.timeout)
response.raise_for_status()

self.installation_info = response.json()
Expand All @@ -251,7 +254,7 @@ def installation(self):
][0]["systemId"]

for loc_data in self.installation_info:
self.locations.append(Location(self, loc_data))
self.locations.append(Location(self, loc_data, self.timeout))

return self.installation_info

Expand All @@ -263,7 +266,7 @@ def full_installation(self, location=None):
% self._get_location(location)
)

response = requests.get(url, headers=self._headers())
response = requests.get(url, headers=self._headers(), timeout=self.timeout)
response.raise_for_status()

return response.json()
Expand All @@ -272,7 +275,7 @@ def gateway(self):
"""Return the details of the gateway."""
url = "https://tccna.honeywell.com/WebAPI/emea/api/v1/gateway"

response = requests.get(url, headers=self._headers())
response = requests.get(url, headers=self._headers(), timeout=self.timeout)
response.raise_for_status()

return response.json()
Expand Down
1 change: 1 addition & 0 deletions evohomeclient2/controlsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def _set_status(self, mode, until=None):
"/temperatureControlSystem/%s/mode" % self.systemId,
data=json.dumps(data),
headers=headers,
timeout=self.location.timeout,
)
response.raise_for_status()

Expand Down
8 changes: 4 additions & 4 deletions evohomeclient2/hotwater.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
class HotWater(ZoneBase):
"""Provides handling of the hot water zone."""

def __init__(self, client, data):
super(HotWater, self).__init__(client)
def __init__(self, client, data, timeout=30):
super(HotWater, self).__init__(client, timeout)

self.dhwId = None # pylint: disable=invalid-name

Expand All @@ -28,7 +28,7 @@ def _set_dhw(self, data):
"/domesticHotWater/%s/state" % self.dhwId
)

response = requests.put(url, data=json.dumps(data), headers=headers)
response = requests.put(url, data=json.dumps(data), headers=headers, timeout=self.timeout)
response.raise_for_status()

def set_dhw_on(self, until=None):
Expand Down Expand Up @@ -73,6 +73,6 @@ def get_dhw_state(self):
"domesticHotWater/%s/status?" % self.dhwId
)

response = requests.get( url, headers=self.client._headers())
response = requests.get( url, headers=self.client._headers(), timeout=self.timeout)
data = response.json()
return data
4 changes: 3 additions & 1 deletion evohomeclient2/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ class Location(
): # pylint: disable=too-few-public-methods,useless-object-inheritance
"""Provide handling of a location."""

def __init__(self, client, data=None):
def __init__(self, client, data=None, timeout=30):
"""Initialise the class."""
self.client = client
self.timeout = timeout
self._gateways = []
self.gateways = {}
self.locationId = None # pylint: disable=invalid-name
Expand All @@ -34,6 +35,7 @@ def status(self):
"location/%s/status?includeTemperatureControlSystems=True"
% self.locationId,
headers=self.client._headers(),
timeout=self.timeout,
)
response.raise_for_status()
data = response.json()
Expand Down
7 changes: 5 additions & 2 deletions evohomeclient2/zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
class ZoneBase(object): # pylint: disable=useless-object-inheritance
"""Provide the base for Zones."""

def __init__(self, client):
def __init__(self, client, timeout=30):
"""Initialise the class."""
self.client = client
self.timeout = timeout
self.name = None
self.zoneId = None # pylint: disable=invalid-name
self.zone_type = None
Expand All @@ -21,6 +22,7 @@ def schedule(self):
"https://tccna.honeywell.com/WebAPI/emea/api/v1/%s/%s/schedule"
% (self.zone_type, self.zoneId),
headers=self.client._headers(),
timeout=self.timeout,
)
response.raise_for_status()

Expand Down Expand Up @@ -61,6 +63,7 @@ def set_schedule(self, zone_info):
% (self.zone_type, self.zoneId),
data=zone_info,
headers=headers,
timeout=self.timeout,
)
response.raise_for_status()

Expand Down Expand Up @@ -105,7 +108,7 @@ def _set_heat_setpoint(self, data):
headers = dict(self.client._headers())
headers["Content-Type"] = "application/json"

response = requests.put(url, json.dumps(data), headers=headers)
response = requests.put(url, json.dumps(data), headers=headers, timeout=self.timeout)
response.raise_for_status()

def cancel_temp_override(self):
Expand Down

0 comments on commit 9f5889b

Please sign in to comment.