From 706cfc84e6e13c677794cf77d1749eaf30d86bee Mon Sep 17 00:00:00 2001 From: Gwendal Roulleau Date: Sat, 13 Nov 2021 10:44:10 +0100 Subject: [PATCH] Some corrections after review. Signed-off-by: Gwendal ROULLEAU --- bundles/org.openhab.binding.mycroft/README.md | 12 +++++------- .../binding/mycroft/internal/MycroftActions.java | 15 --------------- .../internal/api/MessageTypeConverter.java | 2 +- .../mycroft/internal/channels/VolumeChannel.java | 2 ++ .../src/main/resources/OH-INF/binding/binding.xml | 3 +-- .../main/resources/OH-INF/thing/thing-types.xml | 14 ++++++++------ 6 files changed, 17 insertions(+), 31 deletions(-) diff --git a/bundles/org.openhab.binding.mycroft/README.md b/bundles/org.openhab.binding.mycroft/README.md index dd719debc934e..334eac7c9adbd 100644 --- a/bundles/org.openhab.binding.mycroft/README.md +++ b/bundles/org.openhab.binding.mycroft/README.md @@ -1,12 +1,12 @@ # Mycroft Binding -This binding will connect to Mycroft A.I. in order to control it or react to event by listening on the message bus. +This binding will connect to Mycroft A.I. in order to control it or react to events by listening on the message bus. Possibilies include : - Press a button in OpenHAB to wake Mycroft without using a wake word. - Simulate a voice command to launch a skill, as if you just spoke it -- Send some text that Mycroft will say (Using its Text To Speach service) +- Send some text that Mycroft will say (Using its Text To Speech service) - Control the music player - Control the sound volume of Mycroft - React to all the aforementioned events ... @@ -46,10 +46,9 @@ The Mycroft thing supports the following channels : | channel type id | Item type | description | |------------------------------|-----------|------------------------------------------------------------------------------------------------| | listen | Switch | Switch to ON when Mycroft is listening. Can simulate a wake word detection to trigger the STT | -| speak | String | The last sentence Mycroft speaks, or ask Mycroft to say something | -| utterance | String | The last utterance Mycroft receive, or ask Mycroft something | +| speak | String | The last sentence Mycroft speaks | +| utterance | String | The last utterance Mycroft receive | | player | Player | The music player Mycroft is currently controlling | -| volume | Dimmer | The volume of the Mycroft speaker. NOT FUNCTIONNAL. [SEE THIS POST TO SEE EVOLUTION](https://community.mycroft.ai/t/openhab-plugin-development-audio-volume-message-types-missing/10576) | | volume_mute | Switch | Mute the Mycroft speaker | | volume_duck | Switch | Duck the volume of the Mycroft speaker | | full_message | String | The last message (full json) seen on the Mycroft Bus. Filtered by the messageTypes properties | @@ -94,7 +93,7 @@ String myMycroft_fullmessage "Full JSON message" { channel="my A `demo.sitemap` file : -```perl +``` sitemap demo label="myMycroft" { Frame label="myMycroft" { @@ -141,7 +140,6 @@ The following actions are supported. | Action | Description | |----------------------------|--------------| | speak(String message) | Mycroft will say this. | -| listen() | Trigger Mycroft as if the wake word was detected | | utterance(String utterance) | Ask Mycroft something| ## Full Example diff --git a/bundles/org.openhab.binding.mycroft/src/main/java/org/openhab/binding/mycroft/internal/MycroftActions.java b/bundles/org.openhab.binding.mycroft/src/main/java/org/openhab/binding/mycroft/internal/MycroftActions.java index 6814f4ac81b2e..d7974ee38fcb4 100644 --- a/bundles/org.openhab.binding.mycroft/src/main/java/org/openhab/binding/mycroft/internal/MycroftActions.java +++ b/bundles/org.openhab.binding.mycroft/src/main/java/org/openhab/binding/mycroft/internal/MycroftActions.java @@ -5,7 +5,6 @@ import org.openhab.binding.mycroft.internal.channels.MycroftChannel; import org.openhab.core.automation.annotation.ActionInput; import org.openhab.core.automation.annotation.RuleAction; -import org.openhab.core.library.types.OnOffType; import org.openhab.core.library.types.StringType; import org.openhab.core.thing.Channel; import org.openhab.core.thing.binding.ThingActions; @@ -56,19 +55,6 @@ public static void speak(@Nullable ThingActions actions, @Nullable String speak) } } - @RuleAction(label = "Listen", description = "Simulate a wake word detection") - public void listen() { - getChannel(MycroftBindingConstants.LISTEN_CHANNEL).handleCommand(OnOffType.ON); - } - - public static void listen(@Nullable ThingActions actions) { - if (actions instanceof MycroftActions) { - ((MycroftActions) actions).listen(); - } else { - throw new IllegalArgumentException("Instance is not an MycroftActions class."); - } - } - @RuleAction(label = "Utterance", description = "Ask Mycroft something") public void utterance( @ActionInput(name = "utterance", label = "utterance", description = "What to ask") @Nullable String utterance) { @@ -82,5 +68,4 @@ public static void utterance(@Nullable ThingActions actions, @Nullable String ut throw new IllegalArgumentException("Instance is not an MycroftActions class."); } } - } diff --git a/bundles/org.openhab.binding.mycroft/src/main/java/org/openhab/binding/mycroft/internal/api/MessageTypeConverter.java b/bundles/org.openhab.binding.mycroft/src/main/java/org/openhab/binding/mycroft/internal/api/MessageTypeConverter.java index 11a8800bb3ed4..3efa6688527bc 100644 --- a/bundles/org.openhab.binding.mycroft/src/main/java/org/openhab/binding/mycroft/internal/api/MessageTypeConverter.java +++ b/bundles/org.openhab.binding.mycroft/src/main/java/org/openhab/binding/mycroft/internal/api/MessageTypeConverter.java @@ -26,7 +26,7 @@ import com.google.gson.JsonSerializer; /** - * Custom deserializer for {@link LightType} + * Custom deserializer * * @author Gwendal Roulleau - Initial contribution */ diff --git a/bundles/org.openhab.binding.mycroft/src/main/java/org/openhab/binding/mycroft/internal/channels/VolumeChannel.java b/bundles/org.openhab.binding.mycroft/src/main/java/org/openhab/binding/mycroft/internal/channels/VolumeChannel.java index 591d07b7b66dd..9ee45dc5acfc8 100644 --- a/bundles/org.openhab.binding.mycroft/src/main/java/org/openhab/binding/mycroft/internal/channels/VolumeChannel.java +++ b/bundles/org.openhab.binding.mycroft/src/main/java/org/openhab/binding/mycroft/internal/channels/VolumeChannel.java @@ -34,6 +34,8 @@ /** * The channel responsible for handling the volume of the Mycroft speaker + * NOT FUNCTIONAL + * (see https://community.mycroft.ai/t/openhab-plugin-development-audio-volume-message-types-missing/10576) * * @author Gwendal ROULLEAU - Initial contribution */ diff --git a/bundles/org.openhab.binding.mycroft/src/main/resources/OH-INF/binding/binding.xml b/bundles/org.openhab.binding.mycroft/src/main/resources/OH-INF/binding/binding.xml index 1479265170236..9ce70c80aa910 100644 --- a/bundles/org.openhab.binding.mycroft/src/main/resources/OH-INF/binding/binding.xml +++ b/bundles/org.openhab.binding.mycroft/src/main/resources/OH-INF/binding/binding.xml @@ -6,8 +6,7 @@ Mycroft Binding Connect to the Mycroft message bus in order to receive information from, and send command to Mycroft. Typical usage includes triggering Mycroft to listen (as if a wake word was detected), sending text for Mycroft to - speak, - reacting on some specific intent, command skills by faking a spoken utterance, etc. + speak, reacting on some specific intent, command skills by faking a spoken utterance, etc. Gwendal ROULLEAU diff --git a/bundles/org.openhab.binding.mycroft/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.mycroft/src/main/resources/OH-INF/thing/thing-types.xml index cf5b4b2db4b54..0fcc96a25c2de 100644 --- a/bundles/org.openhab.binding.mycroft/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.mycroft/src/main/resources/OH-INF/thing/thing-types.xml @@ -14,7 +14,7 @@ - + @@ -43,16 +43,18 @@ String - The last sentence Mycroft speaks, or ask Mycroft to say something. + The last sentence Mycroft speaks. + String - The last utterance Mycroft receive, or ask Mycroft something. + The last utterance Mycroft receive. + - + String The last full message seen on the Mycroft Bus. @@ -71,11 +73,11 @@ The music player Mycroft is currently controlling. - + Switch