From b568af16989d1011c9991a4ee77104ff1d385eac Mon Sep 17 00:00:00 2001 From: Tomasz Duda Date: Wed, 14 Aug 2024 18:09:33 +0200 Subject: [PATCH] [code-quality] fix clang-tidy api --- esphome/components/api/api_connection.cpp | 2 ++ esphome/components/api/api_connection.h | 4 +++- esphome/components/api/api_frame_helper.cpp | 3 ++- esphome/components/api/api_frame_helper.h | 3 ++- esphome/components/api/api_server.cpp | 2 ++ esphome/components/api/api_server.h | 4 +++- esphome/components/api/custom_api_device.h | 5 +++-- esphome/components/api/homeassistant_service.h | 7 ++++--- esphome/components/api/list_entities.cpp | 2 ++ esphome/components/api/list_entities.h | 5 +++-- esphome/components/api/subscribe_state.cpp | 2 ++ esphome/components/api/subscribe_state.h | 5 +++-- 12 files changed, 31 insertions(+), 13 deletions(-) diff --git a/esphome/components/api/api_connection.cpp b/esphome/components/api/api_connection.cpp index bd438265d4..909f59c681 100644 --- a/esphome/components/api/api_connection.cpp +++ b/esphome/components/api/api_connection.cpp @@ -1,4 +1,5 @@ #include "api_connection.h" +#ifdef USE_API #include #include #include @@ -1511,3 +1512,4 @@ void APIConnection::on_fatal_error() { } // namespace api } // namespace esphome +#endif diff --git a/esphome/components/api/api_connection.h b/esphome/components/api/api_connection.h index 714e806470..c1f25ffda7 100644 --- a/esphome/components/api/api_connection.h +++ b/esphome/components/api/api_connection.h @@ -1,12 +1,13 @@ #pragma once +#include "esphome/core/defines.h" +#ifdef USE_API #include "api_frame_helper.h" #include "api_pb2.h" #include "api_pb2_service.h" #include "api_server.h" #include "esphome/core/application.h" #include "esphome/core/component.h" -#include "esphome/core/defines.h" #include @@ -264,3 +265,4 @@ class APIConnection : public APIServerConnection { } // namespace api } // namespace esphome +#endif diff --git a/esphome/components/api/api_frame_helper.cpp b/esphome/components/api/api_frame_helper.cpp index f4b18a1fd6..62f375508c 100644 --- a/esphome/components/api/api_frame_helper.cpp +++ b/esphome/components/api/api_frame_helper.cpp @@ -1,5 +1,5 @@ #include "api_frame_helper.h" - +#ifdef USE_API #include "esphome/core/log.h" #include "esphome/core/hal.h" #include "esphome/core/helpers.h" @@ -1028,3 +1028,4 @@ APIError APIPlaintextFrameHelper::shutdown(int how) { } // namespace api } // namespace esphome +#endif diff --git a/esphome/components/api/api_frame_helper.h b/esphome/components/api/api_frame_helper.h index bf4872d2d6..56d8bf1973 100644 --- a/esphome/components/api/api_frame_helper.h +++ b/esphome/components/api/api_frame_helper.h @@ -5,7 +5,7 @@ #include #include "esphome/core/defines.h" - +#ifdef USE_API #ifdef USE_API_NOISE #include "noise/protocol.h" #endif @@ -190,3 +190,4 @@ class APIPlaintextFrameHelper : public APIFrameHelper { } // namespace api } // namespace esphome +#endif diff --git a/esphome/components/api/api_server.cpp b/esphome/components/api/api_server.cpp index 0fde3e47af..f16b5a13cf 100644 --- a/esphome/components/api/api_server.cpp +++ b/esphome/components/api/api_server.cpp @@ -1,4 +1,5 @@ #include "api_server.h" +#ifdef USE_API #include #include "api_connection.h" #include "esphome/components/network/util.h" @@ -403,3 +404,4 @@ void APIServer::on_alarm_control_panel_update(alarm_control_panel::AlarmControlP } // namespace api } // namespace esphome +#endif diff --git a/esphome/components/api/api_server.h b/esphome/components/api/api_server.h index 899eaede49..42e0b1048a 100644 --- a/esphome/components/api/api_server.h +++ b/esphome/components/api/api_server.h @@ -1,5 +1,7 @@ #pragma once +#include "esphome/core/defines.h" +#ifdef USE_API #include "api_noise_context.h" #include "api_pb2.h" #include "api_pb2_service.h" @@ -7,7 +9,6 @@ #include "esphome/core/automation.h" #include "esphome/core/component.h" #include "esphome/core/controller.h" -#include "esphome/core/defines.h" #include "esphome/core/log.h" #include "list_entities.h" #include "subscribe_state.h" @@ -153,3 +154,4 @@ template class APIConnectedCondition : public Condition { } // namespace api } // namespace esphome +#endif diff --git a/esphome/components/api/custom_api_device.h b/esphome/components/api/custom_api_device.h index 845a35fc54..1a8e189f41 100644 --- a/esphome/components/api/custom_api_device.h +++ b/esphome/components/api/custom_api_device.h @@ -1,9 +1,9 @@ #pragma once #include -#include "user_services.h" #include "api_server.h" - +#ifdef USE_API +#include "user_services.h" namespace esphome { namespace api { @@ -216,3 +216,4 @@ class CustomAPIDevice { } // namespace api } // namespace esphome +#endif diff --git a/esphome/components/api/homeassistant_service.h b/esphome/components/api/homeassistant_service.h index f04181e5b2..e91756c3c9 100644 --- a/esphome/components/api/homeassistant_service.h +++ b/esphome/components/api/homeassistant_service.h @@ -1,10 +1,10 @@ #pragma once +#include "api_server.h" +#ifdef USE_API +#include "api_pb2.h" #include "esphome/core/helpers.h" #include "esphome/core/automation.h" -#include "api_pb2.h" -#include "api_server.h" - #include namespace esphome { @@ -81,3 +81,4 @@ template class HomeAssistantServiceCallAction : public Action