You need to add the below line at the top of your rule file. It is actually part of the initial rule I posted above.
import org.eclipse.smarthome.model.script.ScriptServiceUtil
You need to add the below line at the top of your rule file. It is actually part of the initial rule I posted above.
import org.eclipse.smarthome.model.script.ScriptServiceUtil
You will need to include this import at the top of the rule file…
import org.eclipse.smarthome.model.script.ScriptServiceUtil
More detail here…
I was just trying to make use of this rule/script but I noticed that the LastVoiceCommand is not working for me on OH 3.2. Is it an issue from my openhab or is it releated to something else ?
That’s an issue with the Amazon Echo Control binding. I would suggest searching for that issue in the forum.
Found it in the meantime, now using the latest binding jar file
I have a Dummy Switch I use so Alexa can tell me the current Gas Price (Question about Amazon Echo Control Speak Feature - #8 by J-N-K). Currently my rule is setup so if the Dummy Switch is triggered only on my living room alexa the answer will be said.
What I am to achieve now is to detect which Alexa Device has received the question, that triggered the dummy switch and have the same Device answering speaking the answer/current gas price.
I have 3 different Alexa devices, named this:
Livingroom
Bedroom
Kitchen
I am now having difficulties to understand how the scripts and rules exactly work to determine the alexa device that was triggered. May I ask you to elaborate how that would work. I seem to be to stupid to understand it how it is wirtten right now.
You could trigger your rule by a change to the lastVoiceCommand
channel of your Echo and check if “gas price” is part of the command. If so, answer with the command, if not, do nothing.
Best Regards,
Jan
Here’s how I know which Alexa was spoken to OR last spoke.
This is pieces of my logic below. All my items for the Alexa are standardized for each room.
i.e. Echo_SourceRoom_ItemDesc
Member of AlexaCmds changed
var String sourceRoom = triggeringItem.name.split("").get(1)
var String TheRoom_TTS = "Echo"+sourceRoom+"_TTS"
logInfo(“ECHO”,"TTS Device is " + TheRoom_TTS + “.”)
logInfo(“ECHO”,"Triggering Command is " + triggeringItem.state + “.”)
TheRoom_TTS.sendCommand(HouseAlarmMsg)
Best, Jay
Perfect. Thank you very much for this.
I solved it in the same way now!
Is it possible with the rule and scripts you @jeshab shared in your posts that alexa understands something like this correctly aswell ?
Alexa, turn on the lights for 10 minutes and 40 seconds ?
My rule fragment lines above is tied to a very long rule watching for last command and re-acting to it based on what is said. You’ll also have to create a rule in the Alexa app, so Alexa doesn’t try to react to what you said. I usually create a routine looking for those words and just have Alexa respond back either “Sure” or “Let me find out”.
Here’s just one example of it.
if (systemStarted.state != ON && triggeringItem.state == 'loft temperature') {
logInfo("ECHO","Alexa Loft temperature Status via Voice has been triggered using " + triggeringItem.name)
Thread::sleep(500)
var String lofttemperature = '<speak><prosody rate="fast">Loft temperature, is unknown to me at this time.</prosody></speak>'
if (systemStarted.state != ON && gLoftTemp.state !== null && gLoftTemp.state != NULL) {
lofttemperature = '<speak>Loft temperature is, ' + gLoftTemp.state + ' degrees.</speak>'
}
TheRoom_TTS.sendCommand(lofttemperature)
return;
}
Best, Jay
i don’t understand how to configure this…
i added a new thing →
after that from the item
Group gAlexaVoiceCommand "Alexa Voice Command" <--- don't touch
String BedroomEchoDotLastVoiceCommand "Last Voice Command" (gAlexaVoiceCommand) {channel="CHANGETHISID?:lastVoiceCommand"} <-- change id
String BedroomEchoDotTextToSpeech "Text to Speech" {channel="CHANGETHISID?:textToSpeech"} <-- change id
Switch BedroomFanPower "Bedroom Fan" {alexa="Switchable"} <--- useless just for example?
Switch AlexaActivityFan "Fan" {alexa="Activity", expire="1s"} <-- command that trigger the rule?
so when u say “alexa fan” the rule is triggered and follow the map config?
Correct. The activity item is a placeholder allowing a command to be received through the textToSpeech
channel without returning a voice error and to trigger the rule.
and what about the strings? they need to be personalized?
Not sure to understand what you mean. Using the logic in the example above, you should be able to customize it for your use case.
i don’t understand the channel parameter and the string value, is something u writed bc trigger some command of alexa?
bc i don’t see mentioned in the rules, so i don’t understand if is required stuff or is something else (u noticed the changes i made?)
The channel metadata parameter should include your device thing id. This equivalent to linking an item to a given channel in the UI.
ok now it works… was missing the plugin for transform …
in the end i just changed the texttospeech in textCommand and used this
>
if (category === null) return;
val deviceName = transform("MAP", "alexa.map", category.toUpperCase + "-" + location)
if (deviceName == "") return;
val command = triggeringItem.state.toString.replace(category,deviceName)
sendCommand(triggeringItem.name.replace("LastVoiceCommand", "TextToSpeech"), command)
basically the map change from the generic name to the correct name and trigger again alexa with the “correct” command… only problem is that alexa answer 2 times, but in this way i can say something like “open curtain at 50%” and is triggered without handle all the special cases
hey everyone,
Where is “triggeringItem” being defined? I’m getting an error that is a null object. Same goes for systemStarted.
Based on the examples above, I believe OH cannot query triggeringItem.State or systemStarted.State without those items being defined somewhere.