Hi all,
I thought I would share this solution was inspired after
conversing with other members in this thread.
I have multiple echo devices in this exampler I show two.
A routine name is spoken to a echo device and the OH rule will
process that rule and respond back to the echo that the user
used for the routine.
This is VERY powerful. anything that OH can do including
running external scripts or grabbing data from external
sites is now available through voice commands using Alexa..
=======================================
Alexa Mobile App
Create a routine using the phrase of your choice,
pick carefully so it is understood by the AI reliably
and is not already used.
For this working example I have a routine using the phrase
‘Alexa, dryer status’
It has a custom sound response configured back to the asking echo of ‘checking’ and that is it.
ITEM
_// Alexa Groups_
Group LR_Alexa <player>
Group HO_Alexa <player>
Group EchoCmds
_// Office Echo_
String HO_Echo_TTS "Speak" (HO_Alexa) {channel="amazonechocontrol:echo:account1:HO_Echo:textToSpeech"}
String HO_Echo_LastVoiceCommand "Last Voice Command" (HO_Alexa, EchoCmds) {channel="amazonechocontrol:echo:account1:HO_Echo:lastVoiceCommand"}
_//Livingroom Echo_
String LR_Echo_TTS "Text to Speech" (LR_Alexa) {channel="amazonechocontrol:echo:account1:LR_Echo:textToSpeech"}
String LR_Echo_LastVoiceCommand "Last Voice Command" (LR_Alexa, EchoCmds) {channel="amazonechocontrol:echo:account1:LR_Echo:lastVoiceCommand"}
RULE
rule "Alexa Dryer Status"
when
Member of EchoCmds changed to "dryer status"
then
logInfo("Dryer_Status","Dryer Status Rule has been triggered using Echo: " + triggeringItem.name)
// Work out which response message to use, start with a default.
var String message = "The dryer is not in use."
// check operational status of the dryer and update default message as needed
if (BR4_Dryer_OPState.state == "INUSE") {
message = "The dryer is currently in use."
// improve on the information passed back to the user
if (DryerElapsedTime != NULL) {message = "The dryer has been in use for approximately " + DrtyerElapsedTime.state + " minutes."}
}
// get the room of the echo device
val sourceRoom = triggeringItem.name.split("_").get(0)
// use the room prefix to specify the actual device TTS for the returned response.
val _TTS = sourceRoom+"_Echo_TTS"
// play the response on the triggering rooms echo device
_TTS.sendCommand(message)
logInfo("Dryer_Status","Message : " + message)
end
==============================
I hope that makes sense and assists others.
Thanks
Paul