fix clang-tidy

This commit is contained in:
Tomasz Duda 2024-08-14 17:43:02 +02:00
parent 36a2e6e941
commit 57b532db95
8 changed files with 36 additions and 22 deletions

View file

@ -1,35 +1,36 @@
from __future__ import annotations from __future__ import annotations
import gzip import gzip
import esphome.codegen as cg import esphome.codegen as cg
import esphome.config_validation as cv
import esphome.final_validate as fv
from esphome.components import web_server_base from esphome.components import web_server_base
from esphome.components.web_server_base import CONF_WEB_SERVER_BASE_ID from esphome.components.web_server_base import CONF_WEB_SERVER_BASE_ID
import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_AUTH,
CONF_CSS_INCLUDE, CONF_CSS_INCLUDE,
CONF_CSS_URL, CONF_CSS_URL,
CONF_ENABLE_PRIVATE_NETWORK_ACCESS,
CONF_ID, CONF_ID,
CONF_INCLUDE_INTERNAL,
CONF_JS_INCLUDE, CONF_JS_INCLUDE,
CONF_JS_URL, CONF_JS_URL,
CONF_ENABLE_PRIVATE_NETWORK_ACCESS,
CONF_PORT,
CONF_AUTH,
CONF_USERNAME,
CONF_PASSWORD,
CONF_INCLUDE_INTERNAL,
CONF_OTA,
CONF_LOG,
CONF_VERSION,
CONF_LOCAL, CONF_LOCAL,
CONF_LOG,
CONF_OTA,
CONF_PASSWORD,
CONF_PORT,
CONF_USERNAME,
CONF_VERSION,
CONF_WEB_SERVER_ID, CONF_WEB_SERVER_ID,
CONF_WEB_SERVER_SORTING_WEIGHT, CONF_WEB_SERVER_SORTING_WEIGHT,
PLATFORM_BK72XX,
PLATFORM_ESP32, PLATFORM_ESP32,
PLATFORM_ESP8266, PLATFORM_ESP8266,
PLATFORM_BK72XX,
PLATFORM_RTL87XX, PLATFORM_RTL87XX,
) )
from esphome.core import CORE, coroutine_with_priority from esphome.core import CORE, coroutine_with_priority
import esphome.final_validate as fv
AUTO_LOAD = ["json", "web_server_base"] AUTO_LOAD = ["json", "web_server_base"]
@ -208,7 +209,6 @@ async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID], paren) var = cg.new_Pvariable(config[CONF_ID], paren)
await cg.register_component(var, config) await cg.register_component(var, config)
cg.add_define("USE_WEBSERVER")
version = config[CONF_VERSION] version = config[CONF_VERSION]
cg.add(paren.set_port(config[CONF_PORT])) cg.add(paren.set_port(config[CONF_PORT]))

View file

@ -1,4 +1,5 @@
#include "list_entities.h" #include "list_entities.h"
#ifdef USE_WEBSERVER
#include "esphome/core/application.h" #include "esphome/core/application.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "esphome/core/util.h" #include "esphome/core/util.h"
@ -188,3 +189,4 @@ bool ListEntitiesIterator::on_update(update::UpdateEntity *update) {
} // namespace web_server } // namespace web_server
} // namespace esphome } // namespace esphome
#endif

View file

@ -1,8 +1,9 @@
#pragma once #pragma once
#include "esphome/core/defines.h"
#ifdef USE_WEBSERVER
#include "esphome/core/component.h" #include "esphome/core/component.h"
#include "esphome/core/component_iterator.h" #include "esphome/core/component_iterator.h"
#include "esphome/core/defines.h"
namespace esphome { namespace esphome {
namespace web_server { namespace web_server {
@ -78,3 +79,4 @@ class ListEntitiesIterator : public ComponentIterator {
} // namespace web_server } // namespace web_server
} // namespace esphome } // namespace esphome
#endif

View file

@ -1,5 +1,5 @@
#include "web_server.h" #include "web_server.h"
#ifdef USE_WEBSERVER
#include "esphome/components/json/json_util.h" #include "esphome/components/json/json_util.h"
#include "esphome/components/network/util.h" #include "esphome/components/network/util.h"
#include "esphome/core/application.h" #include "esphome/core/application.h"
@ -1659,3 +1659,4 @@ void WebServer::schedule_(std::function<void()> &&f) {
} // namespace web_server } // namespace web_server
} // namespace esphome } // namespace esphome
#endif

View file

@ -3,6 +3,7 @@
#include "list_entities.h" #include "list_entities.h"
#include "esphome/components/web_server_base/web_server_base.h" #include "esphome/components/web_server_base/web_server_base.h"
#ifdef USE_WEBSERVER
#include "esphome/core/component.h" #include "esphome/core/component.h"
#include "esphome/core/controller.h" #include "esphome/core/controller.h"
#include "esphome/core/entity_base.h" #include "esphome/core/entity_base.h"
@ -366,3 +367,4 @@ class WebServer : public Controller, public Component, public AsyncWebHandler {
} // namespace web_server } // namespace web_server
} // namespace esphome } // namespace esphome
#endif

View file

@ -1,4 +1,5 @@
#include "web_server_base.h" #include "web_server_base.h"
#ifdef USE_NETWORK
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "esphome/core/application.h" #include "esphome/core/application.h"
#include "esphome/core/helpers.h" #include "esphome/core/helpers.h"
@ -121,3 +122,4 @@ float WebServerBase::get_setup_priority() const {
} // namespace web_server_base } // namespace web_server_base
} // namespace esphome } // namespace esphome
#endif

View file

@ -1,5 +1,6 @@
#pragma once #pragma once
#include "esphome/core/defines.h"
#ifdef USE_NETWORK
#include <memory> #include <memory>
#include <utility> #include <utility>
#include <vector> #include <vector>
@ -145,3 +146,4 @@ class OTARequestHandler : public AsyncWebHandler {
} // namespace web_server_base } // namespace web_server_base
} // namespace esphome } // namespace esphome
#endif

View file

@ -1,19 +1,20 @@
import re
import ipaddress import ipaddress
import re
from esphome import automation
import esphome.codegen as cg import esphome.codegen as cg
from esphome.components import time
from esphome.components.esp32 import CORE, add_idf_sdkconfig_option
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_ID,
CONF_TIME_ID,
CONF_ADDRESS, CONF_ADDRESS,
CONF_ID,
CONF_REBOOT_TIMEOUT, CONF_REBOOT_TIMEOUT,
CONF_TIME_ID,
KEY_CORE, KEY_CORE,
KEY_FRAMEWORK_VERSION, KEY_FRAMEWORK_VERSION,
) )
from esphome.components.esp32 import CORE, add_idf_sdkconfig_option
from esphome.components import time
from esphome.core import TimePeriod from esphome.core import TimePeriod
from esphome import automation
CONF_NETMASK = "netmask" CONF_NETMASK = "netmask"
CONF_PRIVATE_KEY = "private_key" CONF_PRIVATE_KEY = "private_key"
@ -91,6 +92,8 @@ CONFIG_SCHEMA = cv.Schema(
async def to_code(config): async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID]) var = cg.new_Pvariable(config[CONF_ID])
cg.add_define("USE_WIREGUARD")
cg.add(var.set_address(str(config[CONF_ADDRESS]))) cg.add(var.set_address(str(config[CONF_ADDRESS])))
cg.add(var.set_netmask(str(config[CONF_NETMASK]))) cg.add(var.set_netmask(str(config[CONF_NETMASK])))
cg.add(var.set_private_key(config[CONF_PRIVATE_KEY])) cg.add(var.set_private_key(config[CONF_PRIVATE_KEY]))