Fix web server transition length truncated (#807)

Fixes https://github.com/esphome/issues/issues/772
This commit is contained in:
Otto Winter 2019-10-27 12:30:48 +01:00 committed by GitHub
parent 969bdb06ce
commit 08148c5830
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -416,11 +416,15 @@ void WebServer::handle_light_request(AsyncWebServerRequest *request, UrlMatch ma
if (request->hasParam("color_temp"))
call.set_color_temperature(request->getParam("color_temp")->value().toFloat());
if (request->hasParam("flash"))
call.set_flash_length((uint32_t) request->getParam("flash")->value().toFloat() * 1000);
if (request->hasParam("flash")) {
float length_s = request->getParam("flash")->value().toFloat();
call.set_flash_length(static_cast<uint32_t>(length_s * 1000));
}
if (request->hasParam("transition"))
call.set_transition_length((uint32_t) request->getParam("transition")->value().toFloat() * 1000);
if (request->hasParam("transition")) {
float length_s = request->getParam("transition")->value().toFloat();
call.set_transition_length(static_cast<uint32_t>(length_s * 1000));
}
if (request->hasParam("effect")) {
const char *effect = request->getParam("effect")->value().c_str();