I think I have gotten to a point where my SmartHome usually knows what I want in any given situation, but there are a few instances where I would love a voice prompt, and depending on my verbal reply, to do different things.
Walking in to a home theater room, webCoRE can asks if I’d like to watch a movie.
Telling Alexa “Yes” could turn on the right devices, and set the mood lighting.
Telling Alexa “No” could open the blinds or whatever…
And simply ignoring the question could keep the room the way it is…
The good news is, after a bunch of brain-storming, coding & testing on my end, this is no longer science fiction!! I will likely add to this at a later time, but version 1.0 has been reliable in all of my testing, so I am sharing it with all of you.
There are a few caveats I should probably mention before diving in.
(1) This requires a SmartHome setup that can turn text into spoken speech. (TTS) I use Tasker on Android, but there are other alternatives such as BigTalker, LANnouncer, Sonos etc. (they should work as well as they normally do) Just to clarify, this thread will not be addressing how to set up text to speech in your house. There are already many great topics in this forum for those questions.
(2) I did all my testing using Alexa’s microphone to send the appropriate command back to webCoRE. For those without an Alexa, I believe you’ll be able to use a similar method with Google Home’s microphone, but I have not tested that yet.
(3) In it’s current state, each question can only do one of 3 things back in webCoRE. Later on, I may beef it up a bit to accept more than 3 possibilities, but for now, keep that in mind when deciding how to use this in your SmartHome.
(4) Since our speaker is going to ask us a question outloud, and then Alexa will listen for a response to send to webCoRE, I had to implement a short delay (15-30 seconds) so everything has a chance to transmit properly. This means that currently, a question can be asked no more than once every 31 seconds. Seeing how this is a brand new “feature”, and found nowhere else, I think it is a small inconvenience, that will likely not be an issue. I am only mentioning it for clarity. (since there is no ‘que’ system built in)
OK, on to the good stuff:
To implement this in your SmartHome, you will need to create two Simulated Switches in the IDE.
(This is a one-time thing, no matter how many pistons or questions you have now or add later)
NOTE: If you get an error, you’ll need to use a Private Window in Firefox or an Incognito Window in Chrome to create a Simulated Switch.
I named mine “Answer Yes” and “Answer No” because I wanted them grouped together in my list of devices. This is also because these two SimSwitches can be reused in dozens of pistons, each time responding to a different yes/no question.
Next, we need to make sure both Alexa and webCoRE can see those new devices.
- Say, “Alexa, discover my devices”
- Load the ST app on your phone > Automation > SmartApps > webCoRE > Settings > Available Devices > Check both SimSwitches and Save.
This next step is optional, but it really simplifies things in the long run so it is highly recommended.
Click here to see optional step
If you skip this section, you will have to say a longer phrase, “Alexa, turn on Answer yes”
But if you follow my advice, you can reply by simply saying, “Alexa yes” or “Alexa no”
Load the Alexa app on your phone > Routines > and then click on the (+) up top.
- When this happens > When you say something > Alexa, yes > Save
- Add action > Smart Home > Control device > Answer Yes (make sure the next page says Turn on Answer Yes), then hit Next > Add
- Finally, if you are happy with it, click Create
It should look kind of like this:
Note: I added a bonus line here so she will say “As you wish” so I know my answer was understood correctly.
Then click the left arrow, and do the same for the other SimSwitch:
Edit (Jan 2020):
Amazon has recently blocked/reserved many phrases in Alexa.
(iincluding “Alexa, Yes” and “Alexa, No”)
I have been trying to think of a natural phrase to replace “Alexa, Yes” and “Alexa, No”…
Lately, for simplicity, I have not been using Alexa’s Routines to do this… I am just controlling the devices directly using the phrase “Alexa, turn on Yes” or “Alexa, turn on No”.
We are all done in Alexa. Everything else is controlled via webCoRE and our voice.
OK, back in webCoRE, you’ll need to import this piston code (dxwi5). This piston basically just resets each SimSwitch 20-30 seconds after they turn on. (so they are prepared for the next question)
And finally, we can move to a real life example. We can create thousands of variations of this next piston, but I kept the example below fairly streamlined so it should be easy to follow the flow, and implement it in your SmartHome.
The basic concept is:
IF something happens <-- Trigger Then ask a question Wait 15 seconds IF "Answer Yes" is on <-- Condition Then do cool stuff END IF IF "Answer No" is on <-- Condition Then do other stuff (or nothing) END IF END IF
By the way, that 15 second wait is because it is allowing for:
- 1 sec for the speaker to begin
- 6 sec for the question to be asked
- 4 sec for our reply
- 1 sec for the trigger to be recognized by SmartThings
- 3 seconds for good measure.
Here it is in action, ready for import.
Keep in mind that even though the Wait on line 17 can be changed, don’t go too short or Alexa might not have enough time to do her thing. (12-15 seconds seems best during my testing) And don’t go too long without tweaking the Wait in the other piston, otherwise the SimSwitches will already be reset to their default position. (the comments should help explain that a bit)
One of the beauties of this double piston format I am using here is that the two SimSwitches are reusable in as many pistons as you want. You can literally have dozens of your current pistons, each asking a different question, with webCoRE reacting differently depending on the answer you give Alexa.
Just say, “Alexa Yes” or “Alexa No” when prompted.
In other words, the first piston will not need any tweaking. You can simply use this second piston as an example to insert a few lines of code into a pre-existing piston, to take it to a whole 'nother level.
I hope you all have fun with this one. I will definitely be incorporating this new ability in future pistons of mine, as well as adding it to many of my current pistons.
My imagination is running wild with possibilities!!
Side Note for those without Text-To-Speech capabilities:
You could cheat a bit by having the “question” come in the form of a light flashing blue etc. As long as you remember what question a blue flash represents, you could still give an answer verbally for the rest of the piston to function accordingly.