Skip to content

Commit

Permalink
Some corrections after review.
Browse files Browse the repository at this point in the history
Signed-off-by: Gwendal ROULLEAU <[email protected]>
  • Loading branch information
dalgwen committed Nov 14, 2021
1 parent b2cc792 commit 706cfc8
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 31 deletions.
12 changes: 5 additions & 7 deletions bundles/org.openhab.binding.mycroft/README.md
Original file line number Diff line number Diff line change
@@ -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 ...
Expand Down Expand Up @@ -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 |
Expand Down Expand Up @@ -94,7 +93,7 @@ String myMycroft_fullmessage "Full JSON message" { channel="my

A `demo.sitemap` file :

```perl
```
sitemap demo label="myMycroft"
{
Frame label="myMycroft" {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -82,5 +68,4 @@ public static void utterance(@Nullable ThingActions actions, @Nullable String ut
throw new IllegalArgumentException("Instance is not an MycroftActions class.");
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import com.google.gson.JsonSerializer;

/**
* Custom deserializer for {@link LightType}
* Custom deserializer
*
* @author Gwendal Roulleau - Initial contribution
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
<name>Mycroft Binding</name>
<description>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.</description>
speak, reacting on some specific intent, command skills by faking a spoken utterance, etc.</description>
<author>Gwendal ROULLEAU</author>

</binding:binding>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<channel id="speak" typeId="speak-channel"/>
<channel id="utterance" typeId="utterance-channel"/>
<channel id="player" typeId="player-channel"/>
<channel id="volume" typeId="volume-channel"/>
<!-- <channel id="volume" typeId="volume-channel"/> -->
<channel id="volume_mute" typeId="volume-mute-channel"/>
<channel id="volume_duck" typeId="volume-duck-channel"/>
<channel id="full_message" typeId="full-message-channel"/>
Expand Down Expand Up @@ -43,16 +43,18 @@
<channel-type id="speak-channel">
<item-type>String</item-type>
<label>TTS</label>
<description>The last sentence Mycroft speaks, or ask Mycroft to say something.</description>
<description>The last sentence Mycroft speaks.</description>
<state readOnly="true"></state>
</channel-type>

<channel-type id="utterance-channel">
<item-type>String</item-type>
<label>Utterance</label>
<description>The last utterance Mycroft receive, or ask Mycroft something.</description>
<description>The last utterance Mycroft receive.</description>
<state readOnly="true"></state>
</channel-type>

<channel-type id="full-message-channel">
<channel-type id="full-message-channel" advanced="true">
<item-type>String</item-type>
<label>Full Bus Message</label>
<description>The last full message seen on the Mycroft Bus.</description>
Expand All @@ -71,11 +73,11 @@
<description>The music player Mycroft is currently controlling.</description>
</channel-type>

<channel-type id="volume-channel">
<!-- <channel-type id="volume-channel">
<item-type>Dimmer</item-type>
<label>Volume</label>
<description>The volume of the Mycroft speaker</description>
</channel-type>
</channel-type> -->

<channel-type id="volume-mute-channel">
<item-type>Switch</item-type>
Expand Down

0 comments on commit 706cfc8

Please sign in to comment.