datech / node-red-contrib-amazon-echo

Alexa controlled Node-Red nodes supporting latest Amazon Echo devices. NO Alexa Skills required. NO cloud dependencies.
MIT License
137 stars 43 forks source link

Alexa App Unable to Discover Node-Red Hub #139

Open locke4 opened 3 years ago

locke4 commented 3 years ago

Summary:

After adding the npm package node-red-contrib-amazon-echo, and following the setup instructions, as well as going through the applicable troubleshooting on the Wiki, I'm still unable to discover the hub. I'm able to access 192.168.0.21:80/api/description.xml, which is the server I am running node-red on. The description.xml returns the device name that is in my flow.

Devices:

  1. Alexa Android App - Using Device Discovery as well as audio command "Alexa, discover new devices"
  2. CentOS 7 virtual machine running node-red (not docker as some of the other issues seem to relate to this configuration)
  3. Windows 10 PC running node-red during my troubleshooting, same issue

Node-Red debug logging

[root@ANSON ~]# node-red
25 Jul 21:38:06 - [info]

Welcome to Node-RED
===================

25 Jul 21:38:06 - [info] Node-RED version: v1.1.2
25 Jul 21:38:06 - [info] Node.js  version: v14.6.0
25 Jul 21:38:06 - [info] Linux 3.10.0-1127.el7.x86_64 x64 LE
25 Jul 21:38:06 - [info] Loading palette nodes
25 Jul 21:38:08 - [warn] Missing node modules:
25 Jul 21:38:08 - [warn]  - node-red-contrib-alexa-local (0.3.24): alexa-local
25 Jul 21:38:08 - [info] Removing modules from config
25 Jul 21:38:08 - [info] Settings file  : /root/.node-red/settings.js
25 Jul 21:38:08 - [info] Context store  : 'default' [module=memory]
25 Jul 21:38:08 - [info] User directory : /root/.node-red
25 Jul 21:38:08 - [warn] Projects disabled : editorTheme.projects.enabled=false
25 Jul 21:38:08 - [info] Flows file     : /root/.node-red/flows_ANSON.json
25 Jul 21:38:08 - [warn]

---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------

25 Jul 21:38:08 - [info] Starting flows
  node-ssdp:server discovering all IPs from interface lo +0ms
  node-ssdp:server discovering all IPs from interface enp0s3 +1ms
  node-ssdp:server Will use interface enp0s3 +0ms
25 Jul 21:38:08 - [info] Started flows
  node-ssdp:server SSDP listening: { address: 'http://0.0.0.0:1900', interface: '192.168.0.21' } +239ms
25 Jul 21:38:08 - [info] Server now running at http://127.0.0.1:1880/
25 Jul 21:38:08 - [info] [mqtt-broker:909c3b6c.3fc918] Connected to broker: mqtt://192.168.0.19:1883
  node-ssdp:server Sending an advertisement event +3s
  node-ssdp:server Setting LOCATION header "http://192.168.0.21:80/description.xml" on message ID 0720b8ddc86747be +1ms
  node-ssdp:server Sending a message to 239.255.255.250:1900 +2ms
  node-ssdp:server Sending an advertisement event +2ms
  node-ssdp:server Setting LOCATION header "http://192.168.0.21:80/description.xml" on message ID 1a04eae8c931faeb +0ms
  node-ssdp:server Sending a message to 239.255.255.250:1900 +0ms
  node-ssdp:server Sending an advertisement event +1ms
  node-ssdp:server Setting LOCATION header "http://192.168.0.21:80/description.xml" on message ID 7e5b3b689398f6bf +0ms
  node-ssdp:server Sending a message to 239.255.255.250:1900 +1ms
  node-ssdp:server Outgoing server message: { message: 'NOTIFY * HTTP/1.1\r\n' + 'HOST: 239.255.255.250:1900\r\n' + 'NT: upnp:rootdevice\r\n' + 'NTS: ssdp:alive\r\n' + 'USN: uuid:00112233-4455-6677-8899-60be5a8449c344::upnp:rootdevice\r\n' + 'CACHE-CONTROL: max-age=1800\r\n' + 'SERVER: node.js/14.6.0 UPnP/1.1 node-ssdp/4.0.0\r\n' + '\r\n', id: '0720b8ddc86747be' } +4ms

Description.xml:

image

Node-Red flow

[{"id":"d7ef8621.922dc8","type":"tab","label":"Send NRF24L01","disabled":false,"info":"Send data to NRF24L01 topic"},{"id":"cbcade4e.b0b5f","type":"mqtt out","z":"d7ef8621.922dc8","name":"","topic":"","qos":"","retain":"","broker":"909c3b6c.3fc918","x":710,"y":200,"wires":[]},{"id":"787ec2b0.536c9c","type":"inject","z":"d7ef8621.922dc8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"10","crontab":"","once":true,"onceDelay":0.1,"topic":"nrf24l01/bedroomlight","payload":"off","payloadType":"str","x":390,"y":200,"wires":[[]]},{"id":"fc017a21.0ebc58","type":"inject","z":"d7ef8621.922dc8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"10","crontab":"","once":true,"onceDelay":"20","topic":"nrf24l01/bedroomlight","payload":"on","payloadType":"str","x":320,"y":260,"wires":[[]]},{"id":"a4446a01.a73198","type":"debug","z":"d7ef8621.922dc8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":830,"y":340,"wires":[]},{"id":"6bc8ba79.f212b4","type":"mqtt in","z":"d7ef8621.922dc8","name":"","topic":"nrf24l01/bedroomlight","qos":"2","datatype":"auto","broker":"909c3b6c.3fc918","x":580,"y":340,"wires":[["a4446a01.a73198"]]},{"id":"60be5a84.49c344","type":"amazon-echo-hub","z":"d7ef8621.922dc8","port":"80","processinput":0,"discovery":true,"x":250,"y":100,"wires":[["4a9011f9.b8e65"]]},{"id":"4a9011f9.b8e65","type":"amazon-echo-device","z":"d7ef8621.922dc8","name":"Bedroom Light","topic":"nrf24l01/bedroomlight","x":490,"y":80,"wires":[["cbcade4e.b0b5f"]]},{"id":"909c3b6c.3fc918","type":"mqtt-broker","z":"","name":"","broker":"192.168.0.19","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

Is there anything I've missed? I've gone through many of the issues with these and unfortunately I have struggled to find one that matches my exact setup. I'm running node-red as root, and am able to access the description.xml from all devices on my network (mobile phone running Alexa app, my PC, etc.). I can run Wireshark on my network but I wasn't able to identify the filters to show only Alexa App related traffic.

Any advice would be greatly appreciated!

Barabba11 commented 3 years ago

Seems it's a common issue for whom running NR with root permissions. NR stuff recommend to install without root

locke4 commented 3 years ago

Just updating, I've nuked and reinstalled Node-red, NodeJS and NPM all without installing under root permissions.

I'm now running node-red without root permissions, which as expected doesn't allow it to bind to port 80. I haven't yet bound port 80 to the app directly, but running node-red with sudo (as before) doesn't change anything.

Barabba11 commented 3 years ago

please follow what they clearly reccomend, do not run node red with sudo and do not install it as root, in both cases I suppose it uses different path. Simply start node red with the line node-red-start. I hope you didn't install modules when you run node red with sudo, in that case if it still not working I recomend you to nuke again. Do the nat of port 80 as we did too

locke4 commented 3 years ago

Just confirming, I have not run node-red with sudo and I have not installed it as root. I also have not installed any packages through node red, all of them managed through npm. I will try the NAT of port 80 later today

Barabba11 commented 3 years ago

You need the NAT on port 80, else it will not work. Without root you can't open a port lower than 1024, and you need 80.

juampe commented 3 years ago

Same issue using docker with node setcap to use port 80 with nodered user and macvlan to use own IP

UPDATE: Ok I found the problem and it is realated to a malfunctioning switch with a bad IGMP Snooping implementation, that causes deny unicast/multicast from Wifi Acces Point ethernet port I disabled IGMP Snopping from the switch and Alexa can found my devices. Thanks!

Dockerfile

FROM nodered/node-red:latest USER root RUN setcap 'cap_net_bind_service=+ep' $(eval readlink -f which node) USER node-red COPY package.json . RUN npm install --unsafe-perm --no-update-notifier --no-fund --only=production

Run fixed nodered

docker build . -t juampe/node-red
docker run  --init -d --restart=always --network=macvlannet --ip 192.168.0.129 --dns 192.168.0.1 --hostname="nodered" --name="nodered" -v /opt/docker/nodered/data:/data  -e NODE_RED_ENABLE_SAFE_MODE=false -e DEBUG="node-ssdp:*" juampe/node-red:latest

From other host in the same net SSPD seems to respond to multicast (upnp UDP 1900)

gssdp-discover -i br0 --timeout=5
resource available
  USN:      uuid:00112233-4455-6677-8899-cd272225bd01a8::upnp:rootdevice
  Location: http://192.168.0.129:80/description.xml
resource available
  USN:      uuid:00112233-4455-6677-8899-cd272225bd01a8::urn:schemas-upnp-org:device:basic:1
  Location: http://192.168.0.129:80/description.xml
resource available
  USN:      uuid:00112233-4455-6677-8899-cd272225bd01a8
  Location: http://192.168.0.129:80/description.xml


"Alexa please search new devices" seems not work to find the hub
Barabba11 commented 3 years ago

Glad you solved this tricky problem, @datech it would be useful I guess to put this solution on troubleshooter too

rodrigoroma commented 3 years ago

Were you able to discover node red devices without an Echo device, just using the Alexa Android app?

My situation is very similar to yours, I can open description.xml successfully, but Alexa app doesn't find any devices. I'm not sure if not having any Echo devices in my network could by the root problem.

simeon-walker commented 2 years ago

Same issue using docker with node setcap to use port 80 with nodered user and macvlan to use own IP

UPDATE: Ok I found the problem and it is realated to a malfunctioning switch with a bad IGMP Snooping implementation, that causes deny unicast/multicast from Wifi Acces Point ethernet port I disabled IGMP Snopping from the switch and Alexa can found my devices. Thanks!

Thank you for this, it may have been my issue too.

I have NR setup in Docker with its own IP address, listening on port 80. Occasionally the Echo Dot would pickup new devices but it was unreliable so I never got past the testing phase. The first 'discover devices' after completely disabling IGMP snooping on my switch and several new devices were found (some from my existing ZigBee gateway).