node-RED for connecting Amazon Echo-devices to openHAB

You could either find a location, which the container can write to (C:/nodered is of course the directory on the host and the container knows nothing about that!) - or just simply leave it empty and the node will just use a default /tmp.

works with me so far. (german Amazon)

I did not find a readme/howto/… for the node. how did you find out, what variables are possible for the “Alexa Routine” node?
I’d like to add a “Speak at Volume”, which one can chose in the node itself. currently I’m doing a three-call: change volume - speak - revert volume. Speak At Volume would be cheaper with the API-calls.
and I’d like to add some more like DoNotDisturb mode and others…

I seem to have 2 problems: storage location for the cookie and authentication using http://localhost:5678 ? Also many settings within the account cards which i might not use right?

If you’re running docker, you must expose the Port you type in in the configuration accordingly in the container. Either use “host” as network mode or simply add “5678:5678” in the ports part of your docker-compose.xml.

If you’re using the german alexa-enpdoint, then you don’t have to change anything on the card - except “This IP” and an correct/empty “File Path”.
If you’re using any other country/language settings, please check in the docs of the Node-Red node: bbindreiter/node-red-contrib-alexa-remote2-applestrudel: Node-Red Nodes for interacting with Alexa

I apologize but i can’t follow. I need some step by step description. Have looked into the docs without success.

I double-click on “Fresh authentication”:

The this window opens:

What are the right settings here? If i use the port 1880 which is defined for nodered in my docker-compose.yml, i get “this port is already used”. Sorry, but i have a lack of basic understanding of this auth method :frowning: .

Nope, there is nothing to click :innocent:
If you want a fresh authentication, you need to click on the square button left to “Inject”.

But before doing that, just watch the url below the “Fresh Authentication”: it says, open http://…
Open that in your browser and you will be prompted to add your username, password and 2FA for Amazon.
THAT is the authentication.

1 Like

Thanks for this hint. But i cannot open the URL which is shown. “ERR connection refused”.

It needs to be the url for your node-red container (same as in the amazon account setup), but I have no knowledge about Docker or openHAB on Windows to solve this, sorry.

Edit: The ip adress you have to use is not your openHAB instance, but your node-red instance. Connection to openHAB is made through the MQTT broker.

1 Like

Okay, i give up for today and hope for tomorrow :-). If i use the nodered url and port (1880), i get “port already in use”.

Double check Thomas post above:

Apart from that, I cannot help with Docker …

1 Like

oh. thing is you’ll have to learn docker and node-red…
as you started your container you had to fill in some “configuration” for it. So you add just some more:

services:
  nodered2:
    image: nodered/node-red:latest
    container_name: node-red2
    environment:
      NODE_RED_CREDENTIAL_SECRET: ${NODE_RED_CREDENTIAL_SECRET}
      TZ: ${TZ}
    volumes:
      - /Files/AppData/Config/NodeRed2:/data
    ports:
      - 1880:1880
      - 5678:5678 #THIS HERE!
    restart: unless-stopped

that tells docker while spining up the container to open port 5678 in the container and map it to port 5678 on the host. now you should be able to open the URL (either http://localhost:5678 if your physically also on that windows machine - or http://192.168.1.137:5678 if you’re remote).
for more:

THEN in your Node-Red there’s “nodes”, which are connected. if you click on the rectancle of the “inject”-node it will trigger and pass over infomation to the next connected node “Fresh Authentication”. same with all other nodes. the MQTT-IN node waits for payloads for a specific topic (or more).
for more:

2 Likes

Gave it a try but nothing changed. Will try tomorrow and see if the docs will light me.

Just check the dropdown of the Alexa_routine node. There’s a speak_at_volume too. I didn’t use that because I wanted to stay as close to the binding as possible.

yes, but that does not tell me, what arguments and variables there are?
I found out, that at least it’s

msg.payload = {
    type: 'speakAtVolume', // camelcase it is (took me like 3 tries)! ;)
    payload: {
        type: 'regular',
        text: String(pl),
        volume: 70,        // could also be a variable
        devices: [serialNumber]
    }
};

but I’m still looking for a docu on what the arguments are named?

don’t think there’s any. The code in github is

case 'speakAtVolume': {
						if (!Array.isArray(node.payload.devices)) {
							const single = node.payload.devices || node.payload.device;
							node.payload.devices = single ? [single] : [];
						}
						checkPayload({ type: '', text: '', /*mode: '',*/ volume: undefined });
					

the general Echo devices are recognized and are working but I’m struggling with my sonos devices with build in alexa! Is there a filter i can use to make them visible?

thanks a lot @Larsen for sharing, speak and lastVoiceCommand are working now for me!

I still have an issue with start routine (i must say I’m not very familiar with node-red).

I get the following error: "could not find device: "undefined""

What I found out so far: In line 69 I need to change from routineName to routine in the payload, according to the documentation.

So, I tried:

type: 'routine',

            payload: { 

                routine: String(pl),

                devices: [serialNumber]

            }

but this still doesn’t work.

Put a debug node before the filter and check the deviceFamily in the log.

Currently I filter only ECHO (Echo Dot, Plus…) and KNIGHT (Echo Show). AI says Sonos is named SPEAKER, can you confirm?

I forgot to test that :grimacing:. I’m going to look at it this evening.

Currently, I have Alexa with the OpenHAB skill to control devices from Alexa, and on the other hand, the Amazon binding to retrieve voice commands, send messages to Les Echos, launch radio stations, and run routines. Everything is managed by rules in OpenHAB. I’ve heard about Node-RED on the forum, but I don’t know what it is or how it works, and I’m not a developer but self-taught and not always comfortable with the terminology used on the forum. So, I need some guidance to set up this new integration or a link to tutorials that explain the process when starting from scratch.

Does this require a specific skill? Is it done via a specific cloud? Etc…