From 11c59ccc87141396a44765a9b3a27bb9d5192639 Mon Sep 17 00:00:00 2001 From: Christoph Weitkamp Date: Sat, 6 Mar 2021 16:49:44 +0100 Subject: [PATCH] Audiosink might be null (#2224) Signed-off-by: Christoph Weitkamp --- .../module/media/internal/PlayActionHandler.java | 6 ++++-- .../module/media/internal/SayActionHandler.java | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/PlayActionHandler.java b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/PlayActionHandler.java index 6b7dcc191..5d9842054 100644 --- a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/PlayActionHandler.java +++ b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/PlayActionHandler.java @@ -44,7 +44,7 @@ public class PlayActionHandler extends BaseActionModuleHandler { private final AudioManager audioManager; private final String sound; - private final String sink; + private final @Nullable String sink; private final @Nullable PercentType volume; public PlayActionHandler(Action module, AudioManager audioManager) { @@ -52,7 +52,9 @@ public class PlayActionHandler extends BaseActionModuleHandler { this.audioManager = audioManager; this.sound = module.getConfiguration().get(PARAM_SOUND).toString(); - this.sink = module.getConfiguration().get(PARAM_SINK).toString(); + + Object sinkParam = module.getConfiguration().get(PARAM_SINK); + this.sink = sinkParam != null ? sinkParam.toString() : null; Object volumeParam = module.getConfiguration().get(PARAM_VOLUME); this.volume = volumeParam instanceof BigDecimal ? new PercentType((BigDecimal) volumeParam) : null; diff --git a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/SayActionHandler.java b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/SayActionHandler.java index ab4047826..7fd7b049d 100644 --- a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/SayActionHandler.java +++ b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/SayActionHandler.java @@ -39,15 +39,17 @@ public class SayActionHandler extends BaseActionModuleHandler { private final VoiceManager voiceManager; private final String text; - private final String sink; + private final @Nullable String sink; private final @Nullable PercentType volume; public SayActionHandler(Action module, VoiceManager voiceManager) { super(module); this.voiceManager = voiceManager; - text = module.getConfiguration().get(PARAM_TEXT).toString(); - sink = module.getConfiguration().get(PARAM_SINK).toString(); + this.text = module.getConfiguration().get(PARAM_TEXT).toString(); + + Object sinkParam = module.getConfiguration().get(PARAM_SINK); + this.sink = sinkParam != null ? sinkParam.toString() : null; Object volumeParam = module.getConfiguration().get(PARAM_VOLUME); this.volume = volumeParam instanceof BigDecimal ? new PercentType((BigDecimal) volumeParam) : null;