From f6582ecd1892eb2ab8c946a480ff8a4ed84aa5bc Mon Sep 17 00:00:00 2001 From: aL1aL7 <38977615+aL1aL7@users.noreply.github.com> Date: Wed, 28 Oct 2020 20:40:56 +0100 Subject: [PATCH] alexa: fix device discovery / state callback (#2388) alexa device discovery/state calls use URL of type /api/hash_id_key_whatever/lights This is blocked when API is disabled and fails also when http API is enabled because no apikey is sent by amazon calls Don't try to use the http api for alexa calls. Responses for alexa are done by fauxmoesp lib, so there's no need for the http api call. --- code/espurna/api.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/espurna/api.cpp b/code/espurna/api.cpp index 3dfa3554..9aa66cbe 100644 --- a/code/espurna/api.cpp +++ b/code/espurna/api.cpp @@ -224,6 +224,12 @@ bool _apiRequestCallback(AsyncWebServerRequest* request) { } if (!url.startsWith("/api/")) return false; + +// [alexa] don't call the http api -> response for alexa is done by fauxmoesp lib +#if ALEXA_SUPPORT + if (url.indexOf("/lights") > 14 ) return false; +#endif + if (!apiAuthenticate(request)) return false; return _apiDispatchRequest(url, request);