mirror of
https://github.com/esphome/esphome.git
synced 2025-01-18 20:10:55 +00:00
fix(web_server/fan): send speed update values even when fan is off (#8086)
This commit is contained in:
parent
17b88f2e3e
commit
c43d8460bd
@ -455,8 +455,9 @@ void WebServer::handle_fan_request(AsyncWebServerRequest *request, const UrlMatc
|
|||||||
} else if (match.method == "toggle") {
|
} else if (match.method == "toggle") {
|
||||||
this->schedule_([obj]() { obj->toggle().perform(); });
|
this->schedule_([obj]() { obj->toggle().perform(); });
|
||||||
request->send(200);
|
request->send(200);
|
||||||
} else if (match.method == "turn_on") {
|
} else if (match.method == "turn_on" || match.method == "turn_off") {
|
||||||
auto call = obj->turn_on();
|
auto call = match.method == "turn_on" ? obj->turn_on() : obj->turn_off();
|
||||||
|
|
||||||
if (request->hasParam("speed_level")) {
|
if (request->hasParam("speed_level")) {
|
||||||
auto speed_level = request->getParam("speed_level")->value();
|
auto speed_level = request->getParam("speed_level")->value();
|
||||||
auto val = parse_number<int>(speed_level.c_str());
|
auto val = parse_number<int>(speed_level.c_str());
|
||||||
@ -486,9 +487,6 @@ void WebServer::handle_fan_request(AsyncWebServerRequest *request, const UrlMatc
|
|||||||
}
|
}
|
||||||
this->schedule_([call]() mutable { call.perform(); });
|
this->schedule_([call]() mutable { call.perform(); });
|
||||||
request->send(200);
|
request->send(200);
|
||||||
} else if (match.method == "turn_off") {
|
|
||||||
this->schedule_([obj]() { obj->turn_off().perform(); });
|
|
||||||
request->send(200);
|
|
||||||
} else {
|
} else {
|
||||||
request->send(404);
|
request->send(404);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user