[netatmo] Enhance bridge status reporting (#16571)

* Enhance bridge status reporting

---------

Signed-off-by: clinique <gael@lhopital.org>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
Gaël L'hopital 2024-03-25 09:13:48 +01:00 committed by Ciprian Pascu
parent 4206dd811a
commit b861c02386
5 changed files with 9 additions and 5 deletions

View 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;

View 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() {

View 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;
}
}

View 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);

View 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