Node Red Alexa Remote2

To give this set of nodes their full title, the offering is known as node-red-contrib-alexa-remote2 and has VERY recently been updated.  For those of us who’ve been struggling controlling our home devices with various custom packages recently, the best option over the past few weeks seems to be node-red-contrib-amazon-echo – it works well – I’ve blogged about it and so have others, but it always helps to check out alternatives.

And along comes THIS – read the link I just gave you. I’m still struggling figuring out what exactly to do with is – here’s where I’m up to – everything seems to work – as in – I’m not getting errors. Read this blog to avoid the timewasting I did this morning. If you;’re ahead of me, please DO comment or email and let’s make this blog entry an informative took instead of a puzzle.

Ok, so, prerequisites, you should have a device/gadget running a recent Node-Red, let’s say a Raspberry Pi 2 or 3 or 4. You should have an Amazon Alexa device – I have a DOT version 3.

You might want to turn things on and off as a starter… I do that all the time but I’ve not gotten that far with node-red-contrib-amazon-remote2.

Using the Node-Red”Manage Palette” command (top right) install node-red-contrib-alexa-remote2.

Done. Now you have to configure it. That info is here: https://flows.nodered.org/node/node-red-contrib-alexa-remote2.

As the gave me trouble for a few minutes – I’ll give you an EXACT example. Drag an “Alexa Routine” onto a nice new test flow (page) in Node-Red. In the right side of the “Alexa Routine” node’s “account” field, create a new account…  that is a brand new setup, the only thing that will be real here is your Amazon account – more on that soon. I’m assuming you have an Amazon account for your Echo and have already played with devices. maybe real ones?

tmpB3AFSo, in this “account” dialog box, is a field for an optional name – I didn’t give it a name. Next is a dropdown box called “Account”. I created a new “account” called “test2”. In there is an “auth method” and I left that at the default “proxy”. Then there is a field for “This IP”. It defaults to localhost which would be fine if your PI had a browser, mine doesn’t. I changed that to “192.168.1.19” – the local address of my PI. Next is “Port” – which defaults to port 3456. I chose (at random) 3457. I left the “file path” blank as it is optional. “Auto init” and “Events” I left alone.

“Service host” I set to the UK-recommendation “alexa.amazon.co.uk” and “Page” to the UK recommendation “amazon.co.uk”. I set the “language” field to the UK-recommendation “en-UK”. I left the optional “User agent” blank.

imageI closed that lot and I noted something about putting the IP number and port into a browser – it didn’t say WHERE (i.e. on the Pi or a PC etc) so this is where I save you time maybe? My PI has no screen attached. Above, I put in the internal IP address of the PI was working on… so now, in my PC, in my CHROME Browser I could enter “192.168.1.19:3457” – Bingo.

On my PC in the browser, using  the above link, I entered my real Amazon account and password and this dialog closed leaving a page in the browser saying this:

image

I went back to Node-Red and back in “Edit Alexa Routine Node” dialog with my “test2” account, I entered the recommended text “Hello world”… and in devices, I  selected my existing real DOT called “office dot”.

image

And that is where I am up to – totally LOST. No errors – the nodes say “ready” as you can see.

image

I picked the “echo forward” node for no good reason – as I was looking for a “devices” node to create a new dummy device who’s output I could connect to a REAL device to turn it on – i.e. one of my ESP8266 boards I control by MQTT protocol. No such luck.

I was expecting some kind of node so  I could create a “virtual” device called, say “fred” and turn it on and off, the output of which I could feed via, say, MQTT to some real device. I’m sure you must be able to do this – but I’m not at that point yet. Over to readers. I’m sure it is obvious?

Facebooktwitterpinterestlinkedin

57 thoughts on “Node Red Alexa Remote2

  1. I read your blogs avidly and this one really got my attention, i have had a short play with this on my own setup this morning. Im am very excited about that this node can do!!. it appears to be able to open up the whole system at lot more than previous nodes. In the short time i had, i was able to connect to my Mihome alarm sensor and send verbal notifications to any echo device plus, a text notification to my phone. i used routines on the alexa app and set up a trigger word, using the on device activity node for feedback im able to filter out that trigger word to activate my devices. im no expert here, but i hope that helps.

    1. So, making as few assumptions as possible do you want to show us exactly what you did? Rightt now I’m clueless as to how to proceed. Meanwhile of course I have node-red-contrib-amazon-echo telling a device “fred” to turn on and off – (simply by adding a device node eith the name “fred” and telling amazon to search for devices). The 1.0 outputs from the device node then go on via a simple function node to actaully turn something physical on and of etc. All of that (apart from colour, now sorted) was dead easy but I’m not quite picking up on what to do with this remote2 app (I don’t have any REAL Alexa compatible gadgets here – I just then go on to control them with MQTT – hence the mind-set..

      1. Hi,
        I was stuck as well but had the US service host rather than UK,
        changed it and works now

        Service Host Page Language
        USA pitangui.amazon.com amazon.com en-US
        UK alexa.amazon.co.uk amazon.co.uk en-UK

      2. I’m sure you figured this out, but I will post my experience for reference for others and to elaborate on Alan’s post above:
        Once you get this all set up and working you can send state information back to Alexa by using the “Alexa Event” node to basically watch everything a particular Echo Device does/hears (Hook up a debug and watch the JSON come piling in).
        I set up a routine in the Alexa app without an action, (an empty routine if you will) and when I ask “What is the Freezer temperature” nothing happens in the app, but, I use the Alexa Event node to watch for “Freezer Temperature” in the JSON. I have a DHT11 monitoring the freezer’s temperature, I save it to a flow variable, then if the Alexa Event node sees “Freezer Temperature” she speaks back the flow variable (the temperature) using the “Alexa Routine” node.

        1. Just to add if you have multiple Echos, you can use Custom method in the Alexa Routine and pass it a payload something like msg.payload={type: ‘speak’, payload: { type: ‘regular’, text: ‘Freezer is’+temp+’degrees’, devices: [msg.payload.name]}}. Then the payload.name will make sure that the message is routed back to the device that the request was heard on.

  2. Ok, so I went to the examples page for the node and put the first one – a test json flow called “alexa speak”. I put in the account I set up… on my phone the dashboard page came up, no issues – then I selected my office DOT – and in the other field put the text “hello how are you”. In Node Red that cause an “error: input response failed”. Back to square one?

  3. Here’s a sample flow that works for me. The inject is just sedning the default timestamp. The only config I did on the Routine node is to add “This is a test” to the “Text” field and select my config in the “Account field”.

    Once you deploy you should see a blue icon under the Routine node showing it’s connected. If not, you still have work to do. Oh, and it should show a list of available devices in the configuration page for the Routine node.

    You may have to initialize if this is the first time. I did that a few days ago and am now trying to remember how. I know it’s an inject node and an Alexa Init node but there was more to it. I went ahead and added my refresh cookie sequence to the flow below. That should keep it initialized once you get it started. Let me know if you need more help on it and I’m happy to try. I’ve learned so much from you I’d love to give back.

    [
    {
    “id”: “c8594bdc.1ed9d8”,
    “type”: “tab”,
    “label”: “Alexa Init”,
    “disabled”: false,
    “info”: “”
    },
    {
    “id”: “2f8ed8a3.db9a68”,
    “type”: “alexa-remote-init”,
    “z”: “c8594bdc.1ed9d8”,
    “name”: “”,
    “account”: “a30831e3.1d09”,
    “option”: “refresh”,
    “x”: 280,
    “y”: 340,
    “wires”: [
    [
    “8d990367.02bd3”
    ]
    ]
    },
    {
    “id”: “115fefb1.f4dc”,
    “type”: “inject”,
    “z”: “c8594bdc.1ed9d8”,
    “name”: “”,
    “topic”: “”,
    “payload”: “alexa”,
    “payloadType”: “flow”,
    “repeat”: “”,
    “crontab”: “00 12 * * 3,4,0”,
    “once”: false,
    “onceDelay”: 0.1,
    “x”: 110,
    “y”: 340,
    “wires”: [
    [
    “2f8ed8a3.db9a68”
    ]
    ]
    },
    {
    “id”: “8d990367.02bd3”,
    “type”: “change”,
    “z”: “c8594bdc.1ed9d8”,
    “name”: “”,
    “rules”: [
    {
    “t”: “set”,
    “p”: “alexa”,
    “pt”: “flow”,
    “to”: “payload”,
    “tot”: “msg”
    }
    ],
    “action”: “”,
    “property”: “”,
    “from”: “”,
    “to”: “”,
    “reg”: false,
    “x”: 480,
    “y”: 340,
    “wires”: [
    [
    “349f952d.0689fa”
    ]
    ]
    },
    {
    “id”: “349f952d.0689fa”,
    “type”: “debug”,
    “z”: “c8594bdc.1ed9d8”,
    “name”: “”,
    “active”: false,
    “tosidebar”: true,
    “console”: false,
    “tostatus”: false,
    “complete”: “false”,
    “x”: 680,
    “y”: 340,
    “wires”: []
    },
    {
    “id”: “acc03fc2.39c2a”,
    “type”: “inject”,
    “z”: “c8594bdc.1ed9d8”,
    “name”: “”,
    “topic”: “”,
    “payload”: “”,
    “payloadType”: “date”,
    “repeat”: “”,
    “crontab”: “”,
    “once”: false,
    “onceDelay”: 0.1,
    “x”: 160,
    “y”: 220,
    “wires”: [
    [
    “3ff3c45d.20249c”
    ]
    ]
    },
    {
    “id”: “3ff3c45d.20249c”,
    “type”: “alexa-remote-routine”,
    “z”: “c8594bdc.1ed9d8”,
    “name”: “”,
    “account”: “a30831e3.1d09”,
    “routineNode”: {
    “type”: “speak”,
    “payload”: {
    “type”: “regular”,
    “text”: {
    “type”: “str”,
    “value”: “this is a test”
    },
    “devices”: [
    “G090LF1073171DAP”
    ]
    }
    },
    “x”: 400,
    “y”: 140,
    “wires”: [
    []
    ]
    },
    {
    “id”: “a30831e3.1d09”,
    “type”: “alexa-remote-account”,
    “z”: “”,
    “name”: “Home”,
    “authMethod”: “proxy”,
    “proxyOwnIp”: “192.168.254.15”,
    “proxyPort”: “3456”,
    “cookieFile”: “”,
    “refreshInterval”: “3”,
    “alexaServiceHost”: “pitangui.amazon.com”,
    “amazonPage”: “amazon.com”,
    “acceptLanguage”: “en-US”,
    “userAgent”: “”,
    “useWsMqtt”: “on”,
    “autoInit”: “on”
    }
    ]

    1. Hi Terry – after changing the account to mine – and visiting my alexa account, all came up ready…. but on pressing that inject node – I got “Error: Response: input failed” again in the first node. Not having much luck here.

      1. I remember something similar to that when I tried “Speak at volume” instead of “Speak”. Don’t know what it means though or how else to sort it out unfortunately 🙁

    2. It’s probably something I’m doing wrong, or misunderstanding, but I can’t get this flow to import – I get an error of:

      SyntaxError: Unexpected token “ in JSON at position 4
      [↵{↵“id”: “c8594

      with the first “ being the one that’s causing a problem…

      1. If you are cutting and pasting its not unusual for windows to pick up the wrong quotation characters – try overtyping the offending ” with the keyboard and see if the error moves – if so you’ll have to do a global search and replace on that character.

    3. Thanks to Terri for sharing that patch, took a while for me to sort out changing the account, but finally, it worked, I was struggling to get the inject to work from the example patches so this is a great starting place for me, and if it does need that regular update, thanks for that bit as well, as a Node-red novice its great to see some functional stuff like that to help newbies to see what’s possible.

  4. This nodes collection is great. I just want to share a use I made of it.

    I have some difficulties making my 13 years old doughter get up in the morning. She hears alexa’s alarm, but once stopped she continues sleeping. To avoid that, what I did was this:

    At 1:00 AM I get the list of alarms she has set on her Echo Dot and for the first one I add three voice messages she hears, two, four and five minutes after the alarm sounds. The messages tell her something like: two minutes later: “It’s time to get up”, four minutes later: “Come on I you are hearing this message it’s to late, get up now” and five minutes later: ” Come on , get up immediatelly. Your dad is comming”. I use SSML to create some s between text. Each message has higher volume than previous.

    I use cronplus node to fire messages.

    If none of those messages work I have to get up to awake her ;).

  5. Was going to give this a go, but I can’t install any nodes, says there is a permission problem. Using a Mac OSX, searched the net and found giving permission to the /.node-red which I did and have previously. Not sure what else to do?

    2019-09-29T04:45:19.838Z [err] errno: -13,
    2019-09-29T04:45:19.838Z [err] npm
    2019-09-29T04:45:19.838Z [err] ERR! code: ‘EACCES’,
    2019-09-29T04:45:19.838Z [err] npm ERR!
    2019-09-29T04:45:19.838Z [err] syscall: ‘mkdir’,
    2019-09-29T04:45:19.838Z [err] npm
    2019-09-29T04:45:19.838Z [err] ERR! path: ‘/Users/scott/.npm/_cacache/index-v5/b2/d6’ }
    2019-09-29T04:45:19.839Z [err] npm ERR!
    2019-09-29T04:45:19.839Z [err] npm ERR! The operation was rejected by your operating system.
    2019-09-29T04:45:19.839Z [err] npm ERR! It is likely you do not have the permissions to access this file as the current user
    2019-09-29T04:45:19.839Z [err] npm ERR!
    2019-09-29T04:45:19.839Z [err] npm
    2019-09-29T04:45:19.839Z [err] ERR! If you believe this might be a permissions issue, please double-check the
    2019-09-29T04:45:19.839Z [err] npm ERR! permissions of the file and its containing directories, or try running
    2019-09-29T04:45:19.839Z [err] npm ERR!
    2019-09-29T04:45:19.839Z [err] the command again as root/Administrator (though this is not recommended).
    2019-09-29T04:45:19.855Z [err]
    2019-09-29T04:45:19.855Z [err] npm ERR! A complete log of this run can be found in:
    2019-09-29T04:45:19.855Z [err] npm
    2019-09-29T04:45:19.855Z [err] ERR! /Users/scott/.npm/_logs/2019-09-29T04_45_19_840Z-debug.log
    2019-09-29T04:45:19.861Z rc=243

  6. Some of the built in help in the collection of remote2 nodes is not very helpful. The IP address configured is actually the IP of the broker which may or may not be the machine node-red is running on. My goal is to use Alexa to query devices such as what is the humidity and temperature outside? (from my MQTT weather station) or is the garage door closed? and Alexa would answer appropriately. I found a forum with an excellent example for configuring remote2 to have Alexa speak the text contained in an MQTT payload. The example is at https://forums.homeseer.com/forum/homeseer-products-services/cloud-service-integrations/alexa-smart-home-skill/1320858-alexa-tts-that-works-better-imho-than-the-solution-for-home-assistant

    1. Got it working. Just had to do port forward on the container.
      It was quite quick then I expected to get Hello World working.

      I would say add the name of the file (security consideration). This stores the credentials so that every time you deploy, you do not have to go authenticate again.

      1. Hi, I’m having difficulty defining the file path to store the credentials. I’m running Node Red in a docker container using HASSIO.

                1. I faced exactly the same issue. In order to find out what path to use. What i did was create a basic text file in node red using the “file in” node. I used the basic path of / I then searched my file system for this file. I found my file was stored in /config/. Next i created an empty text file in /config/node-red/data/amazon.txt
                  I then set the node-red-alexa node to use this location.
                  Once you have logged in your should see the anazon.txt file update with the cookie info.
                  Oh yeah btw I am using the Node-Red add-on inside HASSIO / Home Assistant.

                  1. Arghh. I absolutely positively cannot find this file!! I have HA & NR running in Docker on a Synology DSM. I created a text file “alexa.txt” and placed it into my node-red data folder and have tried about every path possible… but keep getting the error “File not found.”
                    I have as my path /docker/hassio-02/homeassistant/node-red/alexa.txt and have tried everything removing one directory at a time and still nothing using the file in node and a timestamp inject node.
                    Since this is NR installed inside HA, I technically did not set up my own NR docker container.
                    Any ideas what the path should be?
                    Thanks guys

                    1. If it is the same principle as Node Red running under Home Assistant on Hassio then the file needs to be stored in the /share directory on your HA server so for me the full path is /share/alexa/auth and that is exacly what is entered in the Alexa Account Node config file path

                    2. Thanks for getting back in touch so quickly. I have the node-red config folder on a share inside the HA config folder but for the life of me cannot figure out the path. At this point I just cannot figure it out so I will move on. Love your blog

  7. I’m able to get the green “ready” on the AlexaRoutine node after using my server’s URL to retrieve the cookie. The problem I’m having (and had in earlier V3 releases) is that my AlexaRoutine node doesn’t allow me to change to a value other than “Speak” (there’s a dropdown, but when another value is selected, it doesn’t “stick”) AND I’m missing all the widgets below the Speak dropdown.

    Any suggestions?

    Node v10.15.3
    node-red-contrib-alexa-remote2 v3.2.8
    Node_RED v0.16.2.

      1. Yeah… I was afraid you might start with that. OK… I’ll give it an upgrade and then see where it takes me. Thanks, Peter.

        1. Be careful – updating to 0.20 is easy – avoid 1.00 as there was an issue with msg cloning – 1.01 is good so far but MAY require the odd node install – see node-red site and do an RPI-CLONE or similar first….

        2. Yep… I lost my UI along the way (restored my server to localhost) but it fixed the AlexaRoutine. And as a bonus, it compelled me to make the move up to v1.0.1 — so thanks, Peter 😉

    1. Thank you for that YouTube link.
      Yes this node is indeed awesome!
      The video pulled it all together for me.
      The examples all work great.
      Listening to the player now.

    2. I’ve been using this very useful module for a while but having implemented some system monitoring routines I have discovered that the this module is throwing an uncaught exception occasionally and forcing a node red restart. Not sure yet if it’s my implementation or not but node red and module are on latest versions – so if anyone else is getting unusual node red behaviour this may be the culprit

  8. Superb youTube presentation, so clearly explained. I was thinking about getting an Alexa or a Google device but no experience to base a choice on. However, I think that video has convince me Alexa is the way to go.

  9. I’m getting the error that says ‘Unexpected end of JSON input’ while I’m using proxy method.
    I get ‘Amazon Alexa Cookie successfully retrieved. You can close the browser.’ message okay when I log in on the browser.

    Any help would be appreciated.

      1. I believe Aidan is working on that APP. In time I’ll update the blog… right now I’m working on RPi4 USB Boot, Sonoff Zigbee and other stuff but I always get there eventually.

  10. hello everyone, I haven’t been able to update or initialize the amazon cookie for a day now, after logging in it gives me back a page where it says:
    Please Enable Cookies to Continue
    To continue shopping at Amazon.com, please enable cookies in your Web browser.

    Once you have enabled cookies in your browser, please click on the button below to return to the previous page.

    please help me

    1. I also struggled to get it running and I cannot login using the proxy either as amazon says I should enable cookies (which is actually already the case). I could solve it by switching to cookie authentification and geeting the cookie by logging into my account at pitangui.amazon.com (or your desired country server) and aquiring the cookie as described here: https://www.youtube.com/watch?v=Yg7dv4OOFAY (fast forward to 12:55). Hope that potentially helps, worked for me immediately even if other methods I googled on how to get the cookie did not work.

    2. I had this until I updated my nodes, in the palette look for the remote2 node and click on upgrade.

      Then the magic came back again.

      I know its probably a bit late for you, but this is hoping that it will save others like me a few hours!

  11. hey – I’ve found this blog super helpful in getting myself set up on NR. Though I’m stuck now. I have a number of input_booleans in HA that trigger my alexa devices (using Alexa Remote2). However, if/when I use alexa itself to control the devices the state of the input_booleans in HA do not change.

    Does anybody know of a way to check the state of my devices (in Alexa) and use that state to trigger a change in input_boolean state in HA?

  12. Hi – Using node-red-alexa-remote2, anyone know how to launch a skill and pass additional information to it?
    eg: I can use the Routine node to “Launch Skill”: “BBC”. But I want to get Node-Red to do the equivalent of “Ask the BBC to play Radio 4”. How do I pass “play Radio 4” to the BBC skill?

    1. Not a solution for the general issue of passing input to skills, but more a workaround for your specific example: Use one of the builtin music providers, TuneIn e.g. plays BBC4 perfectly well.

    2. PS: Looking at the source code, the “skill” function passes empty input, but at least passes input. Maybe it’s worth the try reaching out to the developer via his github, asking to provide a text field to pass that to Alexa.

Leave a Reply

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

Leave the field below empty!

This site uses Akismet to reduce spam. Learn how your comment data is processed.