Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

Commit

Permalink
Increased timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
And3rsL committed Jan 27, 2021
1 parent 6f83709 commit 6556190
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
13 changes: 7 additions & 6 deletions deebotozmo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def __call_main_api(self, function, *args):
else:
url = (EcoVacsAPI.MAIN_URL_FORMAT + "/" + function).format(**self.meta)

api_response = requests.get(url, self.__sign(params), verify=self.verify_ssl)
api_response = requests.get(url, self.__sign(params), timeout=60, verify=self.verify_ssl)

json = api_response.json()
_LOGGER.debug("got {}".format(json))
Expand All @@ -141,7 +141,7 @@ def __call_auth_api(self, device_id, *args):
else:
url = (EcoVacsAPI.PORTAL_GLOBAL_AUTHCODE).format(**self.meta)

api_response = requests.get(url, self.__signAuth(params), verify=self.verify_ssl)
api_response = requests.get(url, self.__signAuth(params), timeout=60, verify=self.verify_ssl)

json = api_response.json()
_LOGGER.debug("got {}".format(json))
Expand All @@ -160,7 +160,7 @@ def __call_user_api(self, function, args):
_LOGGER.debug("calling user api {} with {}".format(function, args))
params = {'todo': function}
params.update(args)
response = requests.post(EcoVacsAPI.USER_URL_FORMAT.format(continent=self.continent), json=params, verify=self.verify_ssl)
response = requests.post(EcoVacsAPI.USER_URL_FORMAT.format(continent=self.continent), json=params, timeout=60, verify=self.verify_ssl)
json = response.json()
_LOGGER.debug("got {}".format(json))
if json['result'] == 'ok':
Expand Down Expand Up @@ -189,7 +189,7 @@ def __call_portal_api(self, api, function, args, verify_ssl=True, **kwargs):
else:
url = (EcoVacsAPI.PORTAL_URL_FORMAT + "/" + api).format(continent=continent, **self.meta)

response = requests.post(url, json=params, verify=verify_ssl)
response = requests.post(url, json=params, timeout=60, verify=verify_ssl)

json = response.json()
_LOGGER.debug("got {}".format(json))
Expand Down Expand Up @@ -451,6 +451,8 @@ def _handle_clean_report(self, event):
elif response['trigger'] == 'alert':
self.vacuum_status = 'STATE_ERROR'

self.is_available = True

self.statusEvents.notify(self.vacuum_status)

def _handle_map_trace(self, event):
Expand Down Expand Up @@ -546,6 +548,7 @@ def _handle_battery_info(self, event):
def _handle_charge_state(self, event):
response = event['body']
status = 'none'

if response['code'] == 0:
if response['data']['isCharging'] == 1:
status = 'STATE_DOCKED'
Expand All @@ -562,8 +565,6 @@ def _handle_charge_state(self, event):
if status != 'none':
self.vacuum_status = status
self.is_available = True
else:
self.is_available = False

self.statusEvents.notify(self.vacuum_status)

Expand Down
6 changes: 3 additions & 3 deletions deebotozmo/ecovacsjson.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self, user, resource, secret, continent, vacuum, realm, portal_url_
self.verify_ssl = str_to_bool_or_cert(verify_ssl)
self.realm = realm
self.portal_url_format = portal_url_format

def subscribe_to_ctls(self, function):
self.ctl_subscribers.append(function)

Expand Down Expand Up @@ -122,7 +122,7 @@ def CallIOTApi(self, args, verify_ssl=True):
url = (self.portal_url_format + "/iot/devmanager.do?mid=" + params['toType'] + "&did=" + params['toId'] + "&td=" + params['td'] + "&u=" + params['auth']['userid'] + "&cv=1.67.3&t=a&av=1.3.1").format(continent=self.continent)

try:
with requests.post(url, headers=headers, json=params, timeout=20, verify=verify_ssl) as response:
with requests.post(url, headers=headers, json=params, timeout=60, verify=verify_ssl) as response:
if response.status_code == 502:
_LOGGER.info("Error calling API (502): Unfortunately the ecovacs api is unreliable. Retrying in a few moments")
_LOGGER.debug(f"URL was: {str(url)}")
Expand Down Expand Up @@ -150,7 +150,7 @@ def CallCleanLogsApi(self, args, verify_ssl=True):
url = (self.portal_url_format + "/lg/log.do?td=" + params['td'] + "&u=" + params['auth']['userid'] + "&cv=1.67.3&t=a&av=1.3.1").format(continent=self.continent)

try:
with requests.post(url, headers=headers, json=params, timeout=20, verify=verify_ssl) as response:
with requests.post(url, headers=headers, json=params, timeout=60, verify=verify_ssl) as response:
data = response.json()
if response.status_code != 200:
_LOGGER.warning("Error calling API " + str(url))
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name='deebotozmo',
version='1.7.7',
version='1.7.8',

description='a library for controlling certain robot vacuums [SUCKS FORK]',
long_description=long_description,
Expand Down

0 comments on commit 6556190

Please sign in to comment.