]> git.basschouten.com Git - openhab-addons.git/commitdiff
[netatmo] Enhance bridge status reporting (#16571)
authorGaël L'hopital <gael@lhopital.org>
Mon, 25 Mar 2024 08:13:48 +0000 (09:13 +0100)
committerGitHub <noreply@github.com>
Mon, 25 Mar 2024 08:13:48 +0000 (09:13 +0100)
* Enhance bridge status reporting

---------

Signed-off-by: clinique <gael@lhopital.org>
bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/config/ConfigurationLevel.java
bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/ApiBridgeHandler.java
bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/servlet/NetatmoServlet.java
bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/servlet/WebhookServlet.java
bundles/org.openhab.binding.netatmo/src/main/resources/OH-INF/i18n/netatmo.properties

index 0d08ca6169b7e27d1f895408ba40f5df3a79d106..4eaa0ca19ec908d9a716db5236dde7e0b98c084c 100644 (file)
@@ -23,7 +23,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
 public enum ConfigurationLevel {
     EMPTY_CLIENT_ID("@text/conf-error-no-client-id"),
     EMPTY_CLIENT_SECRET("@text/conf-error-no-client-secret"),
-    REFRESH_TOKEN_NEEDED("@text/conf-error-grant-needed"),
+    REFRESH_TOKEN_NEEDED("@text/conf-error-grant-needed [ \"%s\" ]"),
     COMPLETED("");
 
     public String message;
index e4ae66f196f09f5c63ef8833dfd055ee8396cbba..4df7a1978c1483e63ddefba8418496c0c04c02b8 100644 (file)
@@ -232,7 +232,7 @@ public class ApiBridgeHandler extends BaseBridgeHandler {
         servlet.startListening();
         grantServlet = Optional.of(servlet);
         updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
-                ConfigurationLevel.REFRESH_TOKEN_NEEDED.message);
+                ConfigurationLevel.REFRESH_TOKEN_NEEDED.message.formatted(servlet.getPath()));
     }
 
     public ApiHandlerConfiguration getConfiguration() {
index 81760aca63f6a02c714d2ceb9da2751be5d9c694..c07656aa65ab04c03e0bf243202f640c20ce70ec 100644 (file)
@@ -36,9 +36,9 @@ public abstract class NetatmoServlet extends HttpServlet {
 
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
     private final HttpService httpService;
+    private final String path;
 
     protected final ApiBridgeHandler handler;
-    protected final String path;
 
     public NetatmoServlet(ApiBridgeHandler handler, HttpService httpService, String localPath) {
         this.path = BASE_PATH + localPath + "/" + handler.getId();
@@ -60,4 +60,8 @@ public abstract class NetatmoServlet extends HttpServlet {
         httpService.unregister(path);
         this.destroy();
     }
+
+    public String getPath() {
+        return path;
+    }
 }
index bdd11df6327fb6b1dd17efcada07ff2ec31be0f0..b3f10bac5b18f168a5c165397b4ce445b9ed6b3f 100644 (file)
@@ -66,7 +66,7 @@ public class WebhookServlet extends NetatmoServlet {
     @Override
     public void startListening() {
         super.startListening();
-        URI uri = UriBuilder.fromUri(webHookUrl).path(path + webHookPostfix).build();
+        URI uri = UriBuilder.fromUri(webHookUrl).path(getPath() + webHookPostfix).build();
         try {
             logger.info("Setting up WebHook at Netatmo to {}", uri.toString());
             hookSet = securityApi.addwebhook(uri);
index 940b2d6f6911801303be996101d90b4436440585..7df9236505b256789ff2977b47f375f8ee77dbed 100644 (file)
@@ -459,7 +459,7 @@ config.refreshInterval.description = The refresh interval to poll Netatmo API (i
 
 conf-error-no-client-id = Cannot connect to Netatmo bridge as no client id is available in the configuration
 conf-error-no-client-secret = Cannot connect to Netatmo bridge as no client secret is available in the configuration
-conf-error-grant-needed = Configuration incomplete, please grant the binding to Netatmo Connect.
+conf-error-grant-needed = Complete the configuration by granting the binding to Netatmo Connect: ''{0}''.
 status-bridge-offline = Bridge is not connected to Netatmo API
 device-not-connected = Thing is not reachable
 data-over-limit = Data seems quite old