mirror of
https://github.com/esphome/esphome.git
synced 2026-08-31 10:06:03 +00:00
[core] Rename entity_types.inc to entity_types.h
Neither PlatformIO nor ESP-IDF/CMake copy .inc files to the build directory. Rename to .h so it's recognized by both build systems. Exempt from pragma-once lint since this file is intentionally included multiple times with different macro definitions.
This commit is contained in:
+1
-1
@@ -102,7 +102,7 @@ PLATFORM_RP2040 = Platform.RP2040
|
||||
PLATFORM_RTL87XX = Platform.RTL87XX
|
||||
|
||||
|
||||
SOURCE_FILE_EXTENSIONS = {".cpp", ".hpp", ".h", ".c", ".tcc", ".ino", ".inc"}
|
||||
SOURCE_FILE_EXTENSIONS = {".cpp", ".hpp", ".h", ".c", ".tcc", ".ino"}
|
||||
HEADER_FILE_EXTENSIONS = {".h", ".hpp", ".tcc"}
|
||||
SECRETS_FILES = ("secrets.yaml", "secrets.yml")
|
||||
|
||||
|
||||
@@ -119,13 +119,13 @@ class Application {
|
||||
void set_current_component(Component *component) { this->current_component_ = component; }
|
||||
Component *get_current_component() { return this->current_component_; }
|
||||
|
||||
// Entity register methods (generated from entity_types.inc)
|
||||
// Entity register methods (generated from entity_types.h)
|
||||
// NOLINTBEGIN(bugprone-macro-parentheses)
|
||||
#define ENTITY_TYPE_(type, singular, plural, count, upper) \
|
||||
void register_##singular(type *obj) { this->plural##_.push_back(obj); }
|
||||
#define ENTITY_CONTROLLER_TYPE_(type, singular, plural, count, upper, callback) \
|
||||
ENTITY_TYPE_(type, singular, plural, count, upper)
|
||||
#include "esphome/core/entity_types.inc"
|
||||
#include "esphome/core/entity_types.h"
|
||||
#undef ENTITY_TYPE_
|
||||
#undef ENTITY_CONTROLLER_TYPE_
|
||||
// NOLINTEND(bugprone-macro-parentheses)
|
||||
@@ -272,14 +272,14 @@ class Application {
|
||||
#ifdef USE_AREAS
|
||||
const auto &get_areas() { return this->areas_; }
|
||||
#endif
|
||||
// Entity getter methods (generated from entity_types.inc)
|
||||
// Entity getter methods (generated from entity_types.h)
|
||||
// NOLINTBEGIN(bugprone-macro-parentheses)
|
||||
#define ENTITY_TYPE_(type, singular, plural, count, upper) \
|
||||
auto &get_##plural() const { return this->plural##_; } \
|
||||
GET_ENTITY_METHOD(type, singular, plural)
|
||||
#define ENTITY_CONTROLLER_TYPE_(type, singular, plural, count, upper, callback) \
|
||||
ENTITY_TYPE_(type, singular, plural, count, upper)
|
||||
#include "esphome/core/entity_types.inc"
|
||||
#include "esphome/core/entity_types.h"
|
||||
#undef ENTITY_TYPE_
|
||||
#undef ENTITY_CONTROLLER_TYPE_
|
||||
// NOLINTEND(bugprone-macro-parentheses)
|
||||
@@ -463,12 +463,12 @@ class Application {
|
||||
#ifdef USE_AREAS
|
||||
StaticVector<Area *, ESPHOME_AREA_COUNT> areas_{};
|
||||
#endif
|
||||
// Entity StaticVector fields (generated from entity_types.inc)
|
||||
// Entity StaticVector fields (generated from entity_types.h)
|
||||
// NOLINTBEGIN(bugprone-macro-parentheses)
|
||||
#define ENTITY_TYPE_(type, singular, plural, count, upper) StaticVector<type *, count> plural##_{};
|
||||
#define ENTITY_CONTROLLER_TYPE_(type, singular, plural, count, upper, callback) \
|
||||
ENTITY_TYPE_(type, singular, plural, count, upper)
|
||||
#include "esphome/core/entity_types.inc"
|
||||
#include "esphome/core/entity_types.h"
|
||||
#undef ENTITY_TYPE_
|
||||
#undef ENTITY_CONTROLLER_TYPE_
|
||||
// NOLINTEND(bugprone-macro-parentheses)
|
||||
|
||||
@@ -33,7 +33,7 @@ void ComponentIterator::advance() {
|
||||
}
|
||||
break;
|
||||
|
||||
// Entity iterator cases (generated from entity_types.inc)
|
||||
// Entity iterator cases (generated from entity_types.h)
|
||||
// NOLINTBEGIN(bugprone-macro-parentheses)
|
||||
#define ENTITY_TYPE_(type, singular, plural, count, upper) \
|
||||
case IteratorState::upper: \
|
||||
@@ -41,7 +41,7 @@ void ComponentIterator::advance() {
|
||||
break;
|
||||
#define ENTITY_CONTROLLER_TYPE_(type, singular, plural, count, upper, callback) \
|
||||
ENTITY_TYPE_(type, singular, plural, count, upper)
|
||||
#include "esphome/core/entity_types.inc"
|
||||
#include "esphome/core/entity_types.h"
|
||||
#undef ENTITY_TYPE_
|
||||
#undef ENTITY_CONTROLLER_TYPE_
|
||||
// NOLINTEND(bugprone-macro-parentheses)
|
||||
|
||||
@@ -28,12 +28,12 @@ class ComponentIterator {
|
||||
void advance();
|
||||
bool completed() const { return this->state_ == IteratorState::NONE; }
|
||||
virtual bool on_begin();
|
||||
// Pure virtual entity callbacks (generated from entity_types.inc)
|
||||
// Pure virtual entity callbacks (generated from entity_types.h)
|
||||
// NOLINTBEGIN(bugprone-macro-parentheses)
|
||||
#define ENTITY_TYPE_(type, singular, plural, count, upper) virtual bool on_##singular(type *obj) = 0;
|
||||
#define ENTITY_CONTROLLER_TYPE_(type, singular, plural, count, upper, callback) \
|
||||
ENTITY_TYPE_(type, singular, plural, count, upper)
|
||||
#include "esphome/core/entity_types.inc"
|
||||
#include "esphome/core/entity_types.h"
|
||||
#undef ENTITY_TYPE_
|
||||
#undef ENTITY_CONTROLLER_TYPE_
|
||||
// NOLINTEND(bugprone-macro-parentheses)
|
||||
@@ -52,11 +52,11 @@ class ComponentIterator {
|
||||
enum class IteratorState : uint8_t {
|
||||
NONE = 0,
|
||||
BEGIN,
|
||||
// Entity iterator states (generated from entity_types.inc)
|
||||
// Entity iterator states (generated from entity_types.h)
|
||||
// NOLINTBEGIN(bugprone-macro-parentheses)
|
||||
#define ENTITY_TYPE_(type, singular, plural, count, upper) upper,
|
||||
#define ENTITY_CONTROLLER_TYPE_(type, singular, plural, count, upper, callback) upper,
|
||||
#include "esphome/core/entity_types.inc"
|
||||
#include "esphome/core/entity_types.h"
|
||||
#undef ENTITY_TYPE_
|
||||
#undef ENTITY_CONTROLLER_TYPE_
|
||||
// NOLINTEND(bugprone-macro-parentheses)
|
||||
|
||||
@@ -6,11 +6,11 @@ namespace esphome {
|
||||
|
||||
class Controller {
|
||||
public:
|
||||
// Controller virtual methods (generated from entity_types.inc)
|
||||
// Controller virtual methods (generated from entity_types.h)
|
||||
// NOLINTBEGIN(bugprone-macro-parentheses)
|
||||
#define ENTITY_TYPE_(type, singular, plural, count, upper) // no controller callback
|
||||
#define ENTITY_CONTROLLER_TYPE_(type, singular, plural, count, upper, callback) virtual void on_##callback(type *obj){};
|
||||
#include "esphome/core/entity_types.inc"
|
||||
#include "esphome/core/entity_types.h"
|
||||
#undef ENTITY_TYPE_
|
||||
#undef ENTITY_CONTROLLER_TYPE_
|
||||
// NOLINTEND(bugprone-macro-parentheses)
|
||||
|
||||
@@ -36,12 +36,12 @@ class ControllerRegistry {
|
||||
*/
|
||||
static void register_controller(Controller *controller) { controllers.push_back(controller); }
|
||||
|
||||
// Notify method declarations (generated from entity_types.inc)
|
||||
// Notify method declarations (generated from entity_types.h)
|
||||
// NOLINTBEGIN(bugprone-macro-parentheses)
|
||||
#define ENTITY_TYPE_(type, singular, plural, count, upper) // no controller callback
|
||||
#define ENTITY_CONTROLLER_TYPE_(type, singular, plural, count, upper, callback) \
|
||||
static void notify_##callback(type *obj);
|
||||
#include "esphome/core/entity_types.inc"
|
||||
#include "esphome/core/entity_types.h"
|
||||
#undef ENTITY_TYPE_
|
||||
#undef ENTITY_CONTROLLER_TYPE_
|
||||
// NOLINTEND(bugprone-macro-parentheses)
|
||||
@@ -72,7 +72,7 @@ namespace esphome {
|
||||
controller->on_##callback(obj); \
|
||||
} \
|
||||
}
|
||||
#include "esphome/core/entity_types.inc"
|
||||
#include "esphome/core/entity_types.h"
|
||||
#undef ENTITY_TYPE_
|
||||
#undef ENTITY_CONTROLLER_TYPE_
|
||||
// NOLINTEND(bugprone-macro-parentheses)
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
// - serial_proxy: custom register logic, no by-key lookup
|
||||
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
ENTITY_CONTROLLER_TYPE_(binary_sensor::BinarySensor, binary_sensor, binary_sensors, ESPHOME_ENTITY_BINARY_SENSOR_COUNT, BINARY_SENSOR, binary_sensor_update)
|
||||
ENTITY_CONTROLLER_TYPE_(binary_sensor::BinarySensor, binary_sensor, binary_sensors, ESPHOME_ENTITY_BINARY_SENSOR_COUNT,
|
||||
BINARY_SENSOR, binary_sensor_update)
|
||||
#endif
|
||||
#ifdef USE_COVER
|
||||
ENTITY_CONTROLLER_TYPE_(cover::Cover, cover, covers, ESPHOME_ENTITY_COVER_COUNT, COVER, cover_update)
|
||||
@@ -35,7 +36,8 @@ ENTITY_CONTROLLER_TYPE_(switch_::Switch, switch, switches, ESPHOME_ENTITY_SWITCH
|
||||
ENTITY_TYPE_(button::Button, button, buttons, ESPHOME_ENTITY_BUTTON_COUNT, BUTTON)
|
||||
#endif
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
ENTITY_CONTROLLER_TYPE_(text_sensor::TextSensor, text_sensor, text_sensors, ESPHOME_ENTITY_TEXT_SENSOR_COUNT, TEXT_SENSOR, text_sensor_update)
|
||||
ENTITY_CONTROLLER_TYPE_(text_sensor::TextSensor, text_sensor, text_sensors, ESPHOME_ENTITY_TEXT_SENSOR_COUNT,
|
||||
TEXT_SENSOR, text_sensor_update)
|
||||
#endif
|
||||
#ifdef USE_CLIMATE
|
||||
ENTITY_CONTROLLER_TYPE_(climate::Climate, climate, climates, ESPHOME_ENTITY_CLIMATE_COUNT, CLIMATE, climate_update)
|
||||
@@ -50,7 +52,8 @@ ENTITY_CONTROLLER_TYPE_(datetime::DateEntity, date, dates, ESPHOME_ENTITY_DATE_C
|
||||
ENTITY_CONTROLLER_TYPE_(datetime::TimeEntity, time, times, ESPHOME_ENTITY_TIME_COUNT, DATETIME_TIME, time_update)
|
||||
#endif
|
||||
#ifdef USE_DATETIME_DATETIME
|
||||
ENTITY_CONTROLLER_TYPE_(datetime::DateTimeEntity, datetime, datetimes, ESPHOME_ENTITY_DATETIME_COUNT, DATETIME_DATETIME, datetime_update)
|
||||
ENTITY_CONTROLLER_TYPE_(datetime::DateTimeEntity, datetime, datetimes, ESPHOME_ENTITY_DATETIME_COUNT, DATETIME_DATETIME,
|
||||
datetime_update)
|
||||
#endif
|
||||
#ifdef USE_TEXT
|
||||
ENTITY_CONTROLLER_TYPE_(text::Text, text, texts, ESPHOME_ENTITY_TEXT_COUNT, TEXT, text_update)
|
||||
@@ -65,13 +68,16 @@ ENTITY_CONTROLLER_TYPE_(lock::Lock, lock, locks, ESPHOME_ENTITY_LOCK_COUNT, LOCK
|
||||
ENTITY_CONTROLLER_TYPE_(valve::Valve, valve, valves, ESPHOME_ENTITY_VALVE_COUNT, VALVE, valve_update)
|
||||
#endif
|
||||
#ifdef USE_MEDIA_PLAYER
|
||||
ENTITY_CONTROLLER_TYPE_(media_player::MediaPlayer, media_player, media_players, ESPHOME_ENTITY_MEDIA_PLAYER_COUNT, MEDIA_PLAYER, media_player_update)
|
||||
ENTITY_CONTROLLER_TYPE_(media_player::MediaPlayer, media_player, media_players, ESPHOME_ENTITY_MEDIA_PLAYER_COUNT,
|
||||
MEDIA_PLAYER, media_player_update)
|
||||
#endif
|
||||
#ifdef USE_ALARM_CONTROL_PANEL
|
||||
ENTITY_CONTROLLER_TYPE_(alarm_control_panel::AlarmControlPanel, alarm_control_panel, alarm_control_panels, ESPHOME_ENTITY_ALARM_CONTROL_PANEL_COUNT, ALARM_CONTROL_PANEL, alarm_control_panel_update)
|
||||
ENTITY_CONTROLLER_TYPE_(alarm_control_panel::AlarmControlPanel, alarm_control_panel, alarm_control_panels,
|
||||
ESPHOME_ENTITY_ALARM_CONTROL_PANEL_COUNT, ALARM_CONTROL_PANEL, alarm_control_panel_update)
|
||||
#endif
|
||||
#ifdef USE_WATER_HEATER
|
||||
ENTITY_CONTROLLER_TYPE_(water_heater::WaterHeater, water_heater, water_heaters, ESPHOME_ENTITY_WATER_HEATER_COUNT, WATER_HEATER, water_heater_update)
|
||||
ENTITY_CONTROLLER_TYPE_(water_heater::WaterHeater, water_heater, water_heaters, ESPHOME_ENTITY_WATER_HEATER_COUNT,
|
||||
WATER_HEATER, water_heater_update)
|
||||
#endif
|
||||
#ifdef USE_INFRARED
|
||||
ENTITY_TYPE_(infrared::Infrared, infrared, infrareds, ESPHOME_ENTITY_INFRARED_COUNT, INFRARED)
|
||||
+1
-1
@@ -672,7 +672,7 @@ def lint_using_esp_idf_deprecated(fname, line, col, content):
|
||||
)
|
||||
|
||||
|
||||
@lint_content_check(include=["*.h"])
|
||||
@lint_content_check(include=["*.h"], exclude=["esphome/core/entity_types.h"])
|
||||
def lint_pragma_once(fname, content):
|
||||
if "#pragma once" not in content:
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user