Aircoookie / Espalexa

Alexa voice control for ESP8266/ESP32 (including brightness and color!)
MIT License
542 stars 134 forks source link

ESP32 with Alexa App Compatibility Issue #44

Open eos1d3 opened 5 years ago

eos1d3 commented 5 years ago

When using latest Alexa App to control (on, off, dimming) ESP32 light devices, the light devices will become "Device malfunction" or "Device is unresponsive" randomly. And killing the App and restart it 1 or 2 times, most devices will show the error message. And http://[device-ip]/espalexa can't be connected. Reseting the ESP32 module can make the devices work again.

Image of Alexa App with Error Messages

The Alexa app version: Client Version: 1.24.204839.0 App Version: 2.2.250163.0 OS: Android 8

Using ESP-8266, all control functions work. Never find a problem so far.

Aircoookie commented 5 years ago

Thank you for the report! If http://[device-ip]/espalexa is no longer reachable, the ESP32 device has disconnected from the WiFi for some reason. Does it happen only when using the Alexa app or also randomly after some time if the ESP32 is just idle?

eos1d3 commented 5 years ago

Let me reply later. I just can't confirm. After I installed latest Alexa app (Android version, GUI is newly changed, very different from older ones), it seems I can't use https://alexa.amazon.com on PC to discover ESP32 and even ESP8266 any more!!! But new Alexa apps can discover ESP-8266, and almost no chance to find ESP32. With only two success to find ESP32 in 3 hours. But I do not change any codes or network settings. I only change is the installation of new Alexa Android app.

Usually when ESP32 devices can be discovered, just kill the Alexa App (not just quit it), Then restart it and select the devices, there are buttons to set on/off/dim with this Alexa App, once you do it after first restart, most devices will will not response or malfunction.

Usually restarting Alexa apps more than 2 times, or keeping changing on/off/dim buttons will make ESP32 disappeared in network.

No idle issue, killing using Alexa app for a while, or kill and restart it, you must see devices do not response with messages shown.

I am still testing.... Very confusing.

Aircoookie commented 5 years ago

Thanks for doing all this testing, and sorry that you are encountering those issues! It really sounds like it's currently a gamble whether the library works, several factors can make or break it, like ESP8266 or 32, core version, using async or not, Echo version, Echo type and now even app versions. That said, I'm also using Android 8 and app 2.2.250163.0 and everything works fine for me :/ Honestly it is very hard for me as the developer because even if a version works in my network doesn't mean it works for everyone equally. Therefore I'm very helpful that you and others help me out work out those issues :)

Aircoookie commented 5 years ago

Actually I just attempted using ESP32 and was able to reproduce the issue. The device becomes unresponsive as soon as I open the new Alexa app and the devices are already added. The initial discovery seems to work fine for me though (related to #41, ESP32 discovery works with debug mode disabled for me, without the brackets you added)

eos1d3 commented 5 years ago

several factors can make or break it, like ESP8266 or 32, core version, using async or not, Echo version, Echo type

All are under our control or choice. We can choose which library versions too use. So these are not real problems.

and now even app versions.

The Alexa app, or the Hue private API, I do not believe Amazon or Philips can change or remove them now. Because there are a lot their products released to the market, they just can't change their API to break all their existing products and ruin their customers too.

They can only add more APIs for new features, but they have to keep the old ones for sure without killing their old products too.

The only thing we need is to make the codes fully compatible with their API. Just like ESP8266, the library works perfectly with new app.

Therefore I'm very helpful that you and others help me out work out those issues :)

Will try my best.

The initial discovery seems to work fine for me though (related to #41, ESP32 discovery works with debug mode disabled for me, without the brackets you added)

I remember Amazon has different servers for different countries. The server you connected may not be the same as I one I connected. So if they are updating, we need to wait for a while. I am from HK and may be very different.

robademar commented 5 years ago

I experienced the same unstable result. Starting device search and just after start esp32 , devices are found but when I asked to turn on the first Alexa said device not responding. I don't know if it could be useful but this the dbug log

alexa log 5 feb.pdf

Aircoookie commented 5 years ago

Thanks for the log! Here again, a NOTIFY was received immediately before it stopped working, very interesting. So I'll start investigating that tomorrow :)

Aircoookie commented 5 years ago

I believe I have found and fixed the issue. The ESP32 would disconnect once a UDP packet with more than 254 bytes was received (which those NOTIFY packets often are). There is a new version 2.3.3 for you to test. However, using Echo Dot 2 and non-async, I am still getting the content-type bug despite trying several workarounds. Normal Echo 2 non-async or Echo Dot with async works. For ESP8266, all combinations work. In general, the app control still was very delayed (took up to 5 seconds to receive the command). Can you confirm my findings? I'll do my best to work out the remaining issues ASAP :)

robademar commented 5 years ago

BRAVOOO! First tests are ok tomorrow I will do more

Thanks Gio

eos1d3 commented 5 years ago

Hi, good to hear this. This seems the fix for what I encounted.

I would suggest skipping Echo dot 2 at the moment as this does not support color either. I am using Echo dot gen 3 and can test it later. But I will be home 2 days later.

I never have app control delay like what you said. I did not notice this. Usually after finger released on app, the lamp on off or dim almost instantly. But Alexa may reply one or two seconds later than real lamp operation. I think it is Amazon issue only.

Ps. Implement on off dim via pwm pin to control ESP on board led. You will see real operation is fast.

eos1d3 commented 5 years ago

Version 2.3.3 fixed the bug. Tests were done with newer Alexa apps (App version 2.2.256080.0). Controlling on/off/dim does not disconnect ESP32 any more.