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
140 stars 42 forks source link

Still unable to discover new devices #144

Open gobigdave opened 3 years ago

gobigdave commented 3 years ago
SUMMARY

Recently got an Echo Dot g3. I have HA installed on a Pi, with NodeRed as an Add-On. My Pi is on my main LAN (vlan 1). My Echo Dot is on my IoT vlan (vlan 10). I have confirmed that both can talk to each other, and I successfully access the hub with:

curl http://192.168.1.xx/api/pi/lights

This works from both the LAN and IoT subnets.

When I ask Alexa to discover devices, nothing is ever found.

I have a Unifi USG, and multicast DNS and UPnP are both on.

ECHO DEVICES

Echo Dot 3rd generation

MODULE VERSION
CONFIGURATION
0.1.10
CONSOLE OUTPUT
None
STEPS TO REPRODUCE
  1. Create Amazon Echo Hub with all defaults
  2. Create "Office Lights" echo device and link to hub
  3. Deploy
  4. Verify that /api/pi/lights is returning Office Lights info from LAN and IoT
  5. "Alexa, discover devices" - try from Dot on the IoT and iOS app which is on the LAN.

My Office Lights device is never discovered.

EXPECTED RESULTS

Expected my Office Lights device to be discovered.

ACTUAL RESULTS

Alexa declares that no devices were found.

jmorris644 commented 3 years ago

I have the exact same issue. And an almost identical network setup. My UPnP was not turned on so I did that. Although Alexa has been able to discover all of my other devices with it turned off. Even across VLANs.

I can also curl from the main LAN and the VLANs.

I did some additional testing:

  1. I changed the port that the echo hub node was listening on to avoid a port conflict.
  2. I then add a tcp input node for port 80 and connected it to a debug node. When I did the curl I saw it come in on port 80.
  3. I then did a discover from the Alexa app and did not see anything coming in on port 80.
  4. I then told one of my Alexa devices to discover and again nothing appeared.

My research will continue and I will report back any new findings.

@gobigdave did you get it working?

gobigdave commented 3 years ago

I have not got it working yet. I don’t see any traffic coming in on port 80 either, but like you, the Echo discovers other devices even on different VLANs. Only thing I can think of is something in iptables or Docker that is preventing the multicast discovery traffic from getting through to the Pi. That has to happen before the Echo knows to query http://[home_assistant_ip]/api/description.xml. I’ve been experimenting with a lot of iptables fun, but still no dice. Wonder if it’s something about the Pi OS?

datech commented 3 years ago

It looks like SSDP traffic is not transferred.

I just want to remind you that you have to set the container to use the host network, if Node-Red is running on Docker.

gobigdave commented 3 years ago

I’m pretty sure HA addons are installed using host networking, but I will verify again.

jmorris644 commented 3 years ago

It looks like SSDP traffic is not transferred.

I just want to remind you that you have to set the container to use the host network, if Node-Red is running on Docker.

I did. I am using Docker but not HA at the moment. I just installed IOTstack. IN addition to telling the container to use host network I also had to open up ports 80 and 1880.

gobigdave commented 3 years ago

When running as an add on from HA, NodeRed uses host networking mode.

Barabba11 commented 3 years ago

it would be better to write a guide about docker and put it on troubleshooting..

jmorris644 commented 3 years ago

I have been trying some iptable stuff too.

Other people got versions of these commands to work. I have not. (yes, I changed the echo node to 8980)

sudo iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT
sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8980
gobigdave commented 3 years ago

I tried something similar, but no luck. I’m pretty sure the issue is the SSDP traffic isn’t making it properly, so discovery never makes it to the point where port 80 or 8980 is accessed.

jmorris644 commented 3 years ago

To help eliminate some of the variables (Docker) I spun up a brand new PI with node-red. I then installed this plugin.

At first I was not able to connect to port 80 as expected.

I then tried running node-red as sudo. That did not work. I think because I needed to start node itself with sudo. But, instead of trying that I gave node privileges to use lower port numbers by issuing:

sudo setcap 'cap_net_bind_service=+ep' $(eval readlink -fwhich node)

After doing all of this the situation is the same. I can access it using the curl command in the OP first message. I can also see traffic on port 80. I still cannot discover.

So, people MUST have this working in this type of "plain jane" environment. Now I am thinking it is the USG?

Anyone with thoughts?

datech commented 3 years ago

Can you give a try with the following options: docker run -it --network host --user 0 --name mynodered nodered/node-red-docker

jmorris644 commented 3 years ago

Can you give a try with the following options: docker run -it --network host --user 0 --name mynodered nodered/node-red-docker

That is how I am running it. I have also tried having the network in host mode and not in host mode. Same results both ways.

jmorris644 commented 3 years ago

A little more information. I decided to install contrib-alexa-local on my new test pi.

I tried it both running node-red without sudo and with sudo. Same results for both.

As you can see by the pics that are attached. Upon deployment it looks good. When I tell Alexa to discover devices, the node sees the discovery request. But Alexa never sees the device. The saga continues....

alexa local alexa local discovery
jmorris644 commented 3 years ago

Ah, I see that this node is deprecated. But at least I saw that it was receiving the discovery request. So I think we can assume that contrib-echo can see the request as well.

gobigdave commented 3 years ago

Very interesting. I know the Alexa-local doesn’t work with the newer devices, but it is interesting that it did see the discovery request. What port does Alexa-local listen on?

jmorris644 commented 3 years ago

It changes based upon the SSDP request coming in. I think that is why it doesn't work anymore because the newer echo firmware uses port 80 only.

gobigdave commented 3 years ago

I thought it still used SSDP to determine which IPs to see if they respond to /api/description.xml. Then again, I can’t say it should really work. For example, I curled another device on my network at http://[discovered_plug_ip]/api/description.xml, and it would not accept. That tells me that there is some other mechanism that provides the url to receive the description.xml file.

jmorris644 commented 3 years ago

Do you have a way to test it without the unifi network?

I do but it would be a very big hassle.

gobigdave commented 3 years ago

Looking around the docs for building an Alexa controlled device, and it mentions that the device must support Bluetooth to be discoverable. I tried putting my Pi into discovery mode, but still no dice.

gobigdave commented 3 years ago

Based on what I’m reading at https://developer.amazon.com/en-US/docs/alexa/alexa-gadgets-toolkit/steps-to-set-up-gadget.html, our problem may have nothing to do with mDNS or SSDP. It looks like devices are discovered first with Bluetooth, and that connection provides the url to query for discovery. It makes more sense that Alexa says to “put devices into pairing mode if necessary”.

I tried setting up Bluetooth (mine was off since I didn’t think I needed it) according to: https://raspberry-projects.com/pi/pi-operating-systems/raspbian/bluetooth/bluetooth-commands.

Still playing, but the Alexa doc sure seems to point to Bluetooth being the issue. Does the NodeRed add on know how to deal with Bluetooth? I’m going to try a few more things.

jmorris644 commented 3 years ago

I think that "gadgets" are specifically bluetooth. I have many devices that are WiFi only.

jmorris644 commented 3 years ago

based on this discover interface it looks like TCPIP, Zigbee, and Zwave are all available.

https://developer.amazon.com/en-US/docs/alexa/device-apis/alexa-discovery.html#response

Barabba11 commented 3 years ago

I think you better use an Echo/Alexa skill module instead of this module, in this case you let Alexa discover devices itself, and you will operate with devices mapped on internet by Alexa. Yes you will depend on internet avaliability after that, no internet no smarthome. This module instead operate without internet and it has at all another concept and reason to be, you create devices to be discovered by Alexa and it doesn't pretend to connect to existing devices. Why you ask this? There is no reason to connect to devices by NR, few people will have devices in BT range of Raspberry.. so it vecomes already useful for tto few ones.. I think you need to follow another way for that pourpose

jmorris644 commented 3 years ago

I am in the middle of creating an Alexa skill as your message came in. I must admit, it is one confusing process.

My preference is to not rely on the Internet for my home automation.

I might have to abandon Alexa because of that.

Barabba11 commented 3 years ago

if your goal is to live without internet then you need to chose proper input devices and output ones, zigbee2mqtt devices seems a valid choice. Then let your NR manage all of them, and Alexa find "fake" devices that you named in NR by this module. We have just one significative limitation, this module simulate just a bulb, you can't say alexa to close your shuttes, you need to switch off your shutters to let her close them. We need to simulate more devices here, curtains, fans, heat systems.. but to do that we need to find their documentation, or sniff the protocols and copy them. You may help the author providing him those infos.. probably someone already did the job, and probably this is open source too..

jmorris644 commented 3 years ago

Then let your NR manage all of them, and Alexa find "fake" devices that you named in NR by this module.

Agreed. But it is this module that we cannot get to function. As you state, it would only be a partial solution.

For other solutions I use a combination of keypads and 433MhZ and WiFi sensors and switches.

jmorris644 commented 3 years ago

@gobigdave Dave, I am curious. What is your interest in this stuff?

gobigdave commented 3 years ago

I’m starting to connect several MQTT devices that I can control with NodeRed and Home Assistant. I’m doing everything locally, but I wanted to experiment with using Alexa as well. Mostly, I don’t want to be dependent on the cloud for normal operation, but I’m ok with using Alexa to have voice. However, I have zero devices that require the cloud to operate outside of Alexa.

I’m pretty techie, so I’m tempted to setup Haaska, but it sure would have been a lot easier if this NodeRed palette would just work like it seems to for many.

gobigdave commented 3 years ago

Note, most of my MQTT devices have zero access to ANYTHING (local or web) except my MQTT broker and NTP.

jmorris644 commented 3 years ago

@gobigdave I sent you an email

Barabba11 commented 3 years ago

Have you understood how this module works? It has nothing to do with your devices, it's just for simulate a device to Alexa. When Alexa recognise them you simply create a function to turn on your mqtt device

gobigdave commented 3 years ago

Yes, I understand what it is supposed to do. However, Alexa never discovers the devices when asked. Any device I setup in NodeRed properly responds to http://[rpi_ip]/api/description.xml, but when I do “Alexa, discover devices”, she finds nothing.

I understand this palette has nothing to do with MQTT, but it will allow me to control an MQTT device with Alexa if I could get it to discover the “Amazon Echo Device” I setup to receive the commands.

Barabba11 commented 3 years ago

you simply have a common network problem, there are different people here who asked and find solutions, I suggest you to read all topics

gobigdave commented 3 years ago

I did read all the topics before posting here. Tried changing ports, removing firewalls, etc. No dice. I will read again.

jmorris644 commented 3 years ago

I too understand what it is used for. And I have the exact same issue. I also have looked at all of the posts and have tried man of them to no avail.

gobigdave commented 3 years ago

I did find this. If the cause, then it will be a problem if you also use Home Assistant since everything runs in Docker. I would have to remove Home Assistant to be able to shut off all the containers because of the supervisor.

———-

just to share my 6 hours troubleshooting session's result. I went through most of your suggestions and I actually learned a lot in the process.

I had another docker (zigbee2mqtt) running with --net=host.

If nodered started AFTER zigbee2mqtt it was not working; it was not receiving SSDP messages sent to 239.255.255.250.

If nodered runs by itself with no other docker and it's started when all other dockers are already off it WORKS

thanks for this product datech

jmorris644 commented 3 years ago

I am not running HA or igbee2mqtt. It is good news that you actually got it working in Docker though. Do you have network=host set for NR?

gobigdave commented 3 years ago

I’m running Home Assistant in supervisor mode. HA allows for add ons that are all deployed as containers (as is Home Assistant itself). From what I can see looking around Docker, everything runs in network host mode. I also tried this with HassOS which either takes over the PI or you run it in a VM. That didn’t work either.

My above comment seems to indicate that NodeRed has to run by itself. Otherwise, another container could eat the discovery traffic from Alexa.

jmorris644 commented 3 years ago

Ok, I bit the bullet and booted up a brand new pi instance. I installed NR standalone and still no joy.

Both the PI and my phone using Alexa App are on the same WiFi network, FWIW. So same VLAN.

3ative commented 3 years ago

I have Home Assistant, with Node-Red install on a VM on my unRaid server. Devices are still discoverable...

I made a quick video to show adding devices in Node-Red: https://youtu.be/B6mYkJoupLg

If you would like to see how I install Alexa in my Home Assistant, I made a Blooger post of tutorial videos and you can find that here: https://3ative.blogspot.com/2020/08/our-guide-to-integrating-alexa-in-home.html

jmorris644 commented 3 years ago

I have Home Assistant, with Node-Red install on a VM on my unRaid server. Devices are still discoverable...

I made a quick video to show adding devices in Node-Red: https://youtu.be/B6mYkJoupLg

If you would like to see how I install Alexa in my Home Assistant, I made a Blooger post of tutorial videos and you can find that here: https://3ative.blogspot.com/2020/08/our-guide-to-integrating-alexa-in-home.html

Are you using port 80 for the Echo Hub?

Also, it is hard to see in the video. What version of echo are you using?

3ative commented 3 years ago

Are you using port 80 for the Echo Hub?

Also, it is hard to see in the video. What version of echo are you using?

Yes Port 80 for the Hub, Like I said in the tut video, everything I use is default setup(s)

If by 'Echo' you mean the Echo Dot on my desk, that's a version two. However, I have a V3 (The one with the clock) and that works too/same.

jmorris644 commented 3 years ago

This is so frustrating. Because of the trouble we have been having with NR under Docker I spun up a new pi. All that is on the pi is NodeRed and this contrib.

I have also tried starting node red with sudo.

Still not working..

I am at a loss.

jmorris644 commented 3 years ago

Maybe the new version of node-red broke something? I am on 1.1.3

3ative commented 3 years ago

I don't think it's the NR version, I'm on v1.1.3 too image

And I seem to have the latest version of 'contrib' too image

Barabba11 commented 3 years ago

How you installed node red? With root permissions?

3ative commented 3 years ago

@Barabba11 If you're asking me, I've already addressed that question. 😉

3ative commented 3 years ago

Here's my YouTube playlist for my Alexa stuff: https://www.youtube.com/playlist?list=PLWRTMby105biP9gE08iGLab1FP6n7_mka

3ative commented 3 years ago

FYI - I just updated everything on my installation:

Supervisor to 247
HA to 0.116.0
Latest Node-Red

Tried the test/demo again (from the video I recently made) no change, devices get discovered ok, etc.

I see many ppl complaining they can't get some HA/NR functions to work when installed in a Docker. Like I said, I have HA installed in an UnRaid VM. I used this guide: https://community.home-assistant.io/t/hassio-on-unraid/59959

Everything else I have installed is either through the HA 'Add-on Store' or HACS.

gobigdave commented 3 years ago

I have an NUC on the way. I plan on installing in a VM according to the HA instructions, and we will see if that works.