From 82a30558e18143aa89274008ccf2736c24be6aba Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Sun, 27 Oct 2019 12:30:48 +0100 Subject: [PATCH] Fix web server transition length truncated (#807) Fixes https://github.com/esphome/issues/issues/772 --- esphome/components/web_server/web_server.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/esphome/components/web_server/web_server.cpp b/esphome/components/web_server/web_server.cpp index b51ad2cf51..4fdbbbce7d 100644 --- a/esphome/components/web_server/web_server.cpp +++ b/esphome/components/web_server/web_server.cpp @@ -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(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(length_s * 1000)); + } if (request->hasParam("effect")) { const char *effect = request->getParam("effect")->value().c_str();