Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
DutchmanNL committed Nov 3, 2023
1 parent b81efe1 commit f8a64f1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1064,12 +1064,12 @@ class Esphome extends utils.Adapter {
case 'addDevice':

// eslint-disable-next-line no-case-declarations,no-inner-declarations
function validateIPaddress(ipaddress) {
if (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ipaddress)) {
return true;
function validateIPaddress(ipaddress) {
if (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ipaddress)) {
return true;
}
return false;
}
return false;
}

// eslint-disable-next-line no-case-declarations
const ipValid = validateIPaddress(obj.message['device-ip']);
Expand Down Expand Up @@ -1368,7 +1368,7 @@ class Esphome extends utils.Adapter {
if (!knownDevices) return; // exit function if no known device are detected
if (knownDevices.length > 0) this.log.info(`Try to contact ${knownDevices.length} known devices`);
} catch (e) {
this.log.error(`[offlineDeviceCleanup] Fatal error occured, cannot cleanup offline devices ${e} | ${e.stack}`);
this.log.error(`[offlineDeviceCleanup] Fatal error occurred, cannot cleanup offline devices ${e} | ${e.stack}`);

}
}
Expand Down

0 comments on commit f8a64f1

Please sign in to comment.