From 3ac145750ecf196117d836453f1f4741e8b3dfaa Mon Sep 17 00:00:00 2001 From: aschwith Date: Tue, 21 Nov 2023 20:29:45 +0100 Subject: [PATCH] neato: reduced timeout exceptions from error to warning level; fixed exception for situations in which mapID attribute is not available --- neato/__init__.py | 2 +- neato/plugin.yaml | 2 +- neato/robot.py | 14 ++++++++++---- neato/webif/__init__.py | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/neato/__init__.py b/neato/__init__.py index d9eb69282..8bcab3b96 100755 --- a/neato/__init__.py +++ b/neato/__init__.py @@ -30,7 +30,7 @@ class Neato(SmartPlugin): - PLUGIN_VERSION = '1.6.8' + PLUGIN_VERSION = '1.6.9' robot = 'None' def __init__(self, sh): diff --git a/neato/plugin.yaml b/neato/plugin.yaml index c499cbe43..75c9ba37c 100755 --- a/neato/plugin.yaml +++ b/neato/plugin.yaml @@ -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 diff --git a/neato/robot.py b/neato/robot.py index d40f3d872..050875895 100755 --- a/neato/robot.py +++ b/neato/robot.py @@ -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': @@ -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' @@ -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 @@ -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) diff --git a/neato/webif/__init__.py b/neato/webif/__init__.py index fd604010b..f5c81c9f1 100755 --- a/neato/webif/__init__.py +++ b/neato/webif/__init__.py @@ -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")