[Deprecated] Ask Alexa 2.0.7

Announcing version 2.0.7 of Ask Alexa

Lambda code updated to 1.1.6

Utterance file has been updated with a minor (2) updates.

Created a new posting as the original one is over 1600+ messages and it is difficult for new folks to find the information they need. This will continue the postings from there…

This update is a minor version number change to the SmartApp, and Lambda code. In addition the utterance file was updated with two new utterances and was updated. It is always recommended that you update your slots to ensure you are capturing all of the available variables used within Ask Alexa.

Please note that this is a single SmartApp; it no longer has a parent/child code base.

The only issue encountered so far with this unified code is on Android mobile apps. If you are editing a macro, clicking “Done” will take you back to the mobile app and NOT the main Ask Alexa menu. This is NOT Ask Alexa related, but the mobile app itself; iOS does NOT appear to be affected by this. Either way, a ticket has been opened with SmartThing to address this. If you find this issue annoying, please open a ticket with SmartThings as well to increase visibility.

Other additions to this new version include:

  • Bug Fixes-The usual suspects…syntax errors, punctuations, etc.

  • CoRE Macro Activation Logic-There was a logic error in how timed macros activated CoRE pistons (if you configured this option). Before, the piston would run when you FIRST activate the macro. Now, they activate when the macro runs (after the delay) as you would expect. If you used the “Args” statement within the sendLocationEvents, let me know as these had to be changed as they were put into different locations within the code.

  • Lambda Code-Fixed some syntax items, and changed how random responses are give out, allowing for easier end user changes to these responses. This will also allow for future ‘response style’ type responses that can be configured via the app.

  • Interface tweaks-Moved the Continue of Commands options to a separate page, reducing the size of the Settings area. Other non-impactful tweaks to optimize small sized screen viewing or usage clarity. This is also for the future option of response ‘style’.

  • Utterance file -Added two new utterances. Optional to install, but recommended

Installation

If you are using 2.0.0+, you simply need to update the SmartApp. Again, because of the changes it is advised to run through the entire setup as new items will be presented in your slots, the intent and utterance files have changed, along with the Lambda code.

For those wishing to re-install, the instructions on the wiki have been updated:

The wiki for this app is here: http://thingsthataresmart.wiki/index.php?title=Ask_Alexa

As always, you should also update your custom slots on the Amazon developer site when you have the app running. Nothing SHOULD change but it never hurts to refresh these every once in awhile.

Support

All of you have been great in asking very relevant questions and making suggestions that I end up using. Here are some helpful tips on usage and support:

  • The Echo, as it is designed currently, cannot react to switches opening or other actions within SmartThings. She will do things for you, but only at your direction and at the time of the request. The delay timer mentioned in the control macro happens at the SmartThings hub, not within the Amazon Alexa control.

  • When evaluating new features I will typically ask for a valid use case. If it can be used by others to bring them value I will put it on my list of future revisions. Not all suggestions will be used and many times I add aspects of the request.

  • There are no dumb questions, but many of the questions you may have were probably answered in the past few months since the initial release. Please take some time to go through the forum and the wiki if you have issues. And don’t be offended if I give you the specific area of the manual that answers your question. I have spent almost as much time on the documentation as I have on the app. Finally, there are some big fans of Ask Alexa that know almost as much as I do. They can also help.

  • Feel free to send me forks of utterances or even code revisions. As mentioned above, if it adds value to the overall program I will try to include it. This also goes for the wiki documentation…while I have spent about 80+ hours creating that document, I am open to it being improved; I know there are grammatical errors or syntax issues…If you find them, fix them…I will include your name (if I can) in any fixes submitted.

  • If you find a bug or a consistent crash please help me track it down by giving me repeatable steps to reproduce it. A non-reproducible bug, many times, indicates other areas that may be at fault besides the app. If you watch the live logging and see a red error with a line number, that is very helpful to me! However, I will need a full screenshot and not a copy/paste of the text. But be careful about revealing your OAuth and AppToken in your public posts. People can control you house with that information. May want to blur that out.

Revisions are getting less and less as I mature this product. And with the code base now unified, I expect less and less additions…especially as we integrate CoRE more to do some of the heavy lifting of larger condition-base automations… Any and all suggestions are still on the table for addition.

As always, I appreciate any public accolades or even donation to my PayPal account: https://www.paypal.me/mstruck . And, if you are so inclined, I also will accept bitcoins if you have any laying around. My wallet ID is: 1CMgaiKgBfojTBCLpHLfa9KvcrW3cNxVpm

Enjoy.

9 Likes

Thank you for the update!

I’m not sure if I’m doing something wrong but the updated Lamda code doesn’t seem to work with Voice Macros with Pre/Post Message defined. Voice Macros without it works fine. Alexa simulator gives the following error when I try Voice Macros with Pre/Post Message:

The remote endpoint could not be called, or the response it returned was invalid.

I checked the Lamda logs for this request and here’s the error log from the console:

START RequestId: <id removed> Version: $LATEST 
2016-07-22T15:50:52.519Z <id removed> TypeError: Cannot read property 'endsWith' of undefined
at IncomingMessage.<anonymous> (/var/task/index.js:115:31)
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: <id removed>

That means you are getting a null output from Ask Alexa. This seems to correspond to something not updating in either the developer site or your SmartThings account.

Common solutions are:

Go into the SmartApp and then the macro you are having difficulties in. A device may have recently been renamed…Choose the devices you are reporting on, unselect them, then reselect them, then re-save the macro (clicking Done)

If the above didn’t work, go into the Developer site, remove the macro name from the slot, then read it, saving after each step.

Let me know if that solves your issue.

Thanks for your reply.

I just tried but that didn’t help.

To test, deleted all my Voice Macros and created a simple one for testing. I put in my Patio Motion sensor for temperature report using Voice Macro. If I put nothing in the Pre Message field it works fine. If I put anything in the Pre Message field I get the above error.

I also see this error in the ST Live Logging when this runs with the Pre Message enabled.

10:51:41 AM: error groovy.lang.MissingMethodException: No signature of method: static java.lang.Math.round() is applicable for argument types: (java.lang.String) values: [undefined device]
Possible solutions: round(float), round(double), find(), rint(double), find(groovy.lang.Closure), random()
10:51:15 AM: debug Updated with settings: [muteRestrictions:false, voicePre:OK. The Outside Temperature Based On, noteFeed:false, voiceTemperature:[Patio Sensor], voiceEvtTimeDate:false, macroType:Voice, allowNullRpt:false]
10:50:33 AM: debug Updated with settings: [muteRestrictions:false, noteFeed:false, voiceTemperature:[Patio Sensor], voiceEvtTimeDate:false, macroType:Voice, allowNullRpt:false]

Thanks for the information…Instead of a temperature sensor, can you change that out to another sensor or switch and see if the error persists. Again, the issue is that a device is generating a null value. Unfortunately, I have been unable to reproduce this on my own so I can’t seem to get a good example so I can filter this out.

Let me know how that works.

Same issue with all types of devices, including switches.

Not sure if this is related but my Ask Alexa SmartApp is reporting app version 2.0.7 but lambda version 1.1.5 even though I’m running your 1.1.6 update. Live Logging is also reporting lVer as 116 when things run successfully.

You just haven’t refreshed your version…say “Alexa, Ask SmartThings version” and it will update your help screen to show 1.1.6 (or should).

I just tried this and I can’t get the error some of you are seeing. Is this a new install or just an update? The other thing that has worked for someone else is to go into the code…make a small change to the code, then change back…

Try this…
Go to the code, find line 1523
Change the line to

def fullMsg = ""

Run to see if that fixes it

Then change it back to

String fullMsg=""

if the error comes back after that let me know as I get the feeling that might be the key. If you continue to get the error after you change back I will have you change one more thing and watch Live Logging so I can get a bit more valuable data.

“Bitcoin s” is a little optimistic at $670/coin. :wink:

Not that you don’t deserve it!

1 Like

Maybe I should have said fractions of bitcoins… 0.1 bitcoins (santoshi) would work out well :slight_smile:

2 Likes

Changing to
def fullMsg = ""

Doesn’t seem to help. I’m getting the same error when Pre Message is filled. With this change I now get a different error when Pre Message is empty.

Lambda response is this:

{
  "response": {
    "outputSpeech": {
      "type": "PlainText",
      "text": "There was an error processing the report. Please try again. If this error continues, please contact the author of Ask Alexa. Would you like to try again? "
    },
    "card": {
      "content": "There was an error processing the report. Please try again. If this error continues, please contact the author of Ask Alexa. Would you like to try again? ",
      "title": "SmartThings Voice Macro",
      "type": "Simple"
    },
    "shouldEndSession": false
  },
  "sessionAttributes": {}
}

First, very little that comes from the Lambda will be helpful…it only responds to what the smartapp sends it…However, since the message IS different I know I am on the right track. Here is what to do next. On that same line, remove the ="" and just have String fullMsg Does that work?

If not, then change it back and then change 1525 to

fullMsg += voicePre ?  voicePre + " " : ""

If THAT doesn’t work I am going to have you remark out the error trapping next.

thanks @MichaelS. Updated and working smoothly.

The one area I don’t have working well is Sonos integration. Is it possibly to use Ask Alexa to play a spotify playlist on sonos?

I noticed the Echo-Sonos app that allows: Playlists: “Alexa, tell Sonos to start playlist MY PLAYLIST in the ROOM”

What is the best way to get Sonos working with Spotify playlists?

thanks!

Once you get the Sonos playing what you want, you CAN control the speaker (play, mute, volume) with the Alexa…but at this time I can’t initiate any music…I can add that, but the methods are a bit ‘clunky’ at you wouldn’t be able to initiate any song using your voice…only songs that have been played previously…

right, got it.

I was just wondering if you could use the same methods as the Echo-Sonos app to initiate a playlist.

Those changes don’t seem to fix the issue.

Another thing I noticed was that if I request status from a Switch (non-dimming) I get the “There was an error processing the report” error message I mentioned above. Dimmers are reporting that it can’t find the last “on” event even without a Pre Message using the original 2.0.7 code and the various variation I’ve tried as suggested. Temperature, Presence, Motion, SHM, Modes all report fine in Voice Macro if I don’t use Pre Message.

Just to make sure nothing was wrong with ST itself I rolled back Ask Alexa to 2.0.6 and lambda to 1.1.5 and everything worked without issue.

If they have been played before, then yes…you could possibly reference them…

Can you go back to 2.0.7 and do one more test for me? Can you put remark statement (//) in front of lines 1524, 1560, and 1561 ? This will allow any errors that pop up to show in the live logging. Please let me know if you get any errors in the log (I don’t recommend posting them here (You can PM me) as they have your token information). IF you get nothing set 1523 to def fullMsg and that WILL produce an error that may be enlightening.

The issue is probably not SmartThings, per se. I spent last week with someone troubleshooting this only to find out a switch they were using had its name changed recently. Then before that just changing one line in the code and then changing it back fixed it. So it is account related…I just can’t get a handle on WHAT is causing it so that I can prevent it.

I would also try some radical items…like re-issuing your OAUTH token, and not only saving a macro, but making a small change in your main app (like add and remove a switch) and then ensuring you exit the entire app by pressing done…

Let me know if any of those work. No need to revert back…and reverting will not be a long term fix…unless we unfreeze whatever is 'stuck; within your account you won’t be able to go forward with any further updates to this app.

One of the items with troubleshooting is when too many things are changed. Your last posting about the switches got me thinking and while it seemed similar, this was a completely different issue. As such, I WAS able to reproduce that and fix it…I just published 2.0.7a with that fix. This will NOT probably fix your pre/post message issue, but let me know if it does…I still recommend my suggestions above as that is how I fixed the issue with the switches.

@MichaelS @jpark40

I had this same thing happen to me one night. Same symptoms and everything.

Completely delete the lambda file. Click save.

Make sure you go to the RAW file and copy the lambda and the paste it again.

Not sure why… but that fixed mine.

Thanks.

These suggested remark statement points did not produce any new error messages and produced the same “null” value for fullMsg

I wanted to figure out where the null value was being assigned to fullMsg inside reportResults() so I put some log.debug "Variable check1 fullMsg: ${fullMsg}" at various point inside of reportResults()

The only time log.debug "Variable check1 fullMsg: ${fullMsg}" failed to output something to Live Logging was after line 1563. So to test I commented out this line and now everything works fine with Pre/Post Messages enabled in Voice Macros, expect for the variables. My advanced filtering is off so maybe something inside replaceVoiceVar() is causing the null to be assigned?