Skip to content

Commit

Permalink
Introduced new request error enum to account for superagent.min.js
Browse files Browse the repository at this point in the history
  • Loading branch information
flareman committed Aug 12, 2022
1 parent 013a9fd commit fe2d877
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.2.7] - 2022-8-12
### Fixed
- Introduced a new request error enumeration to compensate for lack thereof in superagent's minified library.


## [1.2.6] - 2022-8-3
### Fixed
- Network request mechanism was made more lenient; now the plugin will try to reconnect in case of network failure, before stopping responding gracefully (instead of bringing the entire homebridge instance crashing down with it). Likewise, after successfully logging in, errors will not cause the plugin to go non-responsive, defaulting to the last know values instead (and retrying during the next pollint attempt). Error reporting was made more robust; this version should fix the bugs introduced in v1.2.5.
Expand Down
4 changes: 2 additions & 2 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"displayName": "CaddX/NetworX Homebridge Plugin",
"name": "homebridge-caddx-interlogix",
"version": "1.2.6",
"version": "1.2.7",
"description": "A homebridge plugin for integrating the ComNav/NetworX/CaddX NX-595E network module with HomeKit.",
"author": "Spyros Smparounis <[email protected]> (https://github.com/flareman)",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/NX595ESecuritySystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ export class NX595ESecuritySystem {
} catch (error) {
throw(error);
}
} else if (superagent.ERROR_CODES.has(err.code)) {
} else if (Utilities.ERROR_CODES.has(err.code)) {
try {
await Utilities.delay(retryDelayDuration);
response = await superagent.post(address).type('form').send(payload).redirects(0);
Expand Down
3 changes: 0 additions & 3 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export class NX595EPlatform implements DynamicPlatformPlugin {
} catch (error) {
this.loggedIn = false;
this.log.error((<Error>error).message);
console.log(error);
this.setCatastrophe(this.accessories);
return;
}
Expand All @@ -80,7 +79,6 @@ export class NX595EPlatform implements DynamicPlatformPlugin {
setTimeout(this.updateAccessories.bind(this), this.pollTimer);
}).catch(err => {
this.log.error(err.message);
console.log(err);
this.setCatastrophe(this.accessories);
});
});
Expand Down Expand Up @@ -126,7 +124,6 @@ export class NX595EPlatform implements DynamicPlatformPlugin {
try { await this.securitySystem.poll(); }
catch (error) {
this.log.error((<Error>error).message);
console.log(error);
setTimeout(this.updateAccessories.bind(this), this.pollTimer);
return;
}
Expand Down
3 changes: 3 additions & 0 deletions src/utility.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
export const ERROR_CODES = new Set(['ETIMEDOUT', 'ECONNRESET', 'EADDRINUSE', 'ECONNREFUSED', 'EPIPE', 'ENOTFOUND', 'ENETUNREACH', 'EAI_AGAIN']);


export function CheckIPAddress(ipaddress: string) {
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);
Expand Down

0 comments on commit fe2d877

Please sign in to comment.