Simon says use Alexa with NodeRED

 

Once you start playing around with getting Alexa to control stuff around your home with NodeRED, you are normally faced with the issue of needing an Alexa skill.

And you then either have to write your own one (big job!) or use one someone else has written, which will have restrictions and limitations on what sort of commands it will accept.

And even if you write your own skill, you’ll find that Alexa is always trying to guess what you want to do and offer other options, especially if you try to use common phrases such as play or record. 🙁

The Simon Says Solution

If you have an Alexa device, you might have heard and tried using “Alexa, Simon says its a lovely day today” and Alexa will say “It’s a lovely day today”

It will just repeat what you ask it to say and will never try and interfere 🙂

So all we need is something that can listen for any commands that A⍺lexa receives and react to ones that start “Alexa, Simon says”

The disadvantage of using this technique is, of course, that you have to say “Alexa, Simon says ….” instead of just “Alexa …. ”

Obviously, for someone called Simon (such as myself) this isn’t an issue at all 🙂

But we do get total freedom to do what we want with Alexa requests.

Setting up NodeRED to listen for Alexa requests

(This assumes that you have have an Alexa device and you’ve used NodeRED If you haven’t used NodeRED before, then have a read of the docs and have a little play with it first)

Select the 3 line hamburger menu at the top-right and then select Manage Palette, click on the install tab search for remote2 and install the node called node-red-contrib-alexa-remote2-applestrudel

Once you’ve done that, copy this flow and import it into NodeRED

https://pastebin.com/iZ7k2AqJ

Double click on the blue On Device Activity node and click on the pencil to add new account details


Notes:

  1. Change the This IP to the IP address of the machine Node-RED is running on
  2. Make sure you have a filename in File Path
  3. Set Refresh to 0
  4. Adjust the Amazon settings depending on which country you are in following this guide
 |     | Service Host        | Page          | Language |
 |-----|---------------------|---------------|----------|
 | USA | pitangui.amazon.com | amazon.com    | en-US    |
 | UK  | alexa.amazon.co.uk  | amazon.co.uk  | en-UK    |
 | GER | layla.amazon.de     | amazon.de     | de-DE    |
 | ITA | alexa.amazon.it     | amazon.it     | it-IT    |
 | AUS | alexa.amazon.com.au | amazon.com.au | en-US    |

When you press Deploy, you’ll see a status underneath the blue Alexa node asking you to open yourIPAddress:3456 in your browser. Open a new tab and then do that and fill the authorisation screen that appears with your Amazon account information and sign in. Sometimes I’ve had to do this twice as 1st time doesn’t take for some reason.


Once that is complete, you’ll get this notice

and you can close this browser tab and go back to your NodeRED tab where it should show that the Alexa node is now listening for your Alexa requests.

Just try it out by asking “Alexa, Simon says hello” and it should show this


If everything works as described you can now connect the output of the filter node to a switch and use the “contains” option to test for commands

Advanced Information

If you just say “Alexa, something” – you’ll find that what you get is this as the output of the Filter node:-

But if you say “Alexa, Simon says something” then you will get this

To sum up the differences, my filter function node supplies:

  • msg.payload: The alexa request without the word “alexa” or the phrase “simon says”
  • msg.name: The name of the Alexa device that heard the request
  • msg.summary: The total request that Alexa thinks you said but with the “alexa ” filtered out

If you have any issues or questions, you can contact me on the Node-RED forums https://discourse.nodered.org (I’m CympleCy on there) or on Twitter (@cymplecy)

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *