From 8a5b3d02b22638536024f98e49ba1acba19e1e8e Mon Sep 17 00:00:00 2001 From: lolodomo Date: Wed, 1 Apr 2020 00:19:12 +0200 Subject: [PATCH] [lgwebos] Handle volume update whatever the audio output (#7259) Fix #7207 Signed-off-by: Laurent Garnier --- .../lgwebos/internal/BaseChannelHandler.java | 2 +- .../internal/handler/LGWebOSTVSocket.java | 22 ++++--------------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/bundles/org.openhab.binding.lgwebos/src/main/java/org/openhab/binding/lgwebos/internal/BaseChannelHandler.java b/bundles/org.openhab.binding.lgwebos/src/main/java/org/openhab/binding/lgwebos/internal/BaseChannelHandler.java index 7cb54b7290497..8e71fd56934a4 100644 --- a/bundles/org.openhab.binding.lgwebos/src/main/java/org/openhab/binding/lgwebos/internal/BaseChannelHandler.java +++ b/bundles/org.openhab.binding.lgwebos/src/main/java/org/openhab/binding/lgwebos/internal/BaseChannelHandler.java @@ -40,7 +40,7 @@ protected ResponseListener createResponseListener() { @Override public void onError(String error) { - logger.warn("{} received error response: {}", BaseChannelHandler.this.getClass().getSimpleName(), + logger.debug("{} received error response: {}", BaseChannelHandler.this.getClass().getSimpleName(), error); } diff --git a/bundles/org.openhab.binding.lgwebos/src/main/java/org/openhab/binding/lgwebos/internal/handler/LGWebOSTVSocket.java b/bundles/org.openhab.binding.lgwebos/src/main/java/org/openhab/binding/lgwebos/internal/handler/LGWebOSTVSocket.java index 050b816428be0..bbe992902cb87 100644 --- a/bundles/org.openhab.binding.lgwebos/src/main/java/org/openhab/binding/lgwebos/internal/handler/LGWebOSTVSocket.java +++ b/bundles/org.openhab.binding.lgwebos/src/main/java/org/openhab/binding/lgwebos/internal/handler/LGWebOSTVSocket.java @@ -448,15 +448,8 @@ public ServiceCommand getMute(ResponseListener listener) { public ServiceSubscription subscribeVolume(ResponseListener listener) { ServiceSubscription request = new ServiceSubscription<>(VOLUME, null, - // "scenario" in the response determines whether "volume" is absolute or a delta value. - // it only makes sense to subscribe to changes in absolute volume - // accept: "mastervolume_tv_speaker" or "mastervolume_tv_speaker_ext" or - // "mastervolume_ext_speaker_lg_optical" - // ignore external amp/receiver: "mastervolume_ext_speaker_arc" or "mastervolume_ext_speaker_urcu_oss" - jsonObj -> jsonObj.get("scenario").getAsString().startsWith("mastervolume_tv_speaker") - || "mastervolume_ext_speaker_lg_optical".equals(jsonObj.get("scenario").getAsString()) - ? (float) (jsonObj.get("volume").getAsInt() / 100.0) - : Float.NaN, + jsonObj -> jsonObj.get("volume").getAsInt() >= 0 ? (float) (jsonObj.get("volume").getAsInt() / 100.0) + : Float.NaN, listener); sendCommand(request); return request; @@ -464,15 +457,8 @@ public ServiceSubscription subscribeVolume(ResponseListener listen public ServiceCommand getVolume(ResponseListener listener) { ServiceCommand request = new ServiceCommand<>(VOLUME, null, - // "scenario" in the response determines whether "volume" is absolute or a delta value. - // it only makes sense to subscribe to changes in absolute volume - // accept: "mastervolume_tv_speaker" or "mastervolume_tv_speaker_ext" or - // "mastervolume_ext_speaker_lg_optical" - // ignore external amp/receiver: "mastervolume_ext_speaker_arc" or "mastervolume_ext_speaker_urcu_oss" - jsonObj -> jsonObj.get("scenario").getAsString().startsWith("mastervolume_tv_speaker") - || "mastervolume_ext_speaker_lg_optical".equals(jsonObj.get("scenario").getAsString()) - ? (float) (jsonObj.get("volume").getAsInt() / 100.0) - : Float.NaN, + jsonObj -> jsonObj.get("volume").getAsInt() >= 0 ? (float) (jsonObj.get("volume").getAsInt() / 100.0) + : Float.NaN, listener); sendCommand(request); return request;