Setting up node-red-contrib-alexa-home

I am trying to setup node-red-contrib-alexa-home (node) - Node-RED to get my devices accessible via alexa, but I am having a hell of a time trying to do it. It says in the documentation that

Alexa devices of generation #3 are not using the information used within the detection process. They do rely that all communication is done on port 80!

Which they go on to say that you can define an environment variable of ALEXA_PORT=80 or do ip tables stuff. But the issue is I believe port 80 is already bound to something:

tcp        0      0 127.0.0.1:8080          0.0.0.0:*               LISTEN      12761/containers-ro 
tcp        0      0 127.0.0.1:8091          0.0.0.0:*               LISTEN      11426/containers-ro 
tcp        0      0 127.0.0.1:1880          0.0.0.0:*               LISTEN      145287/containers-r 
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      3551/nginx: master  
tcp        0      0 10.10.2.1:1880          0.0.0.0:*               LISTEN      145287/containers-r 
tcp        0      0 0.0.0.0:18080           0.0.0.0:*               LISTEN      3551/nginx: master  
tcp6       0      0 :::8086                 :::*                    LISTEN      7942/containers-roo 
udp6       0      0 :::8089                 :::*                                7942/containers-roo 

So whenever try to deploy, it just crashes node red with this:

Dec 23 11:51:59.165792 Collective-Core conmon[144238]: 23 Dec 11:51:59 - [info] Started flows
Dec 23 11:51:59.329067 Collective-Core conmon[144238]: 23 Dec 11:51:59 - [red] Uncaught Exception:
Dec 23 11:51:59.330819 Collective-Core conmon[144238]: 23 Dec 11:51:59 - [error] Error: listen EACCES: permission denied 0.0.0.0:80
Dec 23 11:51:59.330868 Collective-Core conmon[144238]:     at Server.setupListenHandle [as _listen2] (node:net:1355:21)
Dec 23 11:51:59.330889 Collective-Core conmon[144238]:     at listenInCluster (node:net:1420:12)
Dec 23 11:51:59.330910 Collective-Core conmon[144238]:     at doListen (node:net:1559:7)
Dec 23 11:51:59.330927 Collective-Core conmon[144238]:     at processTicksAndRejections (node:internal/process/task_queues:84:21)
Dec 23 11:51:59.631550 Collective-Core podman[144447]: 2022-12-23 11:51:59.631387593 -0800 PST m=+0.151945109 container died 3c8069a63da0df821aa1a6849c8bbe6031b0d2bb1d4cc4d0544f8c4ad55b2a84 (image=container.oh-lalabs.com/oh-lalabs/node-red:3, name=oll-node-red)
Dec 23 11:51:59.792350 Collective-Core podman[144447]: 2022-12-23 11:51:59.791966932 -0800 PST m=+0.312524406 container remove 3c8069a63da0df821aa1a6849c8bbe6031b0d2bb1d4cc4d0544f8c4ad55b2a84 (image=container.oh-lalabs.com/oh-lalabs/node-red:3, name=oll-node-red, org.label-schema.description=Low-code programming for event-driven applications., org.label-schema.vcs-ref=, org.label-schema.arch=arm64v8, org.label-schema.docker.dockerfile=.docker/Dockerfile.marjebian, org.label-schema.license=Apache-2.0, org.label-schema.name=Node-RED, org.label-schema.vcs-type=Git, PODMAN_SYSTEMD_UNIT=podman-oll-node-red.service, org.label-schema.version=, org.label-schema.url=https://nodered.org, org.label-schema.vcs-url=https://github.com/node-red/node-red-docker, org.label-schema.build-date=2022-08-20T15:52:24Z)
Dec 23 11:51:59.808863 Collective-Core systemd[1]: podman-oll-node-red.service: Main process exited, code=exited, status=1/FAILURE
Dec 23 11:51:59.986248 Collective-Core oll-node-red[144462]: Error: no arguments are needed with --latest or --cidfile
Dec 23 11:51:59.993834 Collective-Core systemd[1]: podman-oll-node-red.service: Control process exited, code=exited, status=125/n/a
Dec 23 11:51:59.994406 Collective-Core systemd[1]: podman-oll-node-red.service: Failed with result 'exit-code'.
Dec 23 11:51:59.996447 Collective-Core systemd[1]: podman-oll-node-red.service: Consumed 9.204s CPU time.

I can’t seem to wrap my head around what I need to do as far as networking setup. Any ideas?

P.S. There is also this description in the NR documenation for the controller node which talks about a UDP port of 1900, which I assume I will also have to redirect, but I am not sure:

<p>
This node is setting up the controller node for alexa interaction. It starts a SSDP Service on Port 1900/udp and is also able to start a seperate webserver on the configured port.
But it is also possible to use node-red as webserver and donot start a second webserver.
</p>
<p>
    Be aware that alexa requires a response server running on port 80!
</p>

The way to do it when NR is inside a container would be to add a portmap from 80 to 6000. On CORE that is done inside /home/core-services/data/node-red/oll-node-red.conf using the PORT_MAP variable.

Same goes for UDP port 1900, that is also something which would need a PORT_MAP variable set.

The issue with port 80 is that, as you’ve discovered, it is in use on CORE, but it is something which could be potentially disabled. To make that “easy” it would need to be separated from the current defaults for nginx, that is actually a good idea to do and I will do so for the next update.

At the moment you’d have to comment out the first section about port 80 in this file: /etc/nginx/sites-available/default

Then run sudo systemctl reload nginx

That change will be overwritten during an update however, so it would just be until next time you run update.

Once that update is out, it would be a matter of deleting a symlink and reloading nginx.

EDIT: I made a change and pushed it, you can now just delete /etc/nginx/sites-enabled/default-port80 and then restart nginx

So I ran an update, deleted /etc/nginx/sites-enabled/default-port80, reloaded nginx, restarted nginx, but nginx still seems to be holding onto the port:

oh-la@Collective-Core:~$ sudo netstat -tunlp | grep 80
tcp        0      0 127.0.0.2:80            0.0.0.0:*               LISTEN      253664/nginx: maste
tcp        0      0 127.0.0.1:8080          0.0.0.0:*               LISTEN      12761/containers-ro
tcp        0      0 127.0.0.1:8091          0.0.0.0:*               LISTEN      246350/containers-r
tcp        0      0 127.0.0.1:1880          0.0.0.0:*               LISTEN      145287/containers-r
tcp        0      0 10.10.2.1:1880          0.0.0.0:*               LISTEN      145287/containers-r
tcp        0      0 0.0.0.0:18080           0.0.0.0:*               LISTEN      253664/nginx: maste
tcp6       0      0 :::8086                 :::*                    LISTEN      7942/containers-roo
udp6       0      0 :::8089                 :::*                                7942/containers-roo

This right? PORT_MAP+=("0.0.0.0:1900:1900/udp")

This right? PORT_MAP+=("0.0.0.0:6000:80")

Do you think this is necessary as well?
ENV_MAP+=("ALEXA_PORT=80")

P.S. This might be a good example to have commented out, or just false in the node-red config file:
ENV_MAP+=("NODE_RED_ENABLE_SAFE_MODE=true") Saved me today because it was stuck in a boot loop.

Only on 127.0.0.2:80, that is an internal use thing, nothing to worry about.

Probably better to do it like this:

PORT_MAP+=("core_ip_here:1900:1900/udp")

And for port 80:

PORT_MAP+=("core_ip_here:80:6000")

Do not set ALEX_PORT=80, you’re using the portmap instead.

Those files are auto-generated based on the defaults for each service, but yes, adding it to be false by default may be a good idea.

1 Like

So this is what I have in my config:

Dec 23 18:32:31.331454 Collective-Core oll-node-red[264169]: ---- CONFIG OVERRIDES START ----
Dec 23 18:32:31.337382 Collective-Core oll-node-red[264169]: PORT_MAP+=("0.0.0.0:3456:3456")
Dec 23 18:32:31.337382 Collective-Core oll-node-red[264169]: PORT_MAP+=("0.0.0.0:4567:4567")
Dec 23 18:32:31.337382 Collective-Core oll-node-red[264169]: PORT_MAP+=("192.168.2.242:80:6000")
Dec 23 18:32:31.337382 Collective-Core oll-node-red[264169]: PORT_MAP+=("192.168.2.242:1900:1900/udp")
Dec 23 18:32:31.337382 Collective-Core oll-node-red[264169]: ENV_MAP+=("NODE_RED_ENABLE_SAFE_MODE=true")

But it still seems to be yelling at me:

Dec 23 18:31:57.517984 Collective-Core conmon[263259]: 23 Dec 18:31:57 - [error] Error: listen EACCES: permission denied 0.0.0.0:80
Dec 23 18:31:57.518033 Collective-Core conmon[263259]:     at Server.setupListenHandle [as _listen2] (node:net:1355:21)
Dec 23 18:31:57.518053 Collective-Core conmon[263259]:     at listenInCluster (node:net:1420:12)
Dec 23 18:31:57.518071 Collective-Core conmon[263259]:     at doListen (node:net:1559:7)
Dec 23 18:31:57.518089 Collective-Core conmon[263259]:     at processTicksAndRejections (node:internal/process/task_queues:84:21)
Dec 23 18:31:57.855394 Collective-Core podman[263737]: 2022-12-23 18:31:57.853897491 -0800 PST m=+0.202482435 container died 010743a77d9d9efbf3fba55a11144b7cc359fdcc299b07e29aa8553ea016724c (image=container.oh-lalabs.com/oh-lalabs/node-red:3, name=oll-node-red)
Dec 23 18:31:58.038739 Collective-Core podman[263737]: 2022-12-23 18:31:58.038434313 -0800 PST m=+0.387018882 container remove 010743a77d9d9efbf3fba55a11144b7cc359fdcc299b07e29aa8553ea016724c (image=container.oh-lalabs.com/oh-lalabs/node-red:3, name=oll-node-red, org.label-schema.license=Apache-2.0, org.label-schema.url=https://nodered.org, org.label-schema.build-date=2022-08-20T15:52:24Z, org.label-schema.description=Low-code programming for event-driven applications., org.label-schema.docker.dockerfile=.docker/Dockerfile.marjebian, org.label-schema.name=Node-RED, org.label-schema.vcs-ref=, org.label-schema.vcs-type=Git, org.label-schema.version=, PODMAN_SYSTEMD_UNIT=podman-oll-node-red.service, org.label-schema.arch=arm64v8, org.label-schema.vcs-url=https://github.com/node-red/node-red-docker)
Dec 23 18:31:58.056900 Collective-Core systemd[1]: podman-oll-node-red.service: Main process exited, code=exited, status=1/FAILURE
Dec 23 18:31:58.278968 Collective-Core oll-node-red[263758]: Error: no arguments are needed with --latest or --cidfile
Dec 23 18:31:58.288852 Collective-Core systemd[1]: podman-oll-node-red.service: Control process exited, code=exited, status=125/n/a
Dec 23 18:31:58.289547 Collective-Core systemd[1]: podman-oll-node-red.service: Failed with result 'exit-code'.
Dec 23 18:31:58.292048 Collective-Core systemd[1]: podman-oll-node-red.service: Consumed 12.702s CPU time.

This is the default setup I have for the controller node:
image

set the port to 6000, you’re forwarding to that port from port 80 on the host.

image
Still doesn’t like it.


Dec 23 18:36:46.951311 Collective-Core conmon[264920]: 23 Dec 18:36:46 - [info] Stopped modified nodes
Dec 23 18:36:47.003176 Collective-Core conmon[264920]: 23 Dec 18:36:47 - [info] Updated flows
Dec 23 18:36:47.405699 Collective-Core conmon[264920]: 23 Dec 18:36:47 - [info] Starting modified nodes
Dec 23 18:36:47.411573 Collective-Core conmon[264920]: 23 Dec 18:36:47 - [info] [alexa-home-controller:Alexa Controller] 0 - alexa-home - Starting SSDP
Dec 23 18:36:47.476206 Collective-Core conmon[264920]: 23 Dec 18:36:47 - [info] [alexa-home-controller:Alexa Controller] 0 - announcing location is [object Object]
Dec 23 18:36:47.483910 Collective-Core conmon[264920]: 23 Dec 18:36:47 - [info] Assigning alexa-home nodes to this controller
Dec 23 18:36:47.524686 Collective-Core conmon[264920]: 23 Dec 18:36:47 - [info] Started modified nodes
Dec 23 18:36:47.533282 Collective-Core conmon[264920]: 23 Dec 18:36:47 - [red] Uncaught Exception:
Dec 23 18:36:47.534561 Collective-Core conmon[264920]: 23 Dec 18:36:47 - [error] Error: listen EACCES: permission denied 0.0.0.0:80
Dec 23 18:36:47.534600 Collective-Core conmon[264920]:     at Server.setupListenHandle [as _listen2] (node:net:1355:21)
Dec 23 18:36:47.534622 Collective-Core conmon[264920]:     at listenInCluster (node:net:1420:12)
Dec 23 18:36:47.534644 Collective-Core conmon[264920]:     at doListen (node:net:1559:7)
Dec 23 18:36:47.534660 Collective-Core conmon[264920]:     at processTicksAndRejections (node:internal/process/task_queues:84:21)
Dec 23 18:36:47.988929 Collective-Core podman[267245]: 2022-12-23 18:36:47.988666908 -0800 PST m=+0.171194491 container died c0fce4633a9218cb79ff422b478daa190283c4bf2ca4a2ea62a5b8cd89cb2911 (image=container.oh-lalabs.com/oh-lalabs/node-red:3, name=oll-node-red)
Dec 23 18:36:48.143802 Collective-Core podman[267245]: 2022-12-23 18:36:48.143315282 -0800 PST m=+0.325842574 container remove c0fce4633a9218cb79ff422b478daa190283c4bf2ca4a2ea62a5b8cd89cb2911 (image=container.oh-lalabs.com/oh-lalabs/node-red:3, name=oll-node-red, org.label-schema.arch=arm64v8, org.label-schema.build-date=2022-08-20T15:52:24Z, org.label-schema.vcs-url=https://github.com/node-red/node-red-docker, org.label-schema.version=, PODMAN_SYSTEMD_UNIT=podman-oll-node-red.service, org.label-schema.vcs-type=Git, org.label-schema.docker.dockerfile=.docker/Dockerfile.marjebian, org.label-schema.url=https://nodered.org, org.label-schema.description=Low-code programming for event-driven applications., org.label-schema.license=Apache-2.0, org.label-schema.name=Node-RED, org.label-schema.vcs-ref=)
Dec 23 18:36:48.160836 Collective-Core systemd[1]: podman-oll-node-red.service: Main process exited, code=exited, status=1/FAILURE
Dec 23 18:36:48.352330 Collective-Core oll-node-red[267267]: Error: no arguments are needed with --latest or --cidfile
Dec 23 18:36:48.358546 Collective-Core systemd[1]: podman-oll-node-red.service: Control process exited, code=exited, status=125/n/a
Dec 23 18:36:48.359095 Collective-Core systemd[1]: podman-oll-node-red.service: Failed with result 'exit-code'.
Dec 23 18:36:48.361304 Collective-Core systemd[1]: podman-oll-node-red.service: Consumed 9.886s CPU time.
Dec 23 18:37:18.383517 Collective-Core systemd[1]: podman-oll-node-red.service: Scheduled restart job, restart counter is at 2.
Dec 23 18:37:18.384877 Collective-Core systemd[1]: Stopped Node-RED in Podman (CORE).
Dec 23 18:37:18.385093 Collective-Core systemd[1]: podman-oll-node-red.service: Consumed 9.886s CPU time.

Try setting: ALEXA_PORT=6000

I don’t know this palette, but may be worth a try, if that doesn’t work I’ll go have a look at the sourcecode.

1 Like

I appreciate that, I currently am using node-red-contrib-virtual-smart-home (node) - Node-RED but they have moved to a paid model, and I wanted to look around first before buying that, and these nodes looked interesting since they apparently are local and not reliant on a skill.

Edit: Bingo that did it, well at least it didn’t crash, now to see if the devices actually are found and work.

Edit 2: NR did not crash, but also device discovery is not working…hmmm

Did you disable the safe mode?

EDIT: Could be worth also adding:

PORT_MAP+=("core_ip_here:6000:6000")

In case the device do listen to what is sent as the actual port.

No, but my understanding safe mode just disables the first deploy, so you can manually go in change some stuff and then deploy once it is fixed. My other automations like lights are working, so I assume NR is working as normal.

I also tried injecting some on and off commands to the device to see if I can “wake” it up, but no luck.

Some interesting logs for NR:

Dec 23 18:58:58.799151 Collective-Core conmon[272442]: 23 Dec 18:58:58 - [info] [alexa-home-controller:Alexa Controller] Request data: 10.0.2.100-6000/POST -> /pods/direct/node-red/pods/direct/node-red/webhook-alt/hubitat
Dec 23 18:58:58.809901 Collective-Core conmon[272442]: 23 Dec 18:58:58 - [info] [alexa-home-controller:Alexa Controller] Request data: 10.0.2.100-6000/POST -> /pods/direct/node-red/pods/direct/node-red/webhook-alt/hubitat

What is the hubitat webhook doing there?

Are you running webhooks on port 80? That is what was there in nginx before you disabled it. You can use port 81 for that instead, just enable service_node-red-webhook.conf in /etc/nginx/services-enabled-port81:

ln -s ../services-available/service_node-red-webhook.conf /etc/nginx/services-enabled-port81/service_node-red-webhook.conf

and reload nginx, then switch to using port 81 for those webhooks.


But I have the use websocket option enabled.

Found another set of nodes that appears to be using a similar method, but they have better documentation, currently making my way through it, but figured I would post it here:

Seems they’re not really listening to that setting then, see if you can change the webhook option to use port 81 and at least that part would be sorted.

I see, it’s using multicast, you would have to run in host mode, there’s a hidden setting for that, check /lib/oll/native/homebridge/lib/custom-settings.sh

This could cause other issues, with port-conflicts, but worth a try.

Yeah this is beginning to sound like a 2023 problem haha. Or maybe just use Hubitat as my alexa hub until CORE gets that feature. Not sure yet.

just add that setting to the node-red config you put the port maps in.

It looks like the option is REDACTED, would that be added via ENV_MAP+=("REDACTED")?

no, just added directly, not to env_map

1 Like

Curious why that option is so special, is it a potential vector for attack or something?

yes, it is, if your network is secure and you don’t port-forward to CORE it’s fine though, even if you do portforward to core the firewall is there to stop packets originating from outside your LAN, but still. It is also an option that if you would for example run it on two containers which use the same port, you would have a conflict.

1 Like