Closed pvint closed 3 years ago
Original comment by Alexander Pankow (Bitbucket: [Alexander Pankow](https://bitbucket.org/Alexander Pankow), ).
+1 for support for ESP8266 webserver.
With the current Adafruit DHT sensor library the ESP8266 crashes if we try to get the DHT data via the web server. It does not crash with older versions of the library, but no data is output.
So, currently it is impossible for me to make the fauxmo library working for gen3 devices AND work with a webserver. :disappointed:
Regards,
Alexander
Original comment by Enrico A. (Bitbucket: [Enrico A.](https://bitbucket.org/Enrico A.), ).
Hi Alexander I made a small modify to source to redirect port80 of the internal webaserver to whatever port. So you can use ESP8266webserver or whatever server you want without problems:
is just a small mod that i hope that somebody will be merge it with source.
go in src folder of fauxmo exp lib:
in file fauxmoESP.cpp
in class bool fauxmoESP::_onTCPRequest(AsyncClient *client, bool isGet, String url, String body) {
at the end before of:
return false; }
add this:
if (_redirect_port!=0){
char response[strlen_P(FAUXMO_REDIRECT)+5];
snprintf_P(
response, sizeof(response),
FAUXMO_REDIRECT,
_redirect_port
);
_sendTCPResponse(client, "200 OK", response, "text/html");
}
in the file fauxmoESP.h
after void setPort(unsigned long tcp_port) { _tcp_port = tcp_port; }
add this line:
void setRedirect(unsigned long redirect_port) { _redirect_port = redirect_port; }
and after the line: unsigned int _tcp_port = FAUXMO_TCP_PORT;
add this line:
unsigned int _redirect_port = 0;
and finally in file templates.h
after this code:
PROGMEM const char FAUXMO_TCP_STATE_RESPONSE[] = "["
"{"success":{"/lights/%d/state/on":%s}},"
"{"success":{"/lights/%d/state/bri":%d}}" // not needed?
"]";
add:
PROGMEM const char FAUXMO_REDIRECT[] = "<!DOCTYPE HTML>
"the %d will be replaced at runtime by the port where you want redirect the unanswered calls on port 80.
and the script will redirect everything that is not handled by alexa on this port.
so if you write:
fauxmo.setRedirect(81);
everything on port 81 will go directly on port 81
when something will arrive on port 80 if is something alexa related will be handled by the library.
If the library doesn’t found something know forward to port 81.
I tested for a week also removing and rediscovering and works.
Original report by Enrico A. (Bitbucket: [Enrico A.](https://bitbucket.org/Enrico A.), ).
Is possible to use fauxmoESP with Esp8266webserver as external webserver?
Looking at some messages seems that previous versions was using it, now require AsyncWebserver.