mirror of
https://github.com/esphome/esphome.git
synced 2026-09-14 16:48:40 +00:00
[web_server] Skip ping interval when no SSE clients are connected
This commit is contained in:
@@ -415,6 +415,8 @@ void WebServer::setup() {
|
||||
// doesn't need defer functionality - if the queue is full, the client JS knows it's alive because it's clearly
|
||||
// getting a lot of events
|
||||
this->set_interval(10000, [this]() {
|
||||
if (this->events_.empty())
|
||||
return;
|
||||
char buf[32];
|
||||
auto uptime = static_cast<uint32_t>(millis_64() / 1000);
|
||||
buf_append_printf(buf, sizeof(buf), 0, "{\"uptime\":%" PRIu32 "}", uptime);
|
||||
|
||||
Reference in New Issue
Block a user