Skip to content

Commit

Permalink
[netatmo] Enhance bridge status reporting (openhab#16571)
Browse files Browse the repository at this point in the history
* Enhance bridge status reporting

---------

Signed-off-by: clinique <gael@lhopital.org>
  • Loading branch information
clinique authored and matchews committed Oct 18, 2024
1 parent 66d82ac commit da47897
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ private void startAuthorizationFlow() {
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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -60,4 +60,8 @@ public void dispose() {
httpService.unregister(path);
this.destroy();
}

public String getPath() {
return path;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public WebhookServlet(ApiBridgeHandler handler, HttpService httpService, NADeser
@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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit da47897

Please sign in to comment.