From ecf4914946181e733f9355453847a9e62530a81c Mon Sep 17 00:00:00 2001 From: DutchmanNL Date: Sun, 12 Nov 2023 16:41:57 +0100 Subject: [PATCH] Only show error messages once for unreachable devices --- README.md | 4 ++++ main.js | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e687ce4..727c0dc 100644 --- a/README.md +++ b/README.md @@ -168,6 +168,10 @@ If you like my work, please consider a personal donation ### __WORK IN PROGRESS__ * (DutchmanNL) --> + +### __WORK IN PROGRESS__ +* (DutchmanNL) Only show error messages once for unreachable devices + ### 0.5.0-beta.0 (2023-11-12) - Rebuild Admin Interface & Connection handler * (DutchmanNL) Admin interface redesigned to JSON-Config relates #171 * (DutchmanNL) Backend massages implemented to Add/Modify/Delete devices diff --git a/main.js b/main.js index a82a5e2..53ec0ac 100644 --- a/main.js +++ b/main.js @@ -616,31 +616,31 @@ class Esphome extends utils.Adapter { // Optimise error messages if ((error.message && (error.message.includes('EHOSTUNREACH') || error.message.includes('EHOSTDOWN'))) || (error.code && error.code.includes('ETIMEDOUT'))) { optimisedError = `Client ${host} unreachable !`; - if (!clientDetails[host].connectError) { + if (!clientDetails[host].connectionError) { this.log.error(optimisedError); await this.updateConnectionStatus(host, false, false, 'unreachable', true); } } else if (error.message.includes('Invalid password')) { optimisedError = `Client ${host} incorrect password !`; - if (!clientDetails.connectError) { + if (!clientDetails.connectionError) { this.log.error(optimisedError); await this.updateConnectionStatus(host, false, false, 'API password incorrect', true); } } else if (error.message.includes('Encryption expected')) { optimisedError = `Client ${host} requires encryption key which has not been provided, please enter encryption key in adapter settings for this device !`; - if (!clientDetails[host].connectError) { + if (!clientDetails[host].connectionError) { this.log.error(optimisedError); await this.updateConnectionStatus(host, false, false, 'Encryption Key Missing', true); } } else if (error.message.includes('ECONNRESET')) { optimisedError = `Client ${host} Connection Lost, will reconnect automatically when device is available!`; - if (!clientDetails[host].connectError) { + if (!clientDetails[host].connectionError) { this.log.warn(optimisedError); await this.updateConnectionStatus(host, false, false, 'connection lost', true); } } else if (error.message.includes('timeout')) { optimisedError = `Client ${host} Timeout, will reconnect automatically when device is available!`; - if (!clientDetails[host].connectError) { + if (!clientDetails[host].connectionError) { this.log.warn(optimisedError); await this.updateConnectionStatus(host, false, false, 'unreachable', true); }