From 62115cf7d71119c1ef3d84108d5227d16d0949a0 Mon Sep 17 00:00:00 2001 From: Christoph Weitkamp Date: Sat, 28 Nov 2020 15:44:45 +0100 Subject: [PATCH 1/4] Added Actions for Play and Say which sets the volume Signed-off-by: Christoph Weitkamp --- .../internal/MediaActionTypeProvider.java | 85 +++++++++++++------ .../internal/MediaModuleHandlerFactory.java | 40 ++++----- .../media/internal/PlayActionHandler.java | 23 ++++- .../media/internal/SayActionHandler.java | 23 ++++- 4 files changed, 115 insertions(+), 56 deletions(-) diff --git a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java index b165d791947..64b9317f89e 100644 --- a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java +++ b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java @@ -16,13 +16,12 @@ import static java.util.stream.Collectors.toList; import java.io.File; +import java.math.BigDecimal; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Locale; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -42,14 +41,14 @@ import org.osgi.service.component.annotations.Reference; /** - * This class dynamically provides the Play action type. + * This class dynamically provides the Play and Say action types. * This is necessary since there is no other way to provide dynamic config param options for module types. * * @author Kai Kreuzer - Initial contribution * @author Simon Kaufmann - added "say" action */ @NonNullByDefault -@Component(immediate = true) +@Component(service = ModuleTypeProvider.class) public class MediaActionTypeProvider implements ModuleTypeProvider { private final AudioManager audioManager; @@ -62,43 +61,69 @@ public MediaActionTypeProvider(final @Reference AudioManager audioManager) { @SuppressWarnings("unchecked") @Override public @Nullable ModuleType getModuleType(String UID, @Nullable Locale locale) { - if (PlayActionHandler.TYPE_ID.equals(UID)) { - return getPlayActionType(locale); - } else if (SayActionHandler.TYPE_ID.equals(UID)) { - return getSayActionType(locale); - } else { - return null; + switch (UID) { + case PlayActionHandler.TYPE_ID: + return getPlayActionType(locale); + case PlayActionHandler.VOLUME_TYPE_ID: + return getPlayWithVolumeActionType(locale); + case SayActionHandler.TYPE_ID: + return getSayActionType(locale); + case SayActionHandler.VOLUME_TYPE_ID: + return getSayWithVolumeActionType(locale); + default: + return null; } } @Override public Collection getModuleTypes(@Nullable Locale locale) { - return Stream.of(getPlayActionType(locale), getSayActionType(locale)).collect(Collectors.toList()); + return List.of(getPlayActionType(locale), getPlayWithVolumeActionType(locale), getSayActionType(locale), + getSayWithVolumeActionType(locale)); } private ModuleType getPlayActionType(@Nullable Locale locale) { - return new ActionType(PlayActionHandler.TYPE_ID, getConfigPlayDesc(locale), "play a sound", - "Plays a sound file.", null, Visibility.VISIBLE, new ArrayList<>(), new ArrayList<>()); + return new ActionType(PlayActionHandler.TYPE_ID, getConfigPlayDesc(locale, false), "play a sound", + "Plays a sound file.", null, Visibility.VISIBLE, null, null); + } + + private ModuleType getPlayWithVolumeActionType(@Nullable Locale locale) { + return new ActionType(PlayActionHandler.VOLUME_TYPE_ID, getConfigPlayDesc(locale, true), + "play a sound and set the volume", "Plays a sound file and sets the volume.", null, Visibility.VISIBLE, + null, null); } private ModuleType getSayActionType(@Nullable Locale locale) { - return new ActionType(SayActionHandler.TYPE_ID, getConfigSayDesc(locale), "say something", - "Speaks a given text through a natural voice.", null, Visibility.VISIBLE, new ArrayList<>(), - new ArrayList<>()); + return new ActionType(SayActionHandler.TYPE_ID, getConfigSayDesc(locale, false), "say something", + "Speaks a given text through a natural voice.", null, Visibility.VISIBLE, null, null); + } + + private ModuleType getSayWithVolumeActionType(@Nullable Locale locale) { + return new ActionType(SayActionHandler.VOLUME_TYPE_ID, getConfigSayDesc(locale, true), + "say something and set the volume", "Speaks a given text through a natural voice and sets the volume.", + null, Visibility.VISIBLE, null, null); } - private List getConfigPlayDesc(@Nullable Locale locale) { - ConfigDescriptionParameter param1 = ConfigDescriptionParameterBuilder - .create(PlayActionHandler.PARAM_SOUND, Type.TEXT).withRequired(true).withLabel("Sound") - .withDescription("the sound to play").withOptions(getSoundOptions()).withLimitToOptions(true).build(); - return List.of(param1, getAudioSinkConfigDescParam(locale)); + private List getConfigPlayDesc(@Nullable Locale locale, boolean withVolume) { + List params = new ArrayList<>(); + params.add(ConfigDescriptionParameterBuilder.create(PlayActionHandler.PARAM_SOUND, Type.TEXT).withRequired(true) + .withLabel("Sound").withDescription("the sound to play").withOptions(getSoundOptions()) + .withLimitToOptions(true).build()); + params.add(getAudioSinkConfigDescParam(locale)); + if (withVolume) { + params.add(getVolumeConfigDescParam(locale)); + } + return params; } - private List getConfigSayDesc(@Nullable Locale locale) { - ConfigDescriptionParameter param1 = ConfigDescriptionParameterBuilder - .create(SayActionHandler.PARAM_TEXT, Type.TEXT).withRequired(true).withLabel("Text") - .withDescription("the text to speak").build(); - return List.of(param1, getAudioSinkConfigDescParam(locale)); + private List getConfigSayDesc(@Nullable Locale locale, boolean withVolume) { + List params = new ArrayList<>(); + params.add(ConfigDescriptionParameterBuilder.create(SayActionHandler.PARAM_TEXT, Type.TEXT).withRequired(true) + .withLabel("Text").withDescription("the text to speak").build()); + params.add(getAudioSinkConfigDescParam(locale)); + if (withVolume) { + params.add(getVolumeConfigDescParam(locale)); + } + return params; } private ConfigDescriptionParameter getAudioSinkConfigDescParam(@Nullable Locale locale) { @@ -109,6 +134,14 @@ private ConfigDescriptionParameter getAudioSinkConfigDescParam(@Nullable Locale return param2; } + private ConfigDescriptionParameter getVolumeConfigDescParam(@Nullable Locale locale) { + ConfigDescriptionParameter param3 = ConfigDescriptionParameterBuilder + .create(SayActionHandler.PARAM_VOLUME, Type.INTEGER).withLabel("Volume") + .withDescription("the volume to use").withMinimum(BigDecimal.ZERO).withMaximum(BigDecimal.valueOf(100)) + .withStepSize(BigDecimal.ONE).build(); + return param3; + } + /** * This method creates one option for every file that is found in the sounds directory. * As a label, the file extension is removed and the string is capitalized. diff --git a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaModuleHandlerFactory.java b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaModuleHandlerFactory.java index eb863c09c8f..61f527b7386 100644 --- a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaModuleHandlerFactory.java +++ b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaModuleHandlerFactory.java @@ -15,6 +15,8 @@ import java.util.Collection; import java.util.List; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.audio.AudioManager; import org.openhab.core.automation.Action; import org.openhab.core.automation.Module; @@ -22,6 +24,7 @@ import org.openhab.core.automation.handler.ModuleHandler; import org.openhab.core.automation.handler.ModuleHandlerFactory; import org.openhab.core.voice.VoiceManager; +import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Deactivate; import org.osgi.service.component.annotations.Reference; @@ -30,12 +33,21 @@ * * @author Kai Kreuzer - Initial contribution */ +@NonNullByDefault @Component(service = ModuleHandlerFactory.class) public class MediaModuleHandlerFactory extends BaseModuleHandlerFactory { - private static final Collection TYPES = List.of(SayActionHandler.TYPE_ID, PlayActionHandler.TYPE_ID); - private VoiceManager voiceManager; - private AudioManager audioManager; + private static final Collection TYPES = List.of(SayActionHandler.TYPE_ID, SayActionHandler.VOLUME_TYPE_ID, + PlayActionHandler.TYPE_ID, PlayActionHandler.VOLUME_TYPE_ID); + private final VoiceManager voiceManager; + private final AudioManager audioManager; + + @Activate + public MediaModuleHandlerFactory(final @Reference AudioManager audioManager, + final @Reference VoiceManager voiceManager) { + this.audioManager = audioManager; + this.voiceManager = voiceManager; + } @Override @Deactivate @@ -49,12 +61,14 @@ public Collection getTypes() { } @Override - protected ModuleHandler internalCreate(Module module, String ruleUID) { + protected @Nullable ModuleHandler internalCreate(Module module, String ruleUID) { if (module instanceof Action) { switch (module.getTypeUID()) { case SayActionHandler.TYPE_ID: + case SayActionHandler.VOLUME_TYPE_ID: return new SayActionHandler((Action) module, voiceManager); case PlayActionHandler.TYPE_ID: + case PlayActionHandler.VOLUME_TYPE_ID: return new PlayActionHandler((Action) module, audioManager); default: break; @@ -62,22 +76,4 @@ protected ModuleHandler internalCreate(Module module, String ruleUID) { } return null; } - - @Reference - protected void setAudioManager(AudioManager audioManager) { - this.audioManager = audioManager; - } - - protected void unsetAudioManager(AudioManager audioManager) { - this.audioManager = null; - } - - @Reference - protected void setVoiceManager(VoiceManager voiceManager) { - this.voiceManager = voiceManager; - } - - protected void unsetVoiceManager(VoiceManager voiceManager) { - this.voiceManager = null; - } } 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 9147053740a..7111472fa99 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 @@ -12,12 +12,16 @@ */ package org.openhab.core.automation.module.media.internal; +import java.math.BigDecimal; import java.util.Map; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.audio.AudioException; import org.openhab.core.audio.AudioManager; import org.openhab.core.automation.Action; import org.openhab.core.automation.handler.BaseActionModuleHandler; +import org.openhab.core.library.types.PercentType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -26,27 +30,38 @@ * * @author Kai Kreuzer - Initial contribution */ +@NonNullByDefault public class PlayActionHandler extends BaseActionModuleHandler { public static final String TYPE_ID = "media.PlayAction"; + public static final String VOLUME_TYPE_ID = "media.PlayActionWithVolume"; public static final String PARAM_SOUND = "sound"; public static final String PARAM_SINK = "sink"; + public static final String PARAM_VOLUME = "volume"; private final Logger logger = LoggerFactory.getLogger(PlayActionHandler.class); private final AudioManager audioManager; + private final String sound; + private final String sink; + private final @Nullable PercentType volume; + public PlayActionHandler(Action module, AudioManager audioManager) { super(module); this.audioManager = audioManager; + + this.sound = module.getConfiguration().get(PARAM_SOUND).toString(); + this.sink = module.getConfiguration().get(PARAM_SINK).toString(); + + Object volumeParam = module.getConfiguration().get(PARAM_VOLUME); + this.volume = volumeParam instanceof BigDecimal ? new PercentType((BigDecimal) volumeParam) : null; } @Override - public Map execute(Map context) { - String sound = module.getConfiguration().get(PARAM_SOUND).toString(); - String sink = (String) module.getConfiguration().get(PARAM_SINK); + public @Nullable Map execute(Map context) { try { - audioManager.playFile(sound, sink); + audioManager.playFile(sound, sink, volume); } catch (AudioException e) { logger.error("Error playing sound '{}': {}", sound, e.getMessage()); } 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 2c1f92bb591..a6dbe00a138 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 @@ -12,10 +12,14 @@ */ package org.openhab.core.automation.module.media.internal; +import java.math.BigDecimal; import java.util.Map; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.automation.Action; import org.openhab.core.automation.handler.BaseActionModuleHandler; +import org.openhab.core.library.types.PercentType; import org.openhab.core.voice.VoiceManager; /** @@ -23,24 +27,35 @@ * * @author Kai Kreuzer - Initial contribution */ +@NonNullByDefault public class SayActionHandler extends BaseActionModuleHandler { public static final String TYPE_ID = "media.SayAction"; + public static final String VOLUME_TYPE_ID = "media.SayActionWithVolume"; public static final String PARAM_TEXT = "text"; public static final String PARAM_SINK = "sink"; + public static final String PARAM_VOLUME = "volume"; private final VoiceManager voiceManager; + private final String text; + private final 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(); + + Object volumeParam = module.getConfiguration().get(PARAM_VOLUME); + this.volume = volumeParam instanceof BigDecimal ? new PercentType((BigDecimal) volumeParam) : null; } @Override - public Map execute(Map context) { - String text = module.getConfiguration().get(PARAM_TEXT).toString(); - String sink = (String) module.getConfiguration().get(PARAM_SINK); - voiceManager.say(text, null, sink); + public @Nullable Map execute(Map context) { + voiceManager.say(text, null, sink, volume); return null; } } From 5ca86ae00aeeb343939f07a508633eaaf7b846e9 Mon Sep 17 00:00:00 2001 From: Christoph Weitkamp Date: Sun, 29 Nov 2020 13:49:07 +0100 Subject: [PATCH 2/4] Refactoring based on review comments Signed-off-by: Christoph Weitkamp --- .../internal/MediaActionTypeProvider.java | 59 ++++++------------- .../internal/MediaModuleHandlerFactory.java | 6 +- .../media/internal/PlayActionHandler.java | 2 +- .../media/internal/SayActionHandler.java | 2 +- 4 files changed, 22 insertions(+), 47 deletions(-) diff --git a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java index 64b9317f89e..188f41e2a63 100644 --- a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java +++ b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java @@ -46,6 +46,7 @@ * * @author Kai Kreuzer - Initial contribution * @author Simon Kaufmann - added "say" action + * @author Christoph Weitkamp - Added parameter volume */ @NonNullByDefault @Component(service = ModuleTypeProvider.class) @@ -64,12 +65,8 @@ public MediaActionTypeProvider(final @Reference AudioManager audioManager) { switch (UID) { case PlayActionHandler.TYPE_ID: return getPlayActionType(locale); - case PlayActionHandler.VOLUME_TYPE_ID: - return getPlayWithVolumeActionType(locale); case SayActionHandler.TYPE_ID: return getSayActionType(locale); - case SayActionHandler.VOLUME_TYPE_ID: - return getSayWithVolumeActionType(locale); default: return null; } @@ -77,53 +74,33 @@ public MediaActionTypeProvider(final @Reference AudioManager audioManager) { @Override public Collection getModuleTypes(@Nullable Locale locale) { - return List.of(getPlayActionType(locale), getPlayWithVolumeActionType(locale), getSayActionType(locale), - getSayWithVolumeActionType(locale)); + return List.of(getPlayActionType(locale), getSayActionType(locale)); } private ModuleType getPlayActionType(@Nullable Locale locale) { - return new ActionType(PlayActionHandler.TYPE_ID, getConfigPlayDesc(locale, false), "play a sound", - "Plays a sound file.", null, Visibility.VISIBLE, null, null); - } - - private ModuleType getPlayWithVolumeActionType(@Nullable Locale locale) { - return new ActionType(PlayActionHandler.VOLUME_TYPE_ID, getConfigPlayDesc(locale, true), - "play a sound and set the volume", "Plays a sound file and sets the volume.", null, Visibility.VISIBLE, - null, null); + return new ActionType(PlayActionHandler.TYPE_ID, getConfigPlayDesc(locale), "play a sound", + "Plays a sound file. Optionally set the volume.", null, Visibility.VISIBLE, null, null); } private ModuleType getSayActionType(@Nullable Locale locale) { - return new ActionType(SayActionHandler.TYPE_ID, getConfigSayDesc(locale, false), "say something", - "Speaks a given text through a natural voice.", null, Visibility.VISIBLE, null, null); - } - - private ModuleType getSayWithVolumeActionType(@Nullable Locale locale) { - return new ActionType(SayActionHandler.VOLUME_TYPE_ID, getConfigSayDesc(locale, true), - "say something and set the volume", "Speaks a given text through a natural voice and sets the volume.", - null, Visibility.VISIBLE, null, null); + return new ActionType(SayActionHandler.TYPE_ID, getConfigSayDesc(locale), "say something", + "Speaks a given text through a natural voice. Optionally set the volume.", null, Visibility.VISIBLE, + null, null); } - private List getConfigPlayDesc(@Nullable Locale locale, boolean withVolume) { - List params = new ArrayList<>(); - params.add(ConfigDescriptionParameterBuilder.create(PlayActionHandler.PARAM_SOUND, Type.TEXT).withRequired(true) - .withLabel("Sound").withDescription("the sound to play").withOptions(getSoundOptions()) - .withLimitToOptions(true).build()); - params.add(getAudioSinkConfigDescParam(locale)); - if (withVolume) { - params.add(getVolumeConfigDescParam(locale)); - } - return params; + private List getConfigPlayDesc(@Nullable Locale locale) { + return List.of( + ConfigDescriptionParameterBuilder.create(PlayActionHandler.PARAM_SOUND, Type.TEXT).withRequired(true) + .withLabel("Sound").withDescription("the sound to play").withOptions(getSoundOptions()) + .withLimitToOptions(true).build(), + getAudioSinkConfigDescParam(locale), getVolumeConfigDescParam(locale)); } - private List getConfigSayDesc(@Nullable Locale locale, boolean withVolume) { - List params = new ArrayList<>(); - params.add(ConfigDescriptionParameterBuilder.create(SayActionHandler.PARAM_TEXT, Type.TEXT).withRequired(true) - .withLabel("Text").withDescription("the text to speak").build()); - params.add(getAudioSinkConfigDescParam(locale)); - if (withVolume) { - params.add(getVolumeConfigDescParam(locale)); - } - return params; + private List getConfigSayDesc(@Nullable Locale locale) { + return List.of( + ConfigDescriptionParameterBuilder.create(SayActionHandler.PARAM_TEXT, Type.TEXT).withRequired(true) + .withLabel("Text").withDescription("the text to speak").build(), + getAudioSinkConfigDescParam(locale), getVolumeConfigDescParam(locale)); } private ConfigDescriptionParameter getAudioSinkConfigDescParam(@Nullable Locale locale) { diff --git a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaModuleHandlerFactory.java b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaModuleHandlerFactory.java index 61f527b7386..e3c2fe39b71 100644 --- a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaModuleHandlerFactory.java +++ b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaModuleHandlerFactory.java @@ -32,13 +32,13 @@ /** * * @author Kai Kreuzer - Initial contribution + * @author Christoph Weitkamp - Added parameter volume */ @NonNullByDefault @Component(service = ModuleHandlerFactory.class) public class MediaModuleHandlerFactory extends BaseModuleHandlerFactory { - private static final Collection TYPES = List.of(SayActionHandler.TYPE_ID, SayActionHandler.VOLUME_TYPE_ID, - PlayActionHandler.TYPE_ID, PlayActionHandler.VOLUME_TYPE_ID); + private static final Collection TYPES = List.of(SayActionHandler.TYPE_ID, PlayActionHandler.TYPE_ID); private final VoiceManager voiceManager; private final AudioManager audioManager; @@ -65,10 +65,8 @@ public Collection getTypes() { if (module instanceof Action) { switch (module.getTypeUID()) { case SayActionHandler.TYPE_ID: - case SayActionHandler.VOLUME_TYPE_ID: return new SayActionHandler((Action) module, voiceManager); case PlayActionHandler.TYPE_ID: - case PlayActionHandler.VOLUME_TYPE_ID: return new PlayActionHandler((Action) module, audioManager); default: break; 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 7111472fa99..676b5e3cfdf 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 @@ -29,12 +29,12 @@ * This is an ModuleHandler implementation for Actions that play a sound file from the file system. * * @author Kai Kreuzer - Initial contribution + * @author Christoph Weitkamp - Added parameter volume */ @NonNullByDefault public class PlayActionHandler extends BaseActionModuleHandler { public static final String TYPE_ID = "media.PlayAction"; - public static final String VOLUME_TYPE_ID = "media.PlayActionWithVolume"; public static final String PARAM_SOUND = "sound"; public static final String PARAM_SINK = "sink"; public static final String PARAM_VOLUME = "volume"; 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 a6dbe00a138..7b755f2a171 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 @@ -26,12 +26,12 @@ * This is an ModuleHandler implementation for Actions that trigger a TTS output through "say". * * @author Kai Kreuzer - Initial contribution + * @author Christoph Weitkamp - Added parameter volume */ @NonNullByDefault public class SayActionHandler extends BaseActionModuleHandler { public static final String TYPE_ID = "media.SayAction"; - public static final String VOLUME_TYPE_ID = "media.SayActionWithVolume"; public static final String PARAM_TEXT = "text"; public static final String PARAM_SINK = "sink"; public static final String PARAM_VOLUME = "volume"; From e7724fce2052b5271399940eb25db94c12376bf2 Mon Sep 17 00:00:00 2001 From: Kai Kreuzer Date: Tue, 1 Dec 2020 22:57:19 +0100 Subject: [PATCH 3/4] Update bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java --- .../module/media/internal/MediaActionTypeProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java index 188f41e2a63..c2b2d559596 100644 --- a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java +++ b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java @@ -84,7 +84,7 @@ private ModuleType getPlayActionType(@Nullable Locale locale) { private ModuleType getSayActionType(@Nullable Locale locale) { return new ActionType(SayActionHandler.TYPE_ID, getConfigSayDesc(locale), "say something", - "Speaks a given text through a natural voice. Optionally set the volume.", null, Visibility.VISIBLE, + "Speaks a given text through a natural voice. Optionally sets the volume.", null, Visibility.VISIBLE, null, null); } From 9224841cd696a8fe25e3d07086dc9dea5d3bc1cb Mon Sep 17 00:00:00 2001 From: Kai Kreuzer Date: Tue, 1 Dec 2020 22:57:26 +0100 Subject: [PATCH 4/4] Update bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java --- .../module/media/internal/MediaActionTypeProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java index c2b2d559596..7f2667a6be2 100644 --- a/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java +++ b/bundles/org.openhab.core.automation.module.media/src/main/java/org/openhab/core/automation/module/media/internal/MediaActionTypeProvider.java @@ -79,7 +79,7 @@ public Collection getModuleTypes(@Nullable Locale locale) { private ModuleType getPlayActionType(@Nullable Locale locale) { return new ActionType(PlayActionHandler.TYPE_ID, getConfigPlayDesc(locale), "play a sound", - "Plays a sound file. Optionally set the volume.", null, Visibility.VISIBLE, null, null); + "Plays a sound file. Optionally sets the volume.", null, Visibility.VISIBLE, null, null); } private ModuleType getSayActionType(@Nullable Locale locale) {