[NO LONGER SUPPORTED] Ask Alexa

Ok…I just tested this and it appears there is a mistake in the code…will straighten this up and publish a new version to fix this.

Thanks for pointing this out :slight_smile:

Edit: I tested this and pushed a fix…https://raw.githubusercontent.com/MichaelStruck/SmartThingsPublic/master/smartapps/michaelstruck/ask-alexa.src/ask-alexa.groovy

You should be able to update your IDE directly. Thanks again for pointing this out.

My bad… I went to “About Ask Alexa” - “Display Cheat Sheet” and the format is different. This caused me to question my setup. But now I know… ''Setup Variables" with the big Amazon logo… duh.

No worries…but to be clear, you DID find a bug that I have since fixed…

Guys, fairly new to the Ask Alexa user group, and I’ve looked for this answer in the forum and release notes but haven’t found precisely what I’m looking for. I’m hoping someone can point me to a direct answer.

I’d like to be able to Ask Alexa to perform a ST automation after a variable interval of time, essentially creating a timer. I know she can’t trigger based on a timer, but curious if she can trigger a ST function that waits first, then continues execution (like you can do with a CoRE piston).

Example Utterances:
“Alexa, Ask SmartThings to turn off the Front Porch Lights after 15 minutes”
“Alexa, Ask SmartThings to turn off the Front Porch Lights in 15 minutes”
“Alexa, Ask SmartThings to wait 10 minutes and then turn off the Front Porch Lights”
“Alexa, Ask SmartThings to turn off the Front Porch Lights at 11:00PM”

Are these kind of constructions possible natively or through the use of macros? If so, can you point me towards some examples or documentation to help me implement? Thanks in advance!

Jarrett,

If you think of Ask Alexa as two parts it will hopefully explain how to do this…

For individual devices you really can’t set timers for their action. Alexa is based around real time interactions. There are two reasons for this…first, Alexa will ONLY give feedback to a response…if you set a timer you can’t have her say in 10 minutes (I turned off this light)…In addition, SmartThings has a limit to the number of ‘timers’ that can be set. Right now it is 6 and all programs abide by it, but Ask Alexa creatively gets around it using macros, but more about that in a second. So, for INDIVIDUAL item that are listed in the main menu, you can set those in real time.

However, you do have options…First, you mentioned Core…Ask Alexa integrates with Core nicely. You can run a Core “DO” piston from the Core Macro…Simply create a Core Piston that has a delay as a DO macro. Then, go into Ask Alexa and you will see a list of your Core Pistons in Ask Alexa. You choose the name (or alias) of the macro, and when you trigger it the app will run the macro. If the piston is delayed, then it will be delayed. You can even set a feedback message saying "I am setting the lights in 10 minutes). Since the timers are set in core, you can have MORE than 6 scheduled events.

If you don’t want to use Core for this, a Control Macro in Ask Alexa will also allow you to do the same thing…This one gives you a bit more control over the execution time. Simply build a control macro. This will allow you to initiate a routine, or control groups of devices (including lights). Then you simply say “Alexa, tell SmartThings to run {macro name} in x minutes:”. You can even set a time limit in the macro in case you forget to set a time verbally. And, since a macro is technically a separate program (a child app), you are NOT limited to 6 scheduled events for Ask Alexa…Just create a new macro for every timer item you want.

Let me know if this answers your question. Ask Alexa is VERY powerful and I have found very few use cases that can’t be solved with it.

I have released a great update, which builds on the features of last time, along with adding the framework for some great stuff going forward:

1 Like

Thanks for the details Micheal. I’ve successfully implemented using the Control Macro option. Last question. Is there a way in the feedback message to use a variable to read back the delay time, such as “I will run the macro in X minutes” where X is the time you requested for the delay. If so, what is the variable syntax?

Thanks again for all your help! My wife is very happy with her new timer.

1 Like

WAF (wife acceptance factor) is VERY important. I am glad you got this working.

Funny you should mention the variables…something I put in and wasn’t sure people were going to use it:

http://thingsthataresmart.wiki/index.php?title=Ask_Alexa#Text_Field_Variables

Enjoy!

1 Like

I updated the code today to 2.2.3a…small deletion of code that shouldn’t have been in there and fixed an all too obvious misspelling error…so it was bugging me :slight_smile:

1 Like

For those that come by this thread on Friday’s to see if there is a new update to Ask Alexa, per the release notes for 2.2.3, there won’t be one for a few weeks. However, I have reached a milestone in the development, so we are well on our way for another version release soon. For those of you that use the message queue you will find you have a LOT more options to choose from as we prep for Amazon releasing their push notification feature (no ETA yet).

I will be reaching out to my partner community developers before the release so they may prep for using the new features of the message queues. This will include directing messages to specific speakers and customizing the notification methods. Once this structure is in place, it will only be a little work before we can have speaker to speaker communications!

Thanks for your patience and encouragement (and donations!) for keeping this project going!

6 Likes

I sense a great opportunity for Super programmer Gus Gorman…

2 Likes

Just learned of this today so I did the install. Dude - you rock! This is really great stuff. The install was tedious but easy. It helped that I already had an Amazon Dev account. The lambda account was easy to add. Now I just need to start the tweaking and macro writing process which should be fun. As a programmer I really appreciate have this a a sophisticated sample code for writing my own stuff too.

1 Like

Ken,

Excellent! Good to hear from a fellow programmer! I have some new additions to the app coming soon so be sure to sync your GitHub with your IDE and watch this space! And thanks for the little ‘incentive’ I received today as well…Really appreciate it!

Sorry to bother you , however I keep getting and error when using Ask Alexa, Alexa keeps telling me that the Version of LAmbda Code is out of date , I have updated IDE from GitHub to ver 2.23a. I cant seem to figure out.
W\at am I missing here

Besides not being able to type today

Hehe…no worries…What you will want to do is ensure you get the latest code for the Lambda portion. That is here: https://raw.githubusercontent.com/MichaelStruck/SmartThingsPublic/master/smartapps/michaelstruck/ask-alexa.src/Node.js

Here are the steps you need to take to ensure a clean upgrade.

  • Go to your current code in Lambda (AWS).
  • Find the lines around 39-41 (the STAppID, STToken and URL. Copy those to a notepad or something
  • Copy the code from the GitHub site above and OVERWRITE the current AWS code
  • Copy the items from the second step back into lines 30-41 in the Lamdba code
  • Save…

That should do it…let me know if that works for you and if you get this operational.

I replaced the Code you specified and pasted in my origional STappID and STtoken now when I say “Alexa ask the Hub” , she responds there was an error with the Alexa Smart App execution , if this continues please contsact the Author of the Smart App

Thanks
Larry

Sounds like the OAuth may have changed…If you went through the whole install again you may have inadvertently changed your authentication…no big deal. I recommend going to Settings and running the Setup Variables and recopying the 3 lines from the generated web page to Lambda.

Let me know if that works…

OK Tried That too no luck , Copied OAuth ID and Secret to Lambda Code , NG Tried Refreshing Client Secret in Smart App Settings and tHe executed a save/test here is the log output maybe that will help, sorry to be such a pain.
START RequestId: 260f004c-0cc4-11e7-9851-61ae9256fb76 Version: $LATEST
2017-03-19T16:50:25.768Z 260f004c-0cc4-11e7-9851-61ae9256fb76 TypeError: Cannot read property ‘type’ of undefined
at IncomingMessage. (/var/task/index.js:61:30)
at emitOne (events.js:77:13)
at IncomingMessage.emit (events.js:169:7)
at IncomingMessage.Readable.read (_stream_readable.js:360:10)
at flow (stream_readable.js:743:26)
at resume
(_stream_readable.js:723:3)
at nextTickCallbackWith2Args (node.js:437:9)
at process._tickDomainCallback (node.js:392:17)
END RequestId: 260f004c-0cc4-11e7-9851-61ae9256fb76
REPORT RequestId: 260f004c-0cc4-11e7-9851-61ae9256fb76 Duration: 888.71 ms Billed Duration: 900 ms Memory Size: 128 MB Max Memory Used: 8 MB
RequestId: 260f004c-0cc4-11e7-9851-61ae9256fb76 Process exited before completing request

That looks like the output of Lambda…You don’t need that and that is not a good way to test as it will always show an error without proper input.

The best way to test is via either the developer site or actually speaking to Alexa. If you say “Alexa, Ask {invocaton name] help.” Any output besides the instructions speech is incorrect. Let’s start from there.

I assume you had this working previously, correct? If so, do the test above and let me know the output. If it appears not to be working, I would re-generate your Oauth key (via Settings). I would then copy/paste from the link I sent earlier to Lambda, then do the Setup Variables piece again. I know you already did this, but I have seem TOO many times the copy/paste process miss one character and it shows this symptom.

Please report back on your progress and what you are seeing (hearing).