From e5148607bfb508ef1483c9461aee456e79c6b194 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Thu, 1 Aug 2024 12:32:11 +0200 Subject: [PATCH] Fix clearing Now Playing channels (#17185) Signed-off-by: Jacob Laursen --- .../http/DenonMarantzHttpConnector.java | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/bundles/org.openhab.binding.denonmarantz/src/main/java/org/openhab/binding/denonmarantz/internal/connector/http/DenonMarantzHttpConnector.java b/bundles/org.openhab.binding.denonmarantz/src/main/java/org/openhab/binding/denonmarantz/internal/connector/http/DenonMarantzHttpConnector.java index 73d643654e9..7d284e5d6af 100644 --- a/bundles/org.openhab.binding.denonmarantz/src/main/java/org/openhab/binding/denonmarantz/internal/connector/http/DenonMarantzHttpConnector.java +++ b/bundles/org.openhab.binding.denonmarantz/src/main/java/org/openhab/binding/denonmarantz/internal/connector/http/DenonMarantzHttpConnector.java @@ -19,6 +19,7 @@ import java.math.BigDecimal; import java.net.URLEncoder; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; +import java.util.Objects; import java.util.concurrent.ExecutionException; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; @@ -340,18 +341,9 @@ public class DenonMarantzHttpConnector extends DenonMarantzConnector { return; } CommandRx titleInfo = response.getCommands().get(0); - String artist = titleInfo.getText("artist"); - if (artist != null) { - state.setNowPlayingArtist(artist); - } - String album = titleInfo.getText("album"); - if (album != null) { - state.setNowPlayingAlbum(album); - } - String track = titleInfo.getText("track"); - if (track != null) { - state.setNowPlayingTrack(track); - } + state.setNowPlayingArtist(Objects.requireNonNullElse(titleInfo.getText("artist"), "")); + state.setNowPlayingAlbum(Objects.requireNonNullElse(titleInfo.getText("album"), "")); + state.setNowPlayingTrack(Objects.requireNonNullElse(titleInfo.getText("track"), "")); } catch (HttpCommunicationException e) { logger.debug("Failed to update display info: {}", e.getMessage()); }