From 8db9895d9dfce28cfe411664e4509c8c408a10b7 Mon Sep 17 00:00:00 2001 From: Erik De Boeck Date: Fri, 31 Oct 2025 15:46:49 +0100 Subject: [PATCH 1/4] Adds proxy URL option Signed-off-by: Erik De Boeck --- bundles/org.openhab.binding.tado/README.md | 11 ++++++----- .../binding/tado/internal/api/HomeApiFactory.java | 4 ++-- .../binding/tado/internal/config/TadoHomeConfig.java | 1 + .../tado/internal/handler/TadoHomeHandler.java | 2 +- .../tado/swagger/codegen/api/client/HomeApi.java | 5 +++-- .../src/main/resources/OH-INF/i18n/tado.properties | 2 ++ .../src/main/resources/OH-INF/thing/thing-types.xml | 9 ++++++++- 7 files changed, 23 insertions(+), 11 deletions(-) diff --git a/bundles/org.openhab.binding.tado/README.md b/bundles/org.openhab.binding.tado/README.md index c29aaacb61fb8..f0355143f9eb7 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..ea759425400ed 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, 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..b92f267268a2c 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 = Selects the URL to be used for API calls (it's possible to use a proxy) +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..60bde5ebceae4 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,7 +26,14 @@ 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. true From 35c27e14a7fb32b72689c396fb87711b8c3d64bb Mon Sep 17 00:00:00 2001 From: Erik De Boeck Date: Fri, 31 Oct 2025 16:04:58 +0100 Subject: [PATCH 2/4] Addresses suggestions Signed-off-by: Erik De Boeck --- bundles/org.openhab.binding.tado/README.md | 12 ++++++------ .../src/main/resources/OH-INF/i18n/tado.properties | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bundles/org.openhab.binding.tado/README.md b/bundles/org.openhab.binding.tado/README.md index f0355143f9eb7..42f42482a3600 100644 --- a/bundles/org.openhab.binding.tado/README.md +++ b/bundles/org.openhab.binding.tado/README.md @@ -14,12 +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 | 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. | | +| 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/resources/OH-INF/i18n/tado.properties b/bundles/org.openhab.binding.tado/src/main/resources/OH-INF/i18n/tado.properties index b92f267268a2c..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,7 +22,7 @@ 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 = Selects the URL to be used for API calls (it's possible to use a proxy) +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. From 86366ea000ea936f9704e10a3b0aaf925746f45d Mon Sep 17 00:00:00 2001 From: Erik De Boeck Date: Fri, 31 Oct 2025 16:09:34 +0100 Subject: [PATCH 3/4] Applies `mvn spotless:apply` Signed-off-by: Erik De Boeck --- .../main/resources/OH-INF/thing/thing-types.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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 60bde5ebceae4..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 @@ -27,13 +27,13 @@ - - he base URL used for all API requests. Can be changed to use a proxy. - https://my.tado.com/api/v2 - 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. true From 83762bc655c0f748a2be56fd3576ab8d3d0366a7 Mon Sep 17 00:00:00 2001 From: Erik De Boeck Date: Fri, 31 Oct 2025 16:23:23 +0100 Subject: [PATCH 4/4] Deletes wrongly pasted argument Signed-off-by: Erik De Boeck --- .../org/openhab/binding/tado/internal/api/HomeApiFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ea759425400ed..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 @@ -32,6 +32,6 @@ public class HomeApiFactory { public HomeApi create(OAuthClientService oAuthClientService, String baseUrl) { Gson gson = GsonBuilderFactory.defaultGsonBuilder().create(); OAuthorizerV2 authorizer = new OAuthorizerV2(oAuthClientService); - return new HomeApi(gson, authorizer, authorizer, baseUrl); + return new HomeApi(gson, authorizer, baseUrl); } }