kakopappa / arduino-esp8266-alexa-wemo-switch

Amazon Alexa + WeMos switch made with Arduino D1 Mini
https://sinric.pro
MIT License
281 stars 249 forks source link

Echo Dot 2nd gen not discovered #24

Closed ioanvapi closed 6 years ago

ioanvapi commented 6 years ago

The code

if(request.indexOf("M-SEARCH") > 0) {
    ....
    respondToSearch();
}

expects M-SEARCH to be in request but not at the beginning (index 0). In my case, the Echo's discovery message contains M-SEARCH at the very beginning, at index 0. I had to change the code to:

if(request.indexOf("M-SEARCH") >= 0) {
    ....
    respondToSearch();
}

in order to make it work and respondToSearch() to be invoked. This way, my device has been discovered by my Echo.

I've just looked at the fauxmo.py project and their code for this case is:

if data.find('M-SEARCH') == 0 and data.find('urn:Belkin:device:**') != -1:

data.find('M-SEARCH') == 0 means that 0 is the index of M-SEARCH in data string.

kakopappa commented 6 years ago

Thanks. Updated the code