From 6b97f67d1d1ce6af3a0e598ba77eec8f570a0854 Mon Sep 17 00:00:00 2001 From: DutchmanNL Date: Sun, 3 Dec 2023 17:39:06 +0100 Subject: [PATCH] add optimised error handling in situation network is unavailable --- main.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 050de6f..98c8b0f 100644 --- a/main.js +++ b/main.js @@ -710,11 +710,18 @@ class Esphome extends utils.Adapter { this.log.warn(optimisedError); await this.updateConnectionStatus(host, false, false, 'unreachable', true); } - } else if (error.message.includes('ECONNREFUSED')) { + } else if (error.message.includes('ECONNREFUSED')) { optimisedError = `Client ${host} not yet ready to connect, will try again!`; await this.updateConnectionStatus(host, false, true, 'initializing', true); this.log.warn(optimisedError); + } else if (error.message.includes('ENETUNREACH')) { + optimisedError = `Network not ready to connect to client ${host}`; + if (!clientDetails[host].connectionError) { + await this.updateConnectionStatus(host, false, true, 'No Network', true); + this.log.warn(optimisedError); + } + } else if (error.message.includes('write after end')) { // Ignore error } else {