Skip to content

Commit

Permalink
Only discover bridges which return some response
Browse files Browse the repository at this point in the history
Only bridges which return 200 or 403 response are discovered.
Nuki API might return bridges which no longer exists or are on different
network and are not reachable. We do not want to put these in inbox, only those
who respond do HTTP calls.

Signed-off-by: Jan Vybíral <jan.vybiral1@gmail.com>
  • Loading branch information
janvyb committed May 26, 2021
1 parent e1f27d0 commit 541ddd0
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,17 @@ public void run() {
BridgeApiAuthDto authResult = gson.fromJson(responseData, BridgeApiAuthDto.class);
if (authResult != null && authResult.isSuccess()) {
discoverBridge(bridge, authResult.getToken());
return;
} else {
logger.warn(
"Failed to get API token for bridge {}({}) - bridge did not return success response, make sure button on bridge was pressed during discovery",
bridge.getIp(), bridge.getBridgeId());
discoverBridge(bridge, "");
}
} else if (response.getStatus() == HttpStatus.FORBIDDEN_403) {
logger.error(
"Failed to get API token for bridge {}({}) - bridge authentication is disabled, check settings",
bridge.getIp(), bridge.getBridgeId());
discoverBridge(bridge, "");
} else {
logger.error("Failed to get API token for bridge {}({}) - invalid status {}: {}", bridge.getIp(),
bridge.getBridgeId(), response.getStatus(), responseData);
Expand All @@ -162,7 +163,6 @@ public void run() {
e.getMessage());
logger.debug("Failed to get API token for bridge {}({})", bridge.getIp(), bridge.getBridgeId(), e);
}
discoverBridge(bridge, "");
}
}
}

0 comments on commit 541ddd0

Please sign in to comment.