From 8f97dc908c4fa77554f797147ef4b5c8ced499d4 Mon Sep 17 00:00:00 2001 From: Laurent Garnier Date: Tue, 13 Aug 2024 14:11:02 +0200 Subject: [PATCH 1/2] [freeboxos] Fix media playing Fix #17243 Signed-off-by: Laurent Garnier --- .../freeboxos/internal/api/rest/MediaReceiverManager.java | 7 +++++-- .../binding/freeboxos/internal/api/rest/RestManager.java | 7 ++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/MediaReceiverManager.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/MediaReceiverManager.java index 7b671baaf7ac7..5141e46743387 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/MediaReceiverManager.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/api/rest/MediaReceiverManager.java @@ -54,8 +54,11 @@ public enum MediaType { UNKNOWN } - private static record Request(String password, Action action, MediaType mediaType, @Nullable String media, + private static record Request(String password, String action, String mediaType, @Nullable String media, int position) { + Request(String password, Action action, MediaType mediaType, @Nullable String media, int position) { + this(password, action.name().toLowerCase(), mediaType.name().toLowerCase(), media, position); + } } public MediaReceiverManager(FreeboxOsSession session, UriBuilder uriBuilder) throws FreeboxException { @@ -77,6 +80,6 @@ public void sendToReceiver(String receiver, String password, Action action, Medi } private void sendToReceiver(String receiver, Request payload) throws FreeboxException { - post(payload, GenericResponse.class, receiver); + post(payload, receiver); } } 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 bea01fcef93c4..20bfe4a42b282 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 @@ -20,6 +20,7 @@ import javax.ws.rs.core.UriBuilder; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.freeboxos.internal.api.FreeboxException; import org.openhab.binding.freeboxos.internal.api.PermissionException; import org.openhab.binding.freeboxos.internal.api.Response; @@ -83,7 +84,11 @@ protected > F post(Object payload, Class clazz, Stri } protected void post(String... pathElements) throws FreeboxException { - session.execute(buildUri(pathElements), POST, GenericResponse.class, null); + post(null, pathElements); + } + + protected void post(@Nullable F payload, String... pathElements) throws FreeboxException { + session.execute(buildUri(pathElements), POST, GenericResponse.class, payload); } protected > F put(Class clazz, F payload, String... pathElements) From bc95e323095fdb401a87c8df1117f895dc15babd Mon Sep 17 00:00:00 2001 From: Laurent Garnier Date: Tue, 13 Aug 2024 19:03:15 +0200 Subject: [PATCH 2/2] Minor code change Signed-off-by: Laurent Garnier --- .../binding/freeboxos/internal/handler/ApiConsumerHandler.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 0e7d1ef52684d..9fa6a32dd1190 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 @@ -118,8 +118,7 @@ protected void configureMediaSink() { private void startAudioSink(Receiver receiver) { FreeboxOsHandler bridgeHandler = checkBridgeHandler(); // Only video and photo is supported by the API so use VIDEO capability for audio - Boolean isAudioReceiver = receiver.capabilities().get(MediaType.VIDEO); - if (reg == null && bridgeHandler != null && isAudioReceiver != null && isAudioReceiver.booleanValue()) { + if (reg == null && bridgeHandler != null && Boolean.TRUE.equals(receiver.capabilities().get(MediaType.VIDEO))) { ApiConsumerConfiguration config = getConfig().as(ApiConsumerConfiguration.class); String callbackURL = bridgeHandler.getCallbackURL(); if (!config.password.isEmpty() || !receiver.passwordProtected()) {