diff --git a/bundles/org.openhab.binding.tado/README.md b/bundles/org.openhab.binding.tado/README.md index c29aaacb61fb8..42f42482a3600 100644 --- a/bundles/org.openhab.binding.tado/README.md +++ b/bundles/org.openhab.binding.tado/README.md @@ -14,11 +14,12 @@ The binding will automatically discover this thing and place it in the Inbox. It must be authenticated before it will actually go online. Authenticatation is done online via the OAuth Device Code Grant Flow (RFC-8628) authentication process via the link provided at `http://[openhab-ip-address]:8080/tado`. -| Parameter | Optional | Description | -|---------------|----------|-------------------------------------------------------------------------------| -| `rfcWithUser` | yes | Determines if the user name is included in the oAuth RFC-8628 authentication. | -| `username` | yes | Selects the tado° account to be used if there is more than one account. | -| `homeId` | yes | Selects the Home Id to use in case of more than one home per account. | +| Parameter | Optional | Description | Default | +|---------------|----------|-------------------------------------------------------------------------------|------------------------------| +| `rfcWithUser` | yes | Determines if the user name is included in the oAuth RFC-8628 authentication. | | +| `tadoApiUrl` | no | Selects the URL to be used for API calls (it's possible to use a proxy) | `https://my.tado.com/api/v2` | +| `username` | yes | Selects the tado° account to be used if there is more than one account. | | +| `homeId` | yes | Selects the Home Id to use in case of more than one home per account. | | The `rfcWithUser` and `username` settings are only needed if you have more than one tado° account. The `rfcWithUser` setting makes the binding use a different authentication token for each respective account `username`. diff --git a/bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/api/HomeApiFactory.java b/bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/api/HomeApiFactory.java index ca0e00df0e2e2..8b0ac3949aed0 100644 --- a/bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/api/HomeApiFactory.java +++ b/bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/api/HomeApiFactory.java @@ -29,9 +29,9 @@ @NonNullByDefault public class HomeApiFactory { - public HomeApi create(OAuthClientService oAuthClientService) { + public HomeApi create(OAuthClientService oAuthClientService, String baseUrl) { Gson gson = GsonBuilderFactory.defaultGsonBuilder().create(); OAuthorizerV2 authorizer = new OAuthorizerV2(oAuthClientService); - return new HomeApi(gson, authorizer); + return new HomeApi(gson, authorizer, baseUrl); } } diff --git a/bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/config/TadoHomeConfig.java b/bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/config/TadoHomeConfig.java index 74625989dc9a6..6f3d09917b77a 100644 --- a/bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/config/TadoHomeConfig.java +++ b/bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/config/TadoHomeConfig.java @@ -25,4 +25,5 @@ public class TadoHomeConfig { public @Nullable String username; public @Nullable Boolean rfcWithUser; public @Nullable Integer homeId; + public String tadoApiUrl = "https://my.tado.com/api/v2"; } diff --git a/bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/handler/TadoHomeHandler.java b/bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/handler/TadoHomeHandler.java index e7d41578c3b49..b2649e0144500 100644 --- a/bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/handler/TadoHomeHandler.java +++ b/bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal/handler/TadoHomeHandler.java @@ -101,7 +101,7 @@ public void initialize() { OAuthClientService oAuthClientService = tadoHandlerFactory.subscribeOAuthClientService(this, user); oAuthClientService.addAccessTokenRefreshListener(this); - this.api = new HomeApiFactory().create(oAuthClientService); + this.api = new HomeApiFactory().create(oAuthClientService, configuration.tadoApiUrl); this.oAuthClientService = oAuthClientService; logger.trace("initialize() api v2 created"); confPendingText = CONF_PENDING_OAUTH_CREDS.formatted(TadoAuthenticationServlet.PATH, diff --git a/bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/swagger/codegen/api/client/HomeApi.java b/bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/swagger/codegen/api/client/HomeApi.java index ee9c4b550fed3..96f384f8bf643 100644 --- a/bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/swagger/codegen/api/client/HomeApi.java +++ b/bundles/org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/swagger/codegen/api/client/HomeApi.java @@ -49,15 +49,16 @@ public class HomeApi { private static final HttpClient CLIENT = new HttpClient(new SslContextFactory.Client()); - private String baseUrl = "https://my.tado.com/api/v2"; + private String baseUrl; private int timeout = 5000; private Gson gson; private OAuthorizerV2 authorizer; - public HomeApi(Gson gson, OAuthorizerV2 authorizer) { + public HomeApi(Gson gson, OAuthorizerV2 authorizer, String baseUrl) { this.gson = gson; this.authorizer = authorizer; + this.baseUrl = baseUrl; } public void deleteZoneOverlay(Long homeId, Long zoneId) throws IOException, ApiException { diff --git a/bundles/org.openhab.binding.tado/src/main/resources/OH-INF/i18n/tado.properties b/bundles/org.openhab.binding.tado/src/main/resources/OH-INF/i18n/tado.properties index 84f3367254ed9..704174f1aae3c 100644 --- a/bundles/org.openhab.binding.tado/src/main/resources/OH-INF/i18n/tado.properties +++ b/bundles/org.openhab.binding.tado/src/main/resources/OH-INF/i18n/tado.properties @@ -22,6 +22,8 @@ thing-type.config.tado.home.homeId.label = Home Id thing-type.config.tado.home.homeId.description = Selects the Home Id to be used if there is more than one home per account. thing-type.config.tado.home.rfcWithUser.label = RFC-8628 with User thing-type.config.tado.home.rfcWithUser.description = Determines if the user name is included in the oAuth RFC-8628 authentication +thing-type.config.tado.home.tadoApiUrl.label = API Base URL +thing-type.config.tado.home.tadoApiUrl.description = The base URL used for all API requests. Can be changed to use a proxy. thing-type.config.tado.home.username.label = User Name thing-type.config.tado.home.username.description = Selects the tado° account to be used if there is more than one account. thing-type.config.tado.mobiledevice.id.label = Mobile Device Id diff --git a/bundles/org.openhab.binding.tado/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.tado/src/main/resources/OH-INF/thing/thing-types.xml index 2d21666cdc508..870eb70c7553f 100644 --- a/bundles/org.openhab.binding.tado/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.tado/src/main/resources/OH-INF/thing/thing-types.xml @@ -26,6 +26,13 @@ true + + + he base URL used for all API requests. Can be changed to use a proxy. + https://my.tado.com/api/v2 + true + + Selects the tado° account to be used if there is more than one account.