Closed ioanvapi closed 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.
data.find('M-SEARCH') == 0
Thanks. Updated the code
The code
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:
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.