Skip to content

Commit

Permalink
fix for a crash on error handling (connection lost)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoduj committed Jan 15, 2019
1 parent 944b01d commit 4423057
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ Fields:
- `refreshTimerDuringOperartion` Optional - set the refresh timer during operation in progress to detect the end of the operation. (defaults : 5s, accepted range : 2-15s).

## Changelog

- 0.0.6
- [FIX] crash on error
- 0.0.5
- [FIX] crash homebridge when activating door
- 0.0.4
Expand Down
15 changes: 10 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Gogogate2Platform.prototype = {

//auth error
// ECONNREFUSED

// if we have a login error, try to reconnect
if (statuserror && statuserror.includes('ECONNREFUSED')) {
this.log('handleError - Connection refused, trying to reconnect');
Expand All @@ -113,16 +113,19 @@ Gogogate2Platform.prototype = {
});
}
// check for network connectivity
else if (statuserror && (
statuserror.includes('ENETUNREACH') ||
statuserror.includes('EHOSTUNREACH'))
else if (
statuserror &&
(statuserror.includes('ENETUNREACH') ||
statuserror.includes('EHOSTUNREACH'))
) {
//Try to send a WOL ?
this.log(
'handleError - No network connectivity, check gogogate accessibility'
);
}
//else print error
else if (statuserror && statuserror.includes('ETIMEDOUT')) {
//Try to send a WOL ?
this.log(
'handleError - timeout connecting to gogogate, check gogogate connectivity'
);
Expand Down Expand Up @@ -456,7 +459,9 @@ Gogogate2Platform.prototype = {

callback(true);
} else {
that.log.debug('activateDoor - Command sent to ' + controlService.subtype);
that.log.debug(
'activateDoor - Command sent to ' + controlService.subtype
);
callback(false);
}
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "homebridge-gogogate2",
"version": "0.0.5",
"version": "0.0.6",
"author": "Nicolas Dujardin",
"description": "Publish your gogogate 2 to homebridge",
"main": "index.js",
Expand Down

0 comments on commit 4423057

Please sign in to comment.