From aa0386e4447452be643aea51633a425ba8256236 Mon Sep 17 00:00:00 2001 From: Thomas Theunen Date: Mon, 14 Oct 2024 20:03:07 +0200 Subject: [PATCH] Added server fallback --- package.json | 2 +- src/scripts/getRoombaCredentials.js | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index f8b3e9a..b5c2429 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/scripts/getRoombaCredentials.js b/src/scripts/getRoombaCredentials.js index 41d7b07..0da2f16 100644 --- a/src/scripts/getRoombaCredentials.js +++ b/src/scripts/getRoombaCredentials.js @@ -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: { @@ -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); + } } }); });