WebCoRE asks a question, my voice response determines the action

text-to-speech
answer
query
voice
alexa

#1

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.

For example:
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.

01

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” :-1:
But if you follow my advice, you can reply by simply saying, “Alexa yes” or “Alexa no” :+1:

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”…

@lflorack had success using “Yes, please” and “No, thank you” instead of the two phrases above.

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.


Making voice announcements & controlling Amazon Alexa Echo
Which Alexa am I talking to?
Making voice announcements & controlling Amazon Alexa Echo
TV Accent Lights & Living Room Lights
Dryer piston based on acceleration
Opening the Door when you arrive home with Intractive Push Notification
"continued conversation" trigger
Create a push question then do action based on answers
Making voice announcements & controlling Amazon Alexa Echo
Conditions and Triggers: The difference?
2nd IF not running - Echo Speaks
Dryer piston based on acceleration
Trying to make make my command still run after door is close
Trying to make make my command still run after door is close
Phone Notification with Response
#2

Placeholder


#3

Thank you so much @WCmore this is great…
I’ve been waiting for this:)))

And of course questions LOL

I did not get the PUSH NOTIFICATIONS part…
How is line 24 is text to speech?
is it because you said you use tasker?

I am a sonos user, should I change that to
Speak “Would you like to hear some music?”


#4

Yes, you are exactly right. You can basically replace my "Send PUSH" commands with whatever you normally use for text to speech.

In your case, line 26 would be the question you want asked, and line 32 would be the command to start playing your playlist etc


#5

Ok great thank you…

And the answer YES, if I understand this correctly, I can only use “Alexa yes,” for a single task…
Lets say:
Sonos says “Would you like me to play music”
I say
“Alexa yes”

but for another task, I should be using something else
Sonos says “Would you like more lights?”
I should not say “Alexa yes”
But I can say (after creating the new routine and all)
“Alexa, yes I need more lights”

Am I understanding this???


#6

No, the two SimSwitches are all you’ll need for unlimited yes/no type of questions. They can be used in hundreds of pistons, each asking a different question!!


#7

Ok now mind blown :)))))
I have to read this 5 more times and understand better…

thanks again for this amazing addition…


#8

This community is so freaking awesome, it’s nice to be able to give back when I can.

In a cross-platform environment such as webCoRE, I have not seen this “responding verbally to a question” anywhere else. All other voice respondors I have seen are proprietary, and basically “locked” into a specific company.

All that changes now…


#9

Awesome, will this work with this? I posted your solution over there, so hopefully it does…nice job!


#10

I have not tested that setup yet, but as long as you can get webCoRE to read a question outloud, then yes, the logic here will work!


#11

Awesome…Yes, Echo Speaks is awesome too :slight_smile: I love this stuff…


#12

Hey @smartie , on the other page, can you change your link to point to my original post instead of halfway down the page please?


#13

Of course…I just realized that…

Fixed.


#14

Nice work! This is going to be a great app…

Question… how does Alexa know when to ask you a question?

edit… nevermind. I see what’s triggering the question to be asked.


#15

There is absolutely no logic in Alexa whatsoever. All the coding logic is done in webCoRE, so you decide when to have the question asked.

The Alexa Routine is only used so we can respond with a shorter phrase.
“Alexa yes” is much better than saying “Alexa, turn on Answer yes”


#16

When I try to create the switch, I get a new screen saying

“Access Denied
We’re sorry, but you are not authorized to perform the requested operation”

What’s up with that?


#17

Darn SmartThings acting up again.

It always works for me if I use a Private Window in Firefox
or an Incognito Window in Chrome…

temp


#18

That worked, lol…Do we also input the Hub and Location?


#19

Yes. The only blanks should be “Zigbee Id” and “Group”.

Also note that “Device Network Id” should not contain any spaces


#20

At the bottom of my screen, it says, “Create”

[EDIT] Oops…I missed the second part with her response.