Skip to content

Commit

Permalink
neato: reduced timeout exceptions from error to warning level; fixed …
Browse files Browse the repository at this point in the history
…exception for situations in which mapID attribute is not available
  • Loading branch information
aschwith committed Nov 21, 2023
1 parent cbd5cb9 commit 3ac1457
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion neato/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@


class Neato(SmartPlugin):
PLUGIN_VERSION = '1.6.8'
PLUGIN_VERSION = '1.6.9'
robot = 'None'

def __init__(self, sh):
Expand Down
2 changes: 1 addition & 1 deletion neato/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugin:
documentation: https://github.com/smarthomeng/plugins/blob/develop/neato/README.md
support: https://knx-user-forum.de/forum/supportforen/smarthome-py/1417295-support-thread-plugin-neato

version: 1.6.8 # Plugin version
version: 1.6.9 # Plugin version
sh_minversion: 1.8.0 # minimum shNG version to use this plugin
# sh_maxversion: # maximum shNG version to use this plugin (leave empty if latest)
multi_instance: False # plugin supports multi instance
Expand Down
14 changes: 10 additions & 4 deletions neato/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def robot_command(self, command, arg1 = None, arg2 = None):
responseJson = start_cleaning_response.json()
self.logger.debug("Debug: send command response: {0}".format(start_cleaning_response.text))
if log_message:
self.logger.info("Requested Info: {0}".format(start_cleaning_response.text))
self.logger.warning("INFO: Requested Info: {0}".format(start_cleaning_response.text))

if 'result' in responseJson:
if str(responseJson['result']) == 'ok':
Expand Down Expand Up @@ -202,7 +202,12 @@ def update_robot(self):
'Date': self.__get_current_date(),
'Accept': 'application/vnd.neato.nucleo.v1',
'Authorization': 'NEATOAPP ' + h.hexdigest()}, timeout=self._timeout, verify=self._verifySSL )

except requests.exceptions.ConnectionError as e:
self.logger.warning("Robot: This test works!: %s" % str(e))
return 'error'
except requests.exceptions.Timeout as e:
self.logger.warning("Robot: Timeout exception during cloud state request: %s" % str(e))
return 'error'
except Exception as e:
self.logger.error("Robot: Exception during cloud state request: %s" % str(e))
return 'error'
Expand Down Expand Up @@ -287,7 +292,8 @@ def update_robot(self):
self.navigationMode = response['cleaning']['navigationMode']
self.spotWidth = response['cleaning']['spotWidth']
self.spotHeight = response['cleaning']['spotHeight']
self.mapId = response['cleaning']['mapId']
if 'mapId' in response['cleaning']:
self.mapId = response['cleaning']['mapId']

return response

Expand Down Expand Up @@ -364,7 +370,7 @@ def __get_current_date(self):
try:
locale.setlocale(locale.LC_TIME, 'en_US.utf8')
except locale.Error as e:
self.logger.error("Robot: Locale setting Error. Please install locale en_US.utf8: "+e)
self.logger.error("Robot: Locale setting error. Please install locale en_US.utf8: "+e)
return None
date = time.strftime('%a, %d %b %Y %H:%M:%S', time.gmtime()) + ' GMT'
locale.setlocale(locale.LC_TIME, saved_locale)
Expand Down
2 changes: 1 addition & 1 deletion neato/webif/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ def index(self, reload=None, action=None, email=None, hashInput=None, code=None,
self.plugin.dismiss_current_alert()
resetAlarmsSuccessfull = True
elif action =="listAvailableMaps":
self.logger.warning("List all available maps via webinterface")
boundaryListSuccessfull = self.plugin.get_map_boundaries(map_id=mapIDInput)
self.logger.warning(f"Request all available maps via webinterface successfull: {boundaryListSuccessfull }")
else:
self.logger.error("Unknown command received via webinterface")

Expand Down

0 comments on commit 3ac1457

Please sign in to comment.