vintlabs / fauxmoESP

Add voice control of your ESP32 and ESP8266 devices using Amazon Alexa
MIT License
383 stars 69 forks source link

Fauxmo with echo dot 3 #66

Closed pvint closed 3 years ago

pvint commented 5 years ago

Original report by Wernfried Schwenkner (Bitbucket: schwenkner, GitHub: schwenkner).


First I will introduce, that I use Espurna and came from that to Fauxmo.

My goal was to enable a Raspi for Alexa and found the fauxmo code very handy. Since I'm running Windows 10 IoT Core on my Raspi I have to adopt fauxmo to C#/UWP. FIrst I've done this with fauxmo 2.x, which emulate WeMo devices. This is wirking well with an echo dot 2.

No I purchased an echo dot 3 and the WeMo emulation didn't work anymore. I could get the device recognized, but when I try to control the device, I get the answer, "That isn't supported". Because of reading about some problems I adopted the fauxmo version 3.x with the Hue emulation and tried it first with my echo dot 2. This again worked well.

Now I'm trying to get the same code with echo dot 3 running. The short story, the device is not recognized.

The search package I get is:

M-SEARCH * HTTP/1.1

Host: 239.255.255.250:1900

Man: "ssdp:discover"

MX: 3

ST: upnp:rootdevice

With echo dot 2 it was "ST: urn:schemas-upnp-org:device:basic:1". Sinec fauxmo accepts also "upnp:rootdevice", the udp answer is sent. And there is also a get-request comming back, but different as in case of echo dot 2. It is

GET /description.xml HTTP/1.1 Content-Type: application/json User-Agent: Dalvik/2.1.0 (Linux; U; Android 7.1.2; AEODN Build/NS6504) Host: 192.168.0.25:1901 Connection: Keep-Alive Accept-Encoding: gzip

After sending the description, Alexa answers, with no devices found and I see nothing in the device list. I also do not see any GET /api/ request.

Has anyone tried fauxmo already with echo dot 3? Is there a hint what I can try to get this working?

I now tried echo dot 3 with the binaries of ESPurna for Sonoff pow R2. There is also no device found. With echo dot 2 it works.

pvint commented 5 years ago

Original comment by N 'So (Bitbucket: Inso_maniac, ).


I have tried it with the Echo Dot 3rd gen on an ESP8266 board with no success either. I am wondering if you can use Fauxmo and a 2nd Gen dot to add the device to the Alexa app and then control it using any of your other dots. I do not have a Gen 2 to test this with though figuring out native support for Gen 3 would be ideal.

pvint commented 5 years ago

Original comment by Luca Inox (Bitbucket: LucaInox, ).


why opening another issue when issue #58 describes exactly the same problem???

pvint commented 5 years ago

Original comment by N 'So (Bitbucket: Inso_maniac, ).


There is no mention in the original issue about the specific problem with 3rd generation dots, you are the only one in that issue to mention Gen 3 dots. That issue is discussing version issues with this repo and the board manager causing an unknown type of Echo to not be discovered. Your reply is unhelpful and inaccurate.

As an update I will be using a Gen 2 Dot tomorrow to see if I can link the board to the Alexa app and use my Gen 3 dots to control the fauxmo devices as well.

pvint commented 5 years ago

Original comment by Wernfried Schwenkner (Bitbucket: schwenkner, GitHub: schwenkner).


I think this is worth a separte thread. In #58 it is discussed, that fauxmo v3 does not work anymore, even with echo dot 2. This I cannot verfify, for me et works the Hue emulation with the echo dot 2.

The WeMo emulation does not work at all with echo dot 2. And since I have coded the Hue emulation by my own I can see, that the GET description.xml answer is send to the emulator, but no GET lights request.

pvint commented 5 years ago

Original comment by N 'So (Bitbucket: Inso_maniac, ).


Yesterday I was able to get my devices discovered on the Alexa app, but only with a Gen 2 connected to the same network. If I tried to find the devices without the Gen 2 powered it would find nothing and I would receive no searches from my Gen 3 devices, that is without sniffing the packets fully and just in debug mode. The Gen 2 Dot has to be connected all the time as well because even though the device has been discovered by the Alexa App it will not control the device at all without a Gen 2 somewhere on the same network. It basically is acting like a hub for the fauxmo switches.

For reference I got it working with a Gen 2 Echo Dot(firmware 618622620), a Makerfocus D1 mini board, running the 2.4.2 ESP8266 board version, along with the 2.3.0 Fauxmo library. The only other thing I have changed would be the IwIP variant option in Tools to v2 higher bandwidth. I will be soon seeing if there is better compatibility at all with other options but this was the first combination that got my fauxmo devices discovered.

pvint commented 5 years ago

Original comment by Peter Feerick (Bitbucket: pfeerick, GitHub: pfeerick).


This is definitely worth a separate thread, as #58 is about v3.0 of the library, not the 3rd Gen Echo. This issue is about the 3rd Gen Echo, and trying to get the fauxmoESP library working on a Raspberry Pi running Windows 10 IoT Core. Just a teensy bit different!

pvint commented 5 years ago

Original comment by Arpad (Bitbucket: ArpadB, GitHub: ArpadB).


Yesterday, I saved my notes for the wrong issue (#58). Let me fix this mistake.

Good news! There is a solution. Bad news, you guys need to help. I just started this whole Arduino/ESP8266/Alexa game few days ago. Anyway, this is what I found, but first of all, my configuration: Echo Dot gen 3, IDE 1.8.7, ESP8266 library 2.4.2, FauxmoESP 3.0.0, board selection: regular nodeMCU 1.0 ( 4M/1M SPIFFS, v2 lower memory) And here are the problems: -- 1. In the early stage of my tries I changed the port to 80, and limited to one device only. I'm not sure how much the port 80 contributed in the final success, but adding a second device definitely brakes my otherwise working test project. -- 2. In some reason, when the TCP response (the body in _sendTCPResponse) is big (around 1024 with the header), not the whole buffer is transmitted. I used my PC's browser with Fiddler to see what fauxmo answers for the http://ip/description.xml request, and there was nothing but the header. When I removed few lines from the XML, it started working. I'm not saying, this is the solution. We need someone more competent to check what is the problem with the "client->write(body);". Anyway. Deleting the icon definitions from the XML helped me. At least with the second step of the discover. Then I found the next issue: -- 3. They replaced the PUT verb with POST. Also there is no need for the extra slash at the end of the URL. So in the _onTCPData the "char match[] = {"PUT /api/"};" must be replaced with "char match[] = {"POST /api"};". (Actually I left the fixed "char match[] = {"PUT /api"};" in the code, just in case.) I also changed the url in the GET ("char match[] = {"GET /api"};"). These changes solved the discovery issue, and Alexa finally found the device. But the type was unknown, thus no control was available. This leads to the next problem. -- 4. It turns out, the device definition JSON (FAUXMO_DEVICE_JSON_TEMPLATE) is not correct. I registered to the Philips developer site, and pulled a JSON sample. It finally made the library working. It is still not perfect. The JSON can be shortened, the descriptions can be changed. Also I saw some warnings in the Alexa app about invalid values, but it was too late (or early), and couldn't spend more time. I let you guys finalize the changes. Here is my replacement JSON:

PROGMEM const char FAUXMO_DEVICE_JSON_TEMPLATE[] = "{\"productname\": \"%s\",\"uniqueid\": \"%s-%d\",\"state\": {\"on\": %s,\"bri\": %d,\"hue\": 33761,\"sat\": 254,\"effect\": \"none\",\"xy\": [0.3171,0.3366],\"ct\": 159,\"alert\": \"none\",\"colormode\": \"xy\",\"mode\": \"homeautomation\",\"reachable\": true},\"type\": \"Extended color light\",\"name\": \"Light\",\"modelid\": \"LCT007\",\"manufacturername\": \"Philips\",\"capabilities\": {\"certified\": true,\"control\": {\"mindimlevel\": 5000,\"maxlumen\": 600,\"colorgamuttype\": \"B\",\"colorgamut\": [[0.675,0.322],[0.409,0.518],[0.167,0.04]],\"ct\": {\"min\": 153,\"max\": 500}},\"streaming\": {\"renderer\": true,\"proxy\": false}},\"config\": {\"archetype\": \"sultanbulb\",\"function\": \"mixed\",\"direction\": \"omnidirectional\"},\"swversion\": \"5.105.0.21169\"}}";

Today I continued the fine tuning, and ended up with the following JSONs. These changes will emulate a simple on/off light, so no more issues with the invalid values.

PROGMEM const char FAUXMO_TCP_STATE_RESPONSE[] = "[" "{\"success\":{\"/lights/%d/state/on\":%s}}" "]";

PROGMEM const char FAUXMO_DEVICE_JSON_TEMPLATE[] = "{\"name\": \"%s\",\"type\": \"On/off light\",\"modelid\": \"LWB001\"," "\"manufacturername\": \"Philips\",\"productname\": \"On/Off Plug\",\"uniqueid\": \"%s-%d\"," "\"swversion\": \"1.01.01\",\"swupdate\": {\"state\": \"notupdatable\",\"lastinstall\": \"2018-01-01T00:00:00\"}," "\"config\": {\"archetype\": \"classicbulb\",\"function\": \"functional\",\"direction\": \"omnidirectional\"}," "\"capabilities\": {\"certified\": false,\"streaming\": {\"renderer\": false, \"proxy\": false}}," "\"state\": {\"on\": %s,\"alert\": \"none\",\"mode\": \"homeautomation\",\"reachable\": true}}";

pvint commented 5 years ago

Original comment by Luca Inox (Bitbucket: LucaInox, ).


Hello Arpad, i tried to replicate your code but no success. Can you publish your modified library and your example .ino code so we can all replicate your success? fior example did you modify also FauxmoESP.h ? are these lines correct?

define UDP_MULTICAST_IP IPAddress(239,255,255,250)

define UDP_MULTICAST_PORT 1900

define TCP_MAX_CLIENTS 10

define TCP_PORT 1901

regards and good work

pvint commented 5 years ago

Original comment by Arpad (Bitbucket: ArpadB, GitHub: ArpadB).


I'm not comfortable with messing around in the repository, so let me just include some images that show the difference. (You can copy/paste the JSONs from my previous comment.)

fauxmoESP_Basic.ino fauxmoESP_Basic.ino.jpg fauxmoESP.h fauxmoESP.h.jpg fauxmoESP.cpp fauxmoESP.cpp.jpg templates.h templates.h.jpg

pvint commented 5 years ago

Original comment by Luca Inox (Bitbucket: LucaInox, ).


Arpad #YOU ARE A GENIUS !!!!!

pvint commented 5 years ago

Original comment by Johannes Diehl (Bitbucket: johannes99, GitHub: johannes99).


@Arpad it also works for me!!!

pvint commented 5 years ago

Original comment by Logiciels Andro (Bitbucket: Andrologiciels, GitHub: Andrologiciels).


With the #58 issue, I can manage 1 device. @Arpad @Luca Inox @Johannes Diehl is it possible to put all the modified files on bitbucket or GitHub ? By advance thank's !

pvint commented 5 years ago

Original comment by Xose Pérez (Bitbucket: [Xose Pérez](https://bitbucket.org/Xose Pérez), ).


Hi I received a gen3 last week and will test this ASAP. @arpad, the solution does not seem to be compatible with dimming lights or with using gen1 (or gen2) devices. Have you tested with these?

pvint commented 5 years ago

Original comment by Manan Thareja (Bitbucket: Manan_Thareja, ).


I tried to do what @Arpad did. It still doesn't work for me, there is a probability that I might be doing something wrong. Can someone publish the modified library and the .ino code.

pvint commented 5 years ago

Original comment by Logiciels Andro (Bitbucket: Andrologiciels, GitHub: Andrologiciels).


Hi, I tried the kakopappa sketch, all you have to do is add you SSID and PAssword and modify the name of the device, all works perfectly without external library : https://github.com/kakopappa/arduino-esp8266-alexa-multiple-wemo-switch

pvint commented 5 years ago

Original comment by Arpad (Bitbucket: ArpadB, GitHub: ArpadB).


Logiciels Andro, are you sure you have a 3rd generation Echo Dot? Because your link is another Belkin emulator, and it is not really working with the 3rd gen. This is the whole reason for this (#66) issue.

Xose Pérez, Start with the below JSON. It supports the dimming, it is working, but it needs a little tweaking, because the Alexa app was complaining about invalid values. Also keep the fauxmo_tcp_state_resonse as is. (Don't delete the line I suggested.)

PROGMEM const char FAUXMO_DEVICE_JSON_TEMPLATE[] = "{\"productname\": \"%s\",\"uniqueid\": \"%s-%d\",\"state\": {\"on\": %s,\"bri\": %d,\"hue\": 33761,\"sat\": 254,\"effect\": \"none\",\"xy\": [0.3171,0.3366],\"ct\": 159,\"alert\": \"none\",\"colormode\": \"xy\",\"mode\": \"homeautomation\",\"reachable\": true},\"type\": \"Extended color light\",\"name\": \"Light\",\"modelid\": \"LCT007\",\"manufacturername\": \"Philips\",\"capabilities\": {\"certified\": true,\"control\": {\"mindimlevel\": 5000,\"maxlumen\": 600,\"colorgamuttype\": \"B\",\"colorgamut\": [[0.675,0.322],[0.409,0.518],[0.167,0.04]],\"ct\": {\"min\": 153,\"max\": 500}},\"streaming\": {\"renderer\": true,\"proxy\": false}},\"config\": {\"archetype\": \"sultanbulb\",\"function\": \"mixed\",\"direction\": \"omnidirectional\"},\"swversion\": \"5.105.0.21169\"}}";

pvint commented 5 years ago

Original comment by Xose Pérez (Bitbucket: [Xose Pérez](https://bitbucket.org/Xose Pérez), ).


Just pushed a version to dev branch with dimming support based on @arpad code. The only issue is that gen3 seems to require TCP port 80. That could be a problem when fauxmoESP is integrated into other software, like ESPurna...

pvint commented 5 years ago

Original comment by Xose Pérez (Bitbucket: [Xose Pérez](https://bitbucket.org/Xose Pérez), ).


I have added a way to "inject" requests from an external webserver. This way you can use port 80 for your application and redirect alexa-specific requests to the fauxmoESP. To make it work with gen3 devices you have to set TCP port to 80 with (fauxmo->setPort(80);) before enabling the library the first time. You cannot change the port afterwards, a reboot is required. Check the two examples on how to use it standalone or with an external ESPAsyncWebserver object.

pvint commented 5 years ago

Original comment by Xose Pérez (Bitbucket: [Xose Pérez](https://bitbucket.org/Xose Pérez), ).


Issue #61 was marked as a duplicate of this issue.

pvint commented 5 years ago

Original comment by Wernfried Schwenkner (Bitbucket: schwenkner, GitHub: schwenkner).


I've followed this discussion. Unfortunately I could not try all the changes mentioned here with my C# implementation, since I have my echo dot 3 not present. Hope to find some time after Xmas, the echo is located there where I will stay between the years.

But can someone answer me a question upon the port stuff.

If a gen2 echo works with a port different then 80, why should a new echo version eliminate the port and replace it with 80. As I understood the communication between echo and fauxmo, in the first udp answer fauxmo tells the echo where to send further tcp messages. All this should be indipendent from the bridge used, it is common to SSDP protocol, not all SSDP discovered devices work with port 80. In the udp answer is the different port specified. Since this works with gen2, why in gen3 this port is replaced by 80? I do not beleave that Amazon has such a bug here or that for Philips bridge a special behaviour is implemented, allthogh it was already working for gen2.

And where is port 80 necessary? As I mentioned in my first post, the "description" answer from echo I received already on a different port then 80, it is 1901, the same fauxmo used for gen2. Only the following request is not recevied. But this does not come from the echo but from the implemented skill. Then Philips must destinguish between gen2 and gen3.

Any comments?

pvint commented 5 years ago

Original comment by Jaume Nogues Gazquez (Bitbucket: [Jaume Nogues](https://bitbucket.org/Jaume Nogues), ).


or a lot of hours I'm trying to use a ESP8266 and a ESP32 with a gen3. I Alexa don't discover my device. I agree if someone could share a sketch that works with a a Lolin32, for an Arduino IDE 1.8.8 and the last 'dev' fauxmoESP library. Now I'm thinking if the problem is my router configuration. Thanks in advanced.

pvint commented 5 years ago

Original comment by Xose Pérez (Bitbucket: [Xose Pérez](https://bitbucket.org/Xose Pérez), ).


My dot gen1 works fine whatever the port is. But when using my gen3 alone (unplug all other devices) it handles the UDP requests and correctly requests /description.xml in the given port (1901) but there are no other requests to the /api entry point. When using port 80 all requests are performed and it works just fine. Maybe the problem is that gen3 devices are expecting the port in a different field of the XML the description.xml requests returns, but I couldn't find it.

pvint commented 5 years ago

Original comment by Chirag Ajmera (Bitbucket: nccchirag, GitHub: nccchirag).


Issue #93 was marked as a duplicate of this issue.

pvint commented 5 years ago

Original comment by Chirag Ajmera (Bitbucket: nccchirag, GitHub: nccchirag).


Echo dot generation 3 does not discover hue emulated devices - discovery UDP packet not received

International latest s/w ver - 2315742340 (ref - https://www.amazon.com/gp/help/customer/display.html?nodeId=201602210)

My device s/w ver - 2382875524 (gen 3 echo dot)

Since last few days I noticed echo dot gen 3 stops working abruptly and does not discover devices either. My setup was working since a month with ESP32 (latest fauxmoESP 3.1.x) & 1nos echo dot 3. But now it is not working anymore

Has anyone come across such an issue, if so please guide, otherwise if your setup is working including gen 3 echo dot please share your device software version number on your echo dot gen 3.

Diagnostic Info

although echo dot gen 3 account showed me emulated devices, turn on/off response would be – I’m not able to find light 1 device or group in …account name’s…. profile

I tried to deregister and re discover but no luck!

I also have an echo dot gen 2 in the same setup which is working fine ( both turn on/off & discovery )

Requesting all to share information on the above

Thank you

pvint commented 5 years ago

Original comment by Chirag Ajmera (Bitbucket: nccchirag, GitHub: nccchirag).


seems the discovery is working again, after couple attempts of registering and de-registering

pvint commented 5 years ago

Original comment by Not SoTechnical (Bitbucket: [Not SoTechnical](https://bitbucket.org/Not SoTechnical), ).


Hi. I followed this website to get Alexa Echo dot (Generation 3) connected to Node MCU: https://www.how2electronics.com/home-automation-with-nodemcu-alexa/#comment-607

Initial Testing: No errors, but Alexa can’t discovery the device

I added this to the code in the main program:

fauxmo.setPort(80);

Errors:

Arduino: 1.8.9 (Mac OS X), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 115200, 4M (3M SPIFFS)"

/Users/user/Documents/Arduino/nodemcu_home_automation/nodemcu_home_automation.ino: In function 'void setup()':

nodemcu_home_automation:72:8: error: 'class fauxmoESP' has no member named 'setPort'

fauxmo.setPort(80); // required for gen3 devices

^

exit status 1

'class fauxmoESP' has no member named 'setPort'

This report would have more information with

"Show verbose output during compilation"

option enabled in File -> Preferences.

How do I solve this? I’m very new to this thing. Any help is appreciated.

pvint commented 5 years ago

Original comment by Peter Feerick (Bitbucket: pfeerick, GitHub: pfeerick).


At a guess, without seeing the code, I’d say you’re either running a older version of fauxmoESP (make sure you have v3.1.0 - setPort didn’t exist before that version), or have changed the name of the object - i.e. it’s no longer fauxmoESP fauxmo; ? Have a look at the example, and see if you can spot the difference. Better still, trying compiling the example as is, and see if it works. https://bitbucket.org/xoseperez/fauxmoesp/src/master/examples/fauxmoESP_Basic/fauxmoESP_Basic.ino

pvint commented 4 years ago

Original comment by Gustavo Freire (Bitbucket: gsfreire, GitHub: gsfreire).


How you can find the gen3 echo? I cant do it and i dont know why.

pvint commented 3 years ago

Closing stale issue