From 9a1bb8c9fb28d0954684744f3bbe714705dce626 Mon Sep 17 00:00:00 2001 From: crocri Date: Thu, 17 Oct 2024 17:23:35 +0200 Subject: [PATCH 1/2] Error Handling and Parameters --- admin/i18n/de/translations.json | 7 +- admin/i18n/en/translations.json | 7 +- admin/i18n/es/translations.json | 7 +- admin/i18n/fr/translations.json | 7 +- admin/i18n/it/translations.json | 7 +- admin/i18n/nl/translations.json | 7 +- admin/i18n/pl/translations.json | 7 +- admin/i18n/pt/translations.json | 7 +- admin/i18n/ru/translations.json | 7 +- admin/i18n/uk/translations.json | 7 +- admin/i18n/zh-cn/translations.json | 7 +- admin/jsonConfig.json | 247 +++++++++++++++++------------ io-package.json | 4 +- main.js | 44 +++-- 14 files changed, 247 insertions(+), 125 deletions(-) diff --git a/admin/i18n/de/translations.json b/admin/i18n/de/translations.json index 8f9aa8a..0d3934d 100644 --- a/admin/i18n/de/translations.json +++ b/admin/i18n/de/translations.json @@ -58,5 +58,10 @@ "NoPoll": "Keine Umfrage", "Status": "Status", "Info": "Die Info", - "GarageDoor": "Garagentor" + "GarageDoor": "Garagentor", + "Ignore errors": "Ignoriere Fehler", + "errMain": "Allgemein", + "errMain_desc": "Unterdrückt allgemeine Fehler", + "errPing": "Ping", + "errPing_desc": "Keine Antwort bei Ping wird ignoriert" } diff --git a/admin/i18n/en/translations.json b/admin/i18n/en/translations.json index 2ae2cca..c07e9c7 100644 --- a/admin/i18n/en/translations.json +++ b/admin/i18n/en/translations.json @@ -58,5 +58,10 @@ "NoPoll": "No polling", "Status": "Status", "Info": "Info", - "GarageDoor":"Garage door" + "GarageDoor":"Garage door", + "Ignore errors": "Ignore errors", + "errMain": "General", + "errMain_desc": "Suppress general errors", + "errPing": "Ping", + "errPing_desc": "No response to Ping is ignored" } diff --git a/admin/i18n/es/translations.json b/admin/i18n/es/translations.json index 524b229..c23acfd 100644 --- a/admin/i18n/es/translations.json +++ b/admin/i18n/es/translations.json @@ -58,5 +58,10 @@ "NoPoll": "Sin encuestas", "Status": "Estado", "Info": "Información", - "GarageDoor": "Puerta de la cochera" + "GarageDoor": "Puerta de la cochera", + "Ignore errors": "Ignorar errores", + "errMain": "General", + "errMain_desc": "Suprime los errores generales", + "errPing": "Ping", + "errPing_desc": "Se ignora la falta de respuesta al ping" } diff --git a/admin/i18n/fr/translations.json b/admin/i18n/fr/translations.json index 8b468fb..9bd3c77 100644 --- a/admin/i18n/fr/translations.json +++ b/admin/i18n/fr/translations.json @@ -58,5 +58,10 @@ "NoPoll": "Pas de sondage", "Status": "Statut", "Info": "Info", - "GarageDoor": "Porte de garage" + "GarageDoor": "Porte de garage", + "Ignore errors": "Ignorer les erreurs", + "errMain": "Général", + "errMain_desc": "Supprime les erreurs générales", + "errPing": "Ping", + "errPing_desc": "Pas de réponse au ping est ignoré" } diff --git a/admin/i18n/it/translations.json b/admin/i18n/it/translations.json index 5f56f25..66a0e79 100644 --- a/admin/i18n/it/translations.json +++ b/admin/i18n/it/translations.json @@ -58,5 +58,10 @@ "NoPoll": "Nessun sondaggio", "Status": "Stato", "Info": "Informazioni", - "GarageDoor": "Porta del garage" + "GarageDoor": "Porta del garage", + "Ignore errors": "Ignorare gli errori", + "errMain": "Generale", + "errMain_desc": "Sopprime gli errori generali", + "errPing": "Ping", + "errPing_desc": "Nessuna risposta al ping viene ignorata" } diff --git a/admin/i18n/nl/translations.json b/admin/i18n/nl/translations.json index dcda32f..94191ab 100644 --- a/admin/i18n/nl/translations.json +++ b/admin/i18n/nl/translations.json @@ -58,5 +58,10 @@ "NoPoll": "Geen opiniepeiling", "Status": "Toestand", "Info": "Info", - "GarageDoor": "Garagedeur" + "GarageDoor": "Garagedeur", + "Ignore errors": "Fouten negeren", + "errMain": "Algemeen", + "errMain_desc": "Onderdrukt algemene fouten", + "errPing": "Ping", + "errPing_desc": "Geen reactie op ping wordt genegeerd" } diff --git a/admin/i18n/pl/translations.json b/admin/i18n/pl/translations.json index 67c95be..6b63647 100644 --- a/admin/i18n/pl/translations.json +++ b/admin/i18n/pl/translations.json @@ -58,5 +58,10 @@ "NoPoll": "Żadnego głosowania", "Status": "Status", "Info": "Informacje", - "GarageDoor": "Drzwi garażowe" + "GarageDoor": "Drzwi garażowe", + "Ignore errors": "Ignorowanie błędów", + "errMain": "Ogólne", + "errMain_desc": "Pomija błędy ogólne", + "errPing": "Ping", + "errPing_desc": "Brak odpowiedzi na ping jest ignorowany" } diff --git a/admin/i18n/pt/translations.json b/admin/i18n/pt/translations.json index 9804a2a..aaa3852 100644 --- a/admin/i18n/pt/translations.json +++ b/admin/i18n/pt/translations.json @@ -58,5 +58,10 @@ "NoPoll": "Sem votação", "Status": "Status", "Info": "Informações", - "GarageDoor": "Porta da garagem" + "GarageDoor": "Porta da garagem", + "Ignore errors": "Ignorar erros", + "errMain": "Geral", + "errMain_desc": "Suprime erros gerais", + "errPing": "Ping", + "errPing_desc": "A ausência de resposta ao ping é ignorada" } diff --git a/admin/i18n/ru/translations.json b/admin/i18n/ru/translations.json index e31e802..dffee12 100644 --- a/admin/i18n/ru/translations.json +++ b/admin/i18n/ru/translations.json @@ -58,5 +58,10 @@ "NoPoll": "Нет опроса", "Status": "Положение дел", "Info": "Информация", - "GarageDoor": "Гаражная дверь" + "GarageDoor": "Гаражная дверь", + "Ignore errors": "Игнорировать ошибки", + "errMain": "Общие", + "errMain_desc": "Подавляет общие ошибки", + "errPing": "Пинг", + "errPing_desc": "Отсутствие ответа на пинг игнорируется" } diff --git a/admin/i18n/uk/translations.json b/admin/i18n/uk/translations.json index ed5559b..b259a0f 100644 --- a/admin/i18n/uk/translations.json +++ b/admin/i18n/uk/translations.json @@ -58,5 +58,10 @@ "NoPoll": "Жодного опитування", "Status": "Статус", "Info": "Інформація", - "GarageDoor": "Гаражні ворота" + "GarageDoor": "Гаражні ворота", + "Ignore errors": "Ігнорувати помилки", + "errMain": "Загальні", + "errMain_desc": "Пригнічує загальні помилки", + "errPing": "Пінг", + "errPing_desc": "Ігнорується відсутність відповіді на пінг" } diff --git a/admin/i18n/zh-cn/translations.json b/admin/i18n/zh-cn/translations.json index 995923f..5d13103 100644 --- a/admin/i18n/zh-cn/translations.json +++ b/admin/i18n/zh-cn/translations.json @@ -58,5 +58,10 @@ "NoPoll": "没有轮询", "Status": "地位", "Info": "信息", - "GarageDoor": "车库门" + "GarageDoor": "车库门", + "Ignore errors": "忽略错误", + "errMain": "一般错误", + "errMain_desc": "抑制一般错误", + "errPing": "平移", + "errPing_desc": "忽略无响应的平移" } diff --git a/admin/jsonConfig.json b/admin/jsonConfig.json index 6e7c20a..74c8f19 100644 --- a/admin/jsonConfig.json +++ b/admin/jsonConfig.json @@ -11,15 +11,6 @@ "md": 8, "lg": 6 }, - "_pollConfigSection": { - "newLine": false, - "type": "header", - "text": "Polling configuration", - "size": 2, - "sm": 24, - "md": 8, - "lg": 6 - }, "robonectIp": { "newLine": true, "type": "text", @@ -30,6 +21,7 @@ "lg": 2 }, "username": { + "newLine": false, "type": "text", "label": "Username", "tooltip": "Username_desc", @@ -38,6 +30,7 @@ "lg": 2 }, "password": { + "newLine": false, "type": "password", "label": "password", "tooltip": "password_desc", @@ -45,8 +38,17 @@ "md": 3, "lg": 2 }, + "_pollConfigSection": { + "newLine": true, + "type": "header", + "text": "Polling configuration", + "size": 2, + "sm": 24, + "md": 8, + "lg": 6 + }, "batteryPollType": { - "newLine": false, + "newLine": true, "type": "select", "label": "batteryPollType", "default": "Status", @@ -93,15 +95,6 @@ "md": 4, "lg": 3 }, - "_pushServiceSection": { - "newLine": true, - "type": "header", - "text": "Push Service", - "size": 2, - "sm": 24, - "md": 8, - "lg": 6 - }, "errorsPollType": { "newLine": false, "type": "select", @@ -150,37 +143,6 @@ "md": 4, "lg": 3 }, - "pushService": { - "newLine": true, - "type": "checkbox", - "label": "enabled", - "tooltip": "pushService_desc", - "default": false, - "sm": 4, - "md": 3, - "lg": 2 - }, - "pushServiceIp": { - "newLine": false, - "type": "ip", - "listenOnAllPorts": true, - "label": "pushServiceIp", - "tooltip": "pushServiceIp_desc", - "sm": 4, - "md": 3, - "lg": 2 - }, - "pushServicePort": { - "type": "number", - "min": 1, - "max": 65565, - "default": 55443, - "label": "pushServicePort", - "tooltip": "pushServicePort_desc", - "sm": 4, - "md": 3, - "lg": 2 - }, "gpsPollType": { "newLine": false, "type": "select", @@ -229,15 +191,6 @@ "md": 4, "lg": 3 }, - "_pollingSection": { - "newLine": true, - "type": "header", - "text": "Polling", - "size": 2, - "sm": 24, - "md": 8, - "lg": 6 - }, "motorPollType": { "newLine": false, "type": "select", @@ -286,33 +239,6 @@ "md": 4, "lg": 3 }, - "pingFirst": { - "newLine": true, - "type": "checkbox", - "label": "Ping device before polling", - "sm": 4, - "md": 3, - "lg": 2 - }, - "statusInterval": { - "type": "number", - "default": 36000, - "label": "pollTimeStatus", - "tooltip": "pollTimeStatus_desc", - "sm": 14, - "md": 3, - "lg": 2 - }, - "infoInterval": { - "newLine": false, - "type": "number", - "default": 24000, - "label": "pollTimeInfo", - "tooltip": "pollTimeInfo_desc", - "sm": 14, - "md": 3, - "lg": 2 - }, "pushPollType": { "newLine": false, "type": "select", @@ -361,14 +287,6 @@ "md": 4, "lg": 3 }, - "_placeholder": { - "newLine": true, - "type": "staticText", - "label": "", - "sm": 24, - "md": 8, - "lg": 6 - }, "versionPollType": { "newLine": false, "type": "select", @@ -417,15 +335,6 @@ "md": 4, "lg": 3 }, - "_noPollSection": { - "newLine": true, - "type": "header", - "text": "No polling times", - "size": 2, - "sm": 24, - "md": 8, - "lg": 6 - }, "wlanPollType": { "newLine": false, "type": "select", @@ -450,6 +359,101 @@ "md": 4, "lg": 3 }, + "_pushServiceSection": { + "newLine": true, + "type": "header", + "text": "Push Service", + "size": 2, + "sm": 24, + "md": 8, + "lg": 6 + }, + "pushService": { + "newLine": true, + "type": "checkbox", + "label": "enabled", + "tooltip": "pushService_desc", + "default": false, + "sm": 4, + "md": 3, + "lg": 2 + }, + "pushServiceIp": { + "newLine": false, + "type": "ip", + "listenOnAllPorts": true, + "label": "pushServiceIp", + "tooltip": "pushServiceIp_desc", + "sm": 4, + "md": 3, + "lg": 2 + }, + "pushServicePort": { + "newLine": false, + "type": "number", + "min": 1, + "max": 65565, + "default": 55443, + "label": "pushServicePort", + "tooltip": "pushServicePort_desc", + "sm": 4, + "md": 3, + "lg": 2 + }, + "_pollingSection": { + "newLine": true, + "type": "header", + "text": "Polling", + "size": 2, + "sm": 24, + "md": 8, + "lg": 6 + }, + "pingFirst": { + "newLine": true, + "type": "checkbox", + "label": "Ping device before polling", + "sm": 4, + "md": 3, + "lg": 2 + }, + "statusInterval": { + "newLine": false, + "type": "number", + "default": 36000, + "label": "pollTimeStatus", + "tooltip": "pollTimeStatus_desc", + "sm": 14, + "md": 3, + "lg": 2 + }, + "infoInterval": { + "newLine": false, + "type": "number", + "default": 24000, + "label": "pollTimeInfo", + "tooltip": "pollTimeInfo_desc", + "sm": 14, + "md": 3, + "lg": 2 + }, + "_placeholder": { + "newLine": true, + "type": "staticText", + "label": "", + "sm": 24, + "md": 8, + "lg": 6 + }, + "_noPollSection": { + "newLine": true, + "type": "header", + "text": "No polling times", + "size": 2, + "sm": 24, + "md": 8, + "lg": 6 + }, "restPeriod1Start": { "newLine": true, "type": "text", @@ -459,6 +463,7 @@ "lg": 2 }, "restPeriod2Start": { + "newLine": false, "label": "restPeriod2Start", "type": "text", "sm": 4, @@ -474,11 +479,45 @@ "lg": 2 }, "restPeriod2End": { + "newLine": false, "label": "restPeriod2End", "type": "text", "sm": 4, "md": 3, "lg": 2 + }, + "_ignoreErrorsSection": { + "newLine": true, + "type": "header", + "text": "Ignore errors", + "size": 2, + "sm": 24, + "md": 8, + "lg": 6 + }, + "errMain": { + "newLine": true, + "type": "number", + "min": 0, + "max": 5, + "default": 0, + "label": "errMain", + "tooltip": "errMain_desc", + "sm": 14, + "md": 3, + "lg": 2 + }, + "errPing": { + "newLine": false, + "type": "number", + "min": 0, + "max": 20, + "default": 0, + "label": "errPing", + "tooltip": "errPing_desc", + "sm": 14, + "md": 3, + "lg": 2 } } -} +} \ No newline at end of file diff --git a/io-package.json b/io-package.json index bf4d352..1845e9a 100644 --- a/io-package.json +++ b/io-package.json @@ -184,7 +184,9 @@ "timerPollType": "Info", "versionPollType": "Info", "weatherPollType": "NoPoll", - "wlanPollType": "Info" + "wlanPollType": "Info", + "errMain": 0, + "errPing": 0 }, "encryptedNative": [ "password" diff --git a/main.js b/main.js index 3f554e8..76a523b 100644 --- a/main.js +++ b/main.js @@ -59,6 +59,10 @@ class Robonect extends utils.Adapter { this.infoTimeout; this.statusTimeout; + this.ignError; + this.occError; + this.ignPing; + this.failedPing; // http-server for Robonect PushService this.ps; this.ps_host; @@ -111,7 +115,12 @@ class Robonect extends utils.Adapter { this.ps_host = this.config.pushServiceIp; this.ps_port = this.config.pushServicePort; this.apiUrl = `http://${this.robonectIp}/api/json`; - + // + this.ignError = this.config.errMain; + this.occError = 0; + this.ignPing = this.config.errPing; + this.failedPing = 0; + // if (isNaN(this.statusInterval) || this.statusInterval < 1) { this.statusInterval = 60; this.log.warn('No status interval set. Using default value (60 seconds).'); @@ -129,7 +138,7 @@ class Robonect extends utils.Adapter { this.restPeriod1End = ''; this.log.error('Rest period 1 not configured correctly. Period will be ignored.'); } else { - this.log.warn('Rest period 1 configured (' + this.restPeriod1Start + ' - ' + this.restPeriod1End + '). Only API call /json?cmd=status will be done.'); + this.log.warn('Rest period 1 configured (' + this.restPeriod1Start + ' - ' + this.restPeriod1End + '). Only API call /json?cmd=status will be done.' ); } if (this.restPeriod2Start === '' && this.restPeriod2End === '') { @@ -139,7 +148,7 @@ class Robonect extends utils.Adapter { this.restPeriod2End = ''; this.log.error('Rest period 2 not configured correctly. Period will be ignored.'); } else { - this.log.warn('Rest period 2 configured (' + this.restPeriod2Start + ' - ' + this.restPeriod2End + '). Only API call /json?cmd=status will be done.'); + this.log.warn('Rest period 2 configured (' + this.restPeriod2Start + ' - ' + this.restPeriod2End + '). Only API call /json?cmd=status will be done.' ); } await this.testPushServiceConfig(); @@ -433,7 +442,7 @@ class Robonect extends utils.Adapter { && (this.config.pushServiceIp !== `::`) // listen to all IPV6 adresses ) { this.log.warn(`Push Service is enabled in config, but misconfigured. Please update your Robonect Push-Service configuration.`); - this.log.warn(`The configured URL in your Robonect is: [${url}] -> but should be: ${this.config.pushServiceIp}:${this.config.pushServicePort}`); + this.log.warn(`The configured URL in your Robonect is: [${url}] -> but should be: ${this.config.pushServiceIp}:${this.config.pushServicePort }`); } }) .catch((err)=> { @@ -506,6 +515,7 @@ class Robonect extends utils.Adapter { await ping.sys.probe(this.robonectIp, async function (isAlive) { hostOnline = isAlive; adapter.log.debug(`Adapter is configured to ping the robonect device - and it's ${hostOnline? '':'not'} online.`); + if (hostOnline) adapter.failedPing = 0; }); } else { // no pingFirst configured - assume device to be online @@ -533,6 +543,7 @@ class Robonect extends utils.Adapter { .then((data) => { adapter.log.silly(`Data from poll: ${JSON.stringify(data)}`); adapter.currentStatus = data['status']['status']; + adapter.occError = 0; }) .catch((err) => { // adapter.log.error(`Polling robonect status: ${JSON.stringify(err)}`); @@ -578,10 +589,19 @@ class Robonect extends utils.Adapter { adapter.log.debug('Polling done'); } catch (err) { - adapter.doErrorHandling(err); + if (pollType === 'Initial') { + adapter.log.debug('Initial polling failed, try again after 5 seconds...'); + setTimeout(() => { this.updateRobonectData('Initial') }, 5000); + } else { + adapter.doErrorHandling(err); + } } } else { - adapter.log.warn('No connection to lawn mower (Not able to ping it). Check network connection.'); + adapter.failedPing++; + if (adapter.failedPing >= adapter.ignPing) { + adapter.log.warn('No connection to lawn mower (Not able to ping it). Check network connection.'); + adapter.failedPing = 0; + } } } @@ -606,8 +626,14 @@ class Robonect extends utils.Adapter { this.terminate(11); break; } - default: - this.log.warn('Error returned from Robonect device: '+JSON.stringify(err)); + default: { + this.occError++; + if (this.occError >= this.ignError) { + this.log.warn('Error returned from Robonect device: '+JSON.stringify(err)); + this.occError = 0; + } + break; + } } } catch(error){ this.log.error('Error during error handling: '+JSON.stringify(error)); @@ -905,4 +931,4 @@ if (module.parent) { } else { // otherwise start the instance directly new Robonect(); -} +} \ No newline at end of file From f12f478e8c221804acc6087df1853e8f23faf788 Mon Sep 17 00:00:00 2001 From: crocri Date: Fri, 18 Oct 2024 17:23:14 +0200 Subject: [PATCH 2/2] changed error to silly --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index 76a523b..67697ff 100644 --- a/main.js +++ b/main.js @@ -610,7 +610,7 @@ class Robonect extends utils.Adapter { this.log.debug('Data received for error handling: '+JSON.stringify(err)); const errorCode = err.error_code || (err.response? err.response.status : -666); const errorMessage = err.error_message || err.message; - this.log.error(errorMessage); + this.log.silly(errorMessage); switch (errorCode) { case 7 : // Automower already stopped this.log.info(errorMessage);