Skip to content

Commit

Permalink
Added server fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
taurgis committed Oct 14, 2024
1 parent 9edfda5 commit aa0386e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"displayName": "Hombrige iRobot V2",
"name": "homebridge-irobot-v2",
"version": "3.2.2",
"version": "3.2.3-alpha.1",
"description": "A Homebridge plugin for controlling iRobot devices",
"license": "Apache-2.0",
"repository": {
Expand Down
10 changes: 7 additions & 3 deletions src/scripts/getRoombaCredentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ function handleGigyaSuccess(body) {
}
}

function loginToIRobot(body) {
function loginToIRobot(body, server = 1) {
const iRobotLoginOptions = {
hostname: 'unauth1.prod.iot.irobotapi.com',
hostname: `unauth${server}.prod.iot.irobotapi.com`,
path: '/v2/login',
method: 'POST',
headers: {
Expand All @@ -108,7 +108,11 @@ function loginToIRobot(body) {
try {
loginIrobotResponseHandler(null, res, JSON.parse(data));
} catch (e) {
loginIrobotResponseHandler(e);
if(server === 1) {
loginToIRobot(body, 2);
} else {
loginIrobotResponseHandler(e);
}
}
});
});
Expand Down

0 comments on commit aa0386e

Please sign in to comment.