From f57f7d322930b1d93693da166d32e6ed7589f99a Mon Sep 17 00:00:00 2001 From: clinique Date: Thu, 22 Jun 2023 11:44:21 +0200 Subject: [PATCH] Second fwolter code review Signed-off-by: clinique --- bundles/org.openhab.binding.freeboxos/NOTICE | 2 +- .../org.openhab.binding.freeboxos/README.md | 24 ++--- .../freeboxos/internal/api/ApiHandler.java | 2 +- .../internal/api/FreeboxOsIconProvider.java | 2 +- .../internal/api/rest/FreeboxOsSession.java | 4 +- .../internal/api/rest/HomeManager.java | 2 +- .../internal/api/rest/LoginManager.java | 4 +- .../internal/api/rest/PlayerManager.java | 2 +- .../internal/api/rest/RestManager.java | 2 +- .../internal/api/rest/WebSocketManager.java | 8 +- .../discovery/FreeboxOsDiscoveryService.java | 2 +- .../internal/handler/ActivePlayerHandler.java | 2 +- .../internal/handler/ApiConsumerHandler.java | 99 +++++++++---------- .../internal/handler/ApiConsumerIntf.java | 10 +- .../internal/handler/CallHandler.java | 3 +- .../internal/handler/FreeDeviceIntf.java | 4 +- .../internal/handler/FreeboxOsHandler.java | 5 +- .../internal/handler/FreeplugHandler.java | 4 +- .../internal/handler/HomeNodeHandler.java | 2 +- .../internal/handler/HostHandler.java | 4 +- .../internal/handler/PlayerHandler.java | 6 +- .../internal/handler/RepeaterHandler.java | 2 +- .../internal/handler/ServerHandler.java | 2 +- .../freeboxos/internal/handler/VmHandler.java | 2 +- .../src/main/resources/OH-INF/addon/addon.xml | 4 +- .../OH-INF/i18n/freeboxos.properties | 4 +- .../resources/OH-INF/thing/channel-types.xml | 8 +- 27 files changed, 106 insertions(+), 109 deletions(-) diff --git a/bundles/org.openhab.binding.freeboxos/NOTICE b/bundles/org.openhab.binding.freeboxos/NOTICE index d8bca340d2c35..c0b951f2465ab 100644 --- a/bundles/org.openhab.binding.freeboxos/NOTICE +++ b/bundles/org.openhab.binding.freeboxos/NOTICE @@ -14,7 +14,7 @@ https://github.com/openhab/openhab-addons == Third-party Content -IPAddress : Java library for handling IP addresses and subnets, both IPv4 and IPv6 +IPAddress: Java library for handling IP addresses and subnets, both IPv4 and IPv6 * License: Apache License 2.0 * Project: https://github.com/seancfoley/IPAddress * Source: https://github.com/seancfoley/IPAddress \ No newline at end of file diff --git a/bundles/org.openhab.binding.freeboxos/README.md b/bundles/org.openhab.binding.freeboxos/README.md index 1acc45741a86c..b3b4b041d55d1 100644 --- a/bundles/org.openhab.binding.freeboxos/README.md +++ b/bundles/org.openhab.binding.freeboxos/README.md @@ -196,17 +196,17 @@ The following channels are supported: The following actions are available in rules/scripting: -| Thing Type | Action Name | Parameters | Description | -|-------------|------------------|---------------------------|------------------------------------------------------| -| host | wol | None | Sends a wake on lan packet to the lan connected host | -| player | reboot | None | Reboots the player device | -| player | sendKey | key : String | Send a key (remote emulation) to the player | -| player | sendLongKey | key : String | Sends the key emulating a longpress on the button | -| player | sendMultipleKeys | keys : String | Sends multiple keys to the player, comma separated | -| player | sendKeyRepeat | key : String, count : int | Sends the key multiple times | -| server | reboot | None | Reboots the Freebox Server | -| freeplug | reset | None | Resets the Freeplug | -| call | reset | None | Clears the call log queue | -| repeater | reboot | None | Reboots the Repeater | +| Thing Type | Action Name | Parameters | Description | +|-------------|------------------|-------------------------|------------------------------------------------------| +| host | wol | None | Sends a wake on lan packet to the lan connected host | +| player | reboot | None | Reboots the player device | +| player | sendKey | key: String | Send a key (remote emulation) to the player | +| player | sendLongKey | key: String | Sends the key emulating a longpress on the button | +| player | sendMultipleKeys | keys: String | Sends multiple keys to the player, comma separated | +| player | sendKeyRepeat | key: String, count: int | Sends the key multiple times | +| server | reboot | None | Reboots the Freebox Server | +| freeplug | reset | None | Resets the Freeplug | +| call | reset | None | Clears the call log queue | +| repeater | reboot | None | Reboots the Repeater | diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/ApiHandler.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/ApiHandler.java index 39c633df2c3ca..b6b9bdbc8a480 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/ApiHandler.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/ApiHandler.java @@ -90,7 +90,7 @@ public ApiHandler(HttpClient httpClient, TimeZoneProvider timeZoneProvider) { public synchronized T executeUri(URI uri, HttpMethod method, Class clazz, @Nullable String sessionToken, @Nullable Object payload) throws FreeboxException, InterruptedException { - logger.debug("executeUrl {} : {} ", method, uri); + logger.debug("executeUrl {}: {} ", method, uri); Request request = httpClient.newRequest(uri).method(method).timeout(timeoutInMs, TimeUnit.MILLISECONDS) .header(HttpHeader.CONTENT_TYPE, CONTENT_TYPE); diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/FreeboxOsIconProvider.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/FreeboxOsIconProvider.java index ab6cad21c320b..2895adde5b44d 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/FreeboxOsIconProvider.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/FreeboxOsIconProvider.java @@ -85,7 +85,7 @@ protected Integer getPriority() { return new ByteArrayInputStream(response.getContent()); } } catch (InterruptedException | TimeoutException | ExecutionException e) { - logger.warn("Error getting icon {} : {}", resourceName, e.getMessage()); + logger.warn("Error getting icon {}: {}", resourceName, e.getMessage()); } return null; } diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/FreeboxOsSession.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/FreeboxOsSession.java index 464af410dbe59..b2a19c9e5fb61 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/FreeboxOsSession.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/FreeboxOsSession.java @@ -68,7 +68,7 @@ public static record ApiVersion(String apiBaseUrl, @Nullable String apiDomain, S String uid) { /** - * @return a string like eg : '/api/v8' + * @return a string like eg: '/api/v8' */ private String baseUrl() { return "%sv%s".formatted(apiBaseUrl, apiVersion.split("\\.")[0]); @@ -127,7 +127,7 @@ public void closeSession() { getManager(LoginManager.class).closeSession(); session = null; } catch (FreeboxException e) { - logger.info("Error closing session: {}", e.getMessage()); + logger.warn("Error closing session: {}", e.getMessage()); } } appToken = ""; diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/HomeManager.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/HomeManager.java index 6fd9187016bf9..fbb64ecaf6dc2 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/HomeManager.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/HomeManager.java @@ -60,7 +60,7 @@ private static enum DisplayType { UNKNOWN; } - private static record EndpointValue(T value) { + private static record EndpointValue (T value) { } private static record EndpointUi(AccessType access, DisplayType display, String iconUrl, @Nullable String unit) { diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/LoginManager.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/LoginManager.java index 4f69636c00815..0b62fe0a52a66 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/LoginManager.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/LoginManager.java @@ -43,7 +43,7 @@ public class LoginManager extends RestManager { private static final String SESSION = "session"; private static final String AUTHORIZE_ACTION = "authorize"; private static final String LOGOUT = "logout"; - private static final int GRANT_DELAY_MIN = 3; + private static final int GRANT_DELAY_SEC = 180; private final Mac mac; @@ -145,7 +145,7 @@ private Status trackAuthorize(int trackId) throws FreeboxException { public String grant() throws FreeboxException { Authorization authorize = post(new AuthorizeData(APP_ID, BUNDLE), AuthResponse.class, AUTHORIZE_ACTION); Status track = Status.PENDING; - ZonedDateTime timeLimit = ZonedDateTime.now().plusMinutes(GRANT_DELAY_MIN); + ZonedDateTime timeLimit = ZonedDateTime.now().plusSeconds(GRANT_DELAY_SEC); try { while (Status.PENDING.equals(track) && ZonedDateTime.now().isBefore(timeLimit)) { Thread.sleep(2000); diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/PlayerManager.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/PlayerManager.java index 2b050f4b66136..7ef7907ecde7d 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/PlayerManager.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/PlayerManager.java @@ -72,7 +72,7 @@ private static enum StbType { } /** - * @return a string like eg : '17/api/v8' + * @return a string like eg: '17/api/v8' */ private @Nullable String baseUrl() { String api = apiVersion; diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/RestManager.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/RestManager.java index 15a45240d7808..bb1a57c279d17 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/RestManager.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/RestManager.java @@ -45,7 +45,7 @@ public RestManager(FreeboxOsSession session, LoginManager.Permission required, U this.uriBuilder = uri; this.session = session; if (required != LoginManager.Permission.NONE && !session.hasPermission(required)) { - throw new PermissionException(required, "Permission missing : %s", required.toString()); + throw new PermissionException(required, "Permission missing: %s", required.toString()); } } diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/WebSocketManager.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/WebSocketManager.java index 501de57ee0d51..9607c7b6a46f7 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/WebSocketManager.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/WebSocketManager.java @@ -111,7 +111,7 @@ public void onWebSocketConnect(@NonNullByDefault({}) Session wsSession) { try { wsSession.getRemote().sendString(apiHandler.serialize(REGISTRATION)); } catch (IOException e) { - logger.warn("Error connecting to websocket : {}", e.getMessage()); + logger.warn("Error connecting to websocket: {}", e.getMessage()); } } @@ -133,7 +133,7 @@ public void onWebSocketText(@NonNullByDefault({}) String message) { handleNotification(result); break; default: - logger.info("Unhandled notification received : {}", result.action); + logger.warn("Unhandled notification received: {}", result.action); } } } @@ -160,7 +160,7 @@ private void handleNotification(WebSocketResponse result) { } break; default: - logger.warn("Unhandled event received : {}", result.getEvent()); + logger.warn("Unhandled event received: {}", result.getEvent()); } } else { logger.warn("Empty json element in notification"); @@ -175,7 +175,7 @@ public void onWebSocketClose(int statusCode, @NonNullByDefault({}) String reason @Override public void onWebSocketError(@NonNullByDefault({}) Throwable cause) { - logger.warn("Error on websocket : {}", cause.getMessage()); + logger.warn("Error on websocket: {}", cause.getMessage()); } @Override diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/discovery/FreeboxOsDiscoveryService.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/discovery/FreeboxOsDiscoveryService.java index 97dc77fcb41e4..7308f3e13f7a6 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/discovery/FreeboxOsDiscoveryService.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/discovery/FreeboxOsDiscoveryService.java @@ -132,7 +132,7 @@ protected void startScan() { discoverHosts(localHandler, bridgeUID, lanHosts); } } catch (FreeboxException e) { - logger.warn("Error while requesting data for things discovery : {}", e.getMessage()); + logger.warn("Error while requesting data for things discovery: {}", e.getMessage()); } } } diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ActivePlayerHandler.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ActivePlayerHandler.java index 93f0e24b10819..bc7d7812bb606 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ActivePlayerHandler.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ActivePlayerHandler.java @@ -86,7 +86,7 @@ public void reboot() { try { getManager(PlayerManager.class).reboot(getClientId()); } catch (FreeboxException e) { - logger.warn("Error rebooting : {}", e.getMessage()); + logger.warn("Error rebooting: {}", e.getMessage()); } }); } diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ApiConsumerHandler.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ApiConsumerHandler.java index 4cde1e1b95c19..ed4a699a0d1c8 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ApiConsumerHandler.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ApiConsumerHandler.java @@ -14,9 +14,9 @@ import java.math.BigDecimal; import java.time.ZonedDateTime; +import java.util.HashMap; import java.util.Hashtable; import java.util.Map; -import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; @@ -67,8 +67,8 @@ @NonNullByDefault abstract class ApiConsumerHandler extends BaseThingHandler implements ApiConsumerIntf { private final Logger logger = LoggerFactory.getLogger(ApiConsumerHandler.class); + private final Map> jobs = new HashMap<>(); - private @Nullable ScheduledFuture globalJob; private @Nullable ServiceRegistration reg; ApiConsumerHandler(Thing thing) { @@ -77,7 +77,6 @@ abstract class ApiConsumerHandler extends BaseThingHandler implements ApiConsume @Override public void initialize() { - logger.debug("Initializing handler for thing {}", getThing().getUID()); FreeboxOsHandler bridgeHandler = checkBridgeHandler(); if (bridgeHandler == null) { return; @@ -90,7 +89,7 @@ public void initialize() { checkAirMediaCapabilities(properties); updateProperties(properties); } catch (FreeboxException e) { - logger.warn("Error getting thing {} properties : {}", thing.getUID(), e.getMessage()); + logger.warn("Error getting thing {} properties: {}", thing.getUID(), e.getMessage()); } } @@ -118,7 +117,7 @@ private void configureMediaSink(FreeboxOsHandler bridgeHandler, String upnpName) } } } catch (FreeboxException e) { - logger.warn("Unable to retrieve Media Receivers"); + logger.warn("Unable to retrieve Media Receivers: {}", e.getMessage()); } } @@ -134,11 +133,10 @@ public T getManager(Class clazz) throws FreeboxExcept @Override public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { - logger.debug("Thing {}: bridge status changed to {}", getThing().getUID(), bridgeStatusInfo); if (checkBridgeHandler() != null) { startRefreshJob(); } else { - stopRefreshJob(); + stopJobs(); } } @@ -152,7 +150,7 @@ public void handleCommand(ChannelUID channelUID, Command command) { logger.debug("Unexpected command {} on channel {}", command, channelUID.getId()); } } catch (FreeboxException e) { - logger.warn("Error handling command : {}", e.getMessage()); + logger.warn("Error handling command: {}", e.getMessage()); } } @@ -186,8 +184,7 @@ private void checkAirMediaCapabilities(Map properties) throws Fr @Override public void dispose() { - logger.debug("Disposing handler for thing {}", getThing().getUID()); - stopRefreshJob(); + stopJobs(); ServiceRegistration localReg = reg; if (localReg != null) { localReg.unregister(); @@ -196,47 +193,54 @@ public void dispose() { } private void startRefreshJob() { - ScheduledFuture job = globalJob; - if (job == null || job.isCancelled()) { - int refreshInterval = getConfigAs(ApiConsumerConfiguration.class).refreshInterval; - logger.debug("Scheduling state update every {} seconds for thing {}...", refreshInterval, - getThing().getUID()); - ThingStatusDetail detail = thing.getStatusInfo().getStatusDetail(); - if (ThingStatusDetail.DUTY_CYCLE.equals(detail)) { - boolean rebooting = true; - while (rebooting) { - try { - internalPoll(); - rebooting = false; - } catch (FreeboxException ignore) { - try { - Thread.sleep(20000); - } catch (InterruptedException e) { - rebooting = false; - } - } - } + removeJob("GlobalJob"); + + int refreshInterval = getConfigAs(ApiConsumerConfiguration.class).refreshInterval; + logger.debug("Scheduling state update every {} seconds for thing {}...", refreshInterval, getThing().getUID()); + + ThingStatusDetail detail = thing.getStatusInfo().getStatusDetail(); + if (ThingStatusDetail.DUTY_CYCLE.equals(detail)) { + try { + internalPoll(); + } catch (FreeboxException ignore) { + // An exception is normal if the box is rebooting then let's try again later... + addJob("Initialize", this::initialize, 10, TimeUnit.SECONDS); + return; } + } - globalJob = scheduler.scheduleWithFixedDelay(() -> { - try { - internalPoll(); - } catch (FreeboxException e) { - logger.warn("Error polling thing {} : {}", getThing().getUID(), e.getMessage()); - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage()); - } - }, 0, refreshInterval, TimeUnit.SECONDS); + addJob("GlobalJob", () -> { + try { + internalPoll(); + } catch (FreeboxException e) { + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage()); + } + }, 0, refreshInterval, TimeUnit.SECONDS); + } + + private void removeJob(String name) { + ScheduledFuture existing = jobs.get(name); + if (existing != null && !existing.isCancelled()) { + existing.cancel(true); } } @Override - public void stopRefreshJob() { - ScheduledFuture job = globalJob; - if (job != null && !job.isCancelled()) { - logger.debug("Stop scheduled state update for thing {}", getThing().getUID()); - job.cancel(true); - globalJob = null; - } + public void addJob(String name, Runnable command, long initialDelay, long delay, TimeUnit unit) { + removeJob(name); + jobs.put(name, scheduler.scheduleWithFixedDelay(command, initialDelay, delay, unit)); + } + + @Override + public void addJob(String name, Runnable command, long delay, TimeUnit unit) { + removeJob(name); + jobs.put(name, scheduler.schedule(command, delay, unit)); + } + + @Override + public void stopJobs() { + jobs.keySet().forEach(name -> removeJob(name)); + jobs.clear(); } protected boolean internalHandleCommand(String channelId, Command command) throws FreeboxException { @@ -330,11 +334,6 @@ public void updateProperties(@Nullable Map properties) { super.updateProperties(properties); } - @Override - public ScheduledExecutorService getScheduler() { - return scheduler; - } - @Override public Configuration getConfig() { return super.getConfig(); diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ApiConsumerIntf.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ApiConsumerIntf.java index 76d3521f19498..d1c43caa4eea8 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ApiConsumerIntf.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ApiConsumerIntf.java @@ -14,7 +14,7 @@ import java.math.BigDecimal; import java.util.Map; -import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -37,8 +37,6 @@ @NonNullByDefault public interface ApiConsumerIntf extends ThingHandler { - ScheduledExecutorService getScheduler(); - Map editProperties(); Configuration getConfig(); @@ -47,7 +45,11 @@ public interface ApiConsumerIntf extends ThingHandler { void updateStatus(ThingStatus status, ThingStatusDetail statusDetail, @Nullable String description); - void stopRefreshJob(); + void stopJobs(); + + void addJob(String name, Runnable command, long initialDelay, long delay, TimeUnit unit); + + void addJob(String name, Runnable command, long delay, TimeUnit unit); default int getClientId() { return ((BigDecimal) getConfig().get(ClientConfiguration.ID)).intValue(); diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/CallHandler.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/CallHandler.java index fc33f7c114063..780f9fab79e8d 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/CallHandler.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/CallHandler.java @@ -96,9 +96,8 @@ private void updateCallChannels(Call call) { public void emptyQueue() { try { getManager(CallManager.class).emptyQueue(); - logger.info("Call log succesfully cleared"); } catch (FreeboxException e) { - logger.warn("Error clearing call logs : {}", e.getMessage()); + logger.warn("Error clearing call logs: {}", e.getMessage()); } } diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/FreeDeviceIntf.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/FreeDeviceIntf.java index 3a5d53f4508ea..20dc1345f2b5e 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/FreeDeviceIntf.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/FreeDeviceIntf.java @@ -50,7 +50,7 @@ default void processReboot(Runnable actualReboot) { triggerChannel(getEventChannelUID(), "reboot_requested"); actualReboot.run(); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.DUTY_CYCLE, "System rebooting..."); - stopRefreshJob(); - getScheduler().schedule(this::initialize, 30, TimeUnit.SECONDS); + stopJobs(); + addJob("Initialize", this::initialize, 30, TimeUnit.SECONDS); } } diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/FreeboxOsHandler.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/FreeboxOsHandler.java index 5cdc1fff50596..76a16268c5ebe 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/FreeboxOsHandler.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/FreeboxOsHandler.java @@ -62,7 +62,6 @@ public FreeboxOsHandler(Bridge thing, FreeboxOsSession session, String callbackU @Override public void initialize() { - logger.debug("Initializing Freebox OS API handler for thing {}.", getThing().getUID()); freeConnectionJob(); openConnectionJob = Optional.of(scheduler.submit(() -> { @@ -83,7 +82,7 @@ public void initialize() { thingConfig.put(FreeboxOsConfiguration.APP_TOKEN, currentAppToken); updateConfiguration(thingConfig); logger.info( - "App token updated in Configuration, please give needed permissions to openHAB app in your Freebox management console"); + "App token updated in Configuration, please ensure expected permissions are given openHAB in your Freebox management console"); } updateStatus(ThingStatus.ONLINE); @@ -106,8 +105,6 @@ private void freeConnectionJob() { @Override public void dispose() { - logger.debug("Disposing Freebox OS API handler for thing {}", getThing().getUID()); - freeConnectionJob(); session.closeSession(); diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/FreeplugHandler.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/FreeplugHandler.java index d2eeb975633fb..9849ae5f42f75 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/FreeplugHandler.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/FreeplugHandler.java @@ -89,9 +89,9 @@ private void updateRateChannel(String channel, int rate) { public void reset() { try { getManager(FreeplugManager.class).reboot(getMac()); - logger.info("Freeplug {} succesfully restarted", getMac()); + logger.debug("Freeplug {} succesfully restarted", getMac()); } catch (FreeboxException e) { - logger.warn("Error restarting freeplug : {}", e.getMessage()); + logger.warn("Error restarting freeplug: {}", e.getMessage()); } } diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/HomeNodeHandler.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/HomeNodeHandler.java index ace1e7c81ac08..33c8f12360e1d 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/HomeNodeHandler.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/HomeNodeHandler.java @@ -88,7 +88,7 @@ protected void internalPoll() throws FreeboxException { result = getChannelState(homeManager, channel.getUID().getIdWithoutGroup()); } } catch (FreeboxException e) { - logger.info("Error updating channel : {}", e.getMessage()); + logger.warn("Error updating channel: {}", e.getMessage()); } } else { result = getChannelState(homeManager, channel.getUID().getIdWithoutGroup()); diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/HostHandler.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/HostHandler.java index 6fcf60bc5a960..d7966549eca5c 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/HostHandler.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/HostHandler.java @@ -63,7 +63,7 @@ public void dispose() { try { getManager(WebSocketManager.class).unregisterListener(getMac()); } catch (FreeboxException e) { - logger.warn("Error unregistering host from the websocket : {}", e.getMessage()); + logger.warn("Error unregistering host from the websocket: {}", e.getMessage()); } super.dispose(); } @@ -94,7 +94,7 @@ public void wol() { getManager(LanBrowserManager.class).wakeOnLan(getMac(), getConfigAs(ApiConsumerConfiguration.class).password); } catch (FreeboxException e) { - logger.warn("Error waking up host : {}", e.getMessage()); + logger.warn("Error waking up host: {}", e.getMessage()); } } diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/PlayerHandler.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/PlayerHandler.java index b90eff31928dd..c4eb959473568 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/PlayerHandler.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/PlayerHandler.java @@ -83,20 +83,20 @@ public void sendKey(String key, boolean longPress, int count) { String aKey = key.toLowerCase(); IPAddress ip = ipAddress; if (ip == null) { - logger.info("Player IP is unknown"); + logger.warn("Player IP is unknown"); } else if (VALID_REMOTE_KEYS.contains(aKey)) { String remoteCode = (String) getConfig().get(PlayerConfiguration.REMOTE_CODE); if (remoteCode != null) { try { getManager(PlayerManager.class).sendKey(ip.toCanonicalString(), remoteCode, aKey, longPress, count); } catch (FreeboxException e) { - logger.info("Error sending key : {}", e.getMessage()); + logger.warn("Error sending key: {}", e.getMessage()); } } else { logger.warn("A remote code must be configured in the on the player thing."); } } else { - logger.info("Key '{}' is not a valid key expression", key); + logger.warn("Key '{}' is not a valid key expression", key); } } diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/RepeaterHandler.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/RepeaterHandler.java index d166cf58599d5..6b345a88cb058 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/RepeaterHandler.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/RepeaterHandler.java @@ -97,7 +97,7 @@ public void reboot() { try { getManager(RepeaterManager.class).reboot(getClientId()); } catch (FreeboxException e) { - logger.warn("Error rebooting : {}", e.getMessage()); + logger.warn("Error rebooting: {}", e.getMessage()); } }); } diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ServerHandler.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ServerHandler.java index 017ff35ed5be2..f6d607efe2868 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ServerHandler.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ServerHandler.java @@ -193,7 +193,7 @@ public void reboot() { try { getManager(SystemManager.class).reboot(); } catch (FreeboxException e) { - logger.warn("Error rebooting : {}", e.getMessage()); + logger.warn("Error rebooting: {}", e.getMessage()); } }); } diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/VmHandler.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/VmHandler.java index 28b301b808176..2f1ab7b06cf62 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/VmHandler.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/VmHandler.java @@ -49,7 +49,7 @@ public void dispose() { try { getManager(WebSocketManager.class).unregisterVm(getClientId()); } catch (FreeboxException e) { - logger.warn("Error unregistering VM from the websocket : {}", e.getMessage()); + logger.warn("Error unregistering VM from the websocket: {}", e.getMessage()); } super.dispose(); } diff --git a/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/addon/addon.xml b/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/addon/addon.xml index c1dbb63042660..9c9b553c8fe47 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/addon/addon.xml +++ b/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/addon/addon.xml @@ -10,14 +10,14 @@ fr,it - + The timeout for reading from the API in seconds. 8 - URL to use for playing notification sounds hosted by openHab, e.g. 'http://192.168.0.2:8080' + URL to use for playing notification sounds hosted by openHAB, e.g. 'http://192.168.0.2:8080' diff --git a/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/i18n/freeboxos.properties b/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/i18n/freeboxos.properties index 42b2c0ab9fae9..86b59db4e61d8 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/i18n/freeboxos.properties +++ b/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/i18n/freeboxos.properties @@ -6,7 +6,7 @@ addon.freeboxos.description = The Freebox OS binding integrates Free equipments # add-on config addon.config.freeboxos.callbackUrl.label = Callback URL -addon.config.freeboxos.callbackUrl.description = URL to use for playing notification sounds hosted by openHab, e.g. 'http://192.168.0.2:8080' +addon.config.freeboxos.callbackUrl.description = URL to use for playing notification sounds hosted by openHAB, e.g. 'http://192.168.0.2:8080' addon.config.freeboxos.timeout.label = Timeout addon.config.freeboxos.timeout.description = The timeout for reading from the API in seconds. @@ -221,7 +221,7 @@ channel-type.freeboxos.fanspeed.description = Actual measured rotation speed of channel-type.freeboxos.ftp-status.label = FTP Server Enabled channel-type.freeboxos.ftp-status.description = Indicates whether the FTP server is enabled channel-type.freeboxos.gain.label = Gain -channel-type.freeboxos.hardware-status.label = Hardware status +channel-type.freeboxos.hardware-status.label = Hardware Status channel-type.freeboxos.hardware-status.description = Hardware status of the phone line channel-type.freeboxos.host-count.label = Host Count channel-type.freeboxos.host-count.description = Number of hosts connected to the device diff --git a/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/channel-types.xml b/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/channel-types.xml index 5c12b39865c9a..b785f830e0ce5 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/channel-types.xml +++ b/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/channel-types.xml @@ -386,7 +386,7 @@ String - + Hardware status of the phone line @@ -444,21 +444,21 @@ Number:Time - zone_temporisee + oh:freeboxos:zone_temporisee Number:Dimensionless - sirene + oh:freeboxos:sirene String - pin_code + oh:freeboxos:pin_code