From 0edfa4746a03ed35febbeb1131897eaf2bd05a10 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 13 May 2025 22:00:08 -0500 Subject: [PATCH] revert --- .../alarm_control_panel.cpp | 2 - .../alarm_control_panel/alarm_control_panel.h | 2 - esphome/components/api/api_connection.cpp | 47 ++++++++++--------- esphome/components/api/api_connection.h | 4 +- .../binary_sensor/binary_sensor.cpp | 2 - .../components/binary_sensor/binary_sensor.h | 3 -- esphome/components/button/button.cpp | 2 - esphome/components/button/button.h | 2 - esphome/components/climate/climate.cpp | 2 - esphome/components/climate/climate.h | 2 - esphome/components/cover/cover.cpp | 1 - esphome/components/cover/cover.h | 1 - esphome/components/datetime/date_entity.h | 2 - esphome/components/datetime/datetime_base.h | 2 - esphome/components/datetime/datetime_entity.h | 2 - esphome/components/datetime/time_entity.h | 2 - esphome/components/event/event.cpp | 2 - esphome/components/event/event.h | 2 - esphome/components/fan/fan.cpp | 2 - esphome/components/fan/fan.h | 1 - esphome/components/light/light_state.cpp | 2 - esphome/components/light/light_state.h | 2 - esphome/components/lock/lock.cpp | 2 - esphome/components/lock/lock.h | 2 - .../components/media_player/media_player.cpp | 2 - .../components/media_player/media_player.h | 2 - esphome/components/number/number.cpp | 2 - esphome/components/number/number.h | 2 - esphome/components/select/select.cpp | 2 - esphome/components/select/select.h | 2 - esphome/components/sensor/sensor.cpp | 1 - esphome/components/sensor/sensor.h | 1 - esphome/components/switch/switch.cpp | 1 - esphome/components/switch/switch.h | 1 - esphome/components/text/text.cpp | 2 - esphome/components/text/text.h | 2 - .../components/text_sensor/text_sensor.cpp | 1 - esphome/components/text_sensor/text_sensor.h | 1 - esphome/components/update/update_entity.cpp | 2 - esphome/components/update/update_entity.h | 2 - esphome/components/valve/valve.cpp | 2 - esphome/components/valve/valve.h | 2 - esphome/core/entity_base.h | 4 -- 43 files changed, 27 insertions(+), 100 deletions(-) diff --git a/esphome/components/alarm_control_panel/alarm_control_panel.cpp b/esphome/components/alarm_control_panel/alarm_control_panel.cpp index 3417def62e..9f1485ee90 100644 --- a/esphome/components/alarm_control_panel/alarm_control_panel.cpp +++ b/esphome/components/alarm_control_panel/alarm_control_panel.cpp @@ -13,8 +13,6 @@ static const char *const TAG = "alarm_control_panel"; AlarmControlPanelCall AlarmControlPanel::make_call() { return AlarmControlPanelCall(this); } -const char *AlarmControlPanel::get_component_type() const { return "alarm_control_panel"; } - bool AlarmControlPanel::is_state_armed(AlarmControlPanelState state) { switch (state) { case ACP_STATE_ARMED_AWAY: diff --git a/esphome/components/alarm_control_panel/alarm_control_panel.h b/esphome/components/alarm_control_panel/alarm_control_panel.h index 32d07a14b6..85c2b2148e 100644 --- a/esphome/components/alarm_control_panel/alarm_control_panel.h +++ b/esphome/components/alarm_control_panel/alarm_control_panel.h @@ -29,8 +29,6 @@ class AlarmControlPanel : public EntityBase { */ AlarmControlPanelCall make_call(); - const char *get_component_type() const override; - /** Set the state of the alarm_control_panel. * * @param state The AlarmControlPanelState. diff --git a/esphome/components/api/api_connection.cpp b/esphome/components/api/api_connection.cpp index 9f5297fdeb..f127bcc600 100644 --- a/esphome/components/api/api_connection.cpp +++ b/esphome/components/api/api_connection.cpp @@ -289,7 +289,8 @@ bool APIConnection::try_send_binary_sensor_info_(binary_sensor::BinarySensor *bi ListEntitiesBinarySensorResponse msg; msg.device_class = binary_sensor->get_device_class(); msg.is_status_binary_sensor = binary_sensor->is_status_binary_sensor(); - return this->try_send_entity_info_(binary_sensor, msg, &APIConnection::send_list_entities_binary_sensor_response); + return this->try_send_entity_info_(binary_sensor, msg, "binary_sensor", + &APIConnection::send_list_entities_binary_sensor_response); } #endif @@ -320,7 +321,7 @@ bool APIConnection::try_send_cover_info_(cover::Cover *cover) { msg.supports_tilt = traits.get_supports_tilt(); msg.supports_stop = traits.get_supports_stop(); msg.device_class = cover->get_device_class(); - return this->try_send_entity_info_(cover, msg, &APIConnection::send_list_entities_cover_response); + return this->try_send_entity_info_(cover, msg, "cover", &APIConnection::send_list_entities_cover_response); } void APIConnection::cover_command(const CoverCommandRequest &msg) { cover::Cover *cover = App.get_cover_by_key(msg.key); @@ -381,7 +382,7 @@ bool APIConnection::try_send_fan_info_(fan::Fan *fan) { msg.supported_speed_count = traits.supported_speed_count(); for (auto const &preset : traits.supported_preset_modes()) msg.supported_preset_modes.push_back(preset); - return this->try_send_entity_info_(fan, msg, &APIConnection::send_list_entities_fan_response); + return this->try_send_entity_info_(fan, msg, "fan", &APIConnection::send_list_entities_fan_response); } void APIConnection::fan_command(const FanCommandRequest &msg) { fan::Fan *fan = App.get_fan_by_key(msg.key); @@ -455,7 +456,7 @@ bool APIConnection::try_send_light_info_(light::LightState *light) { msg.effects.push_back(effect->get_name()); } } - return this->try_send_entity_info_(light, msg, &APIConnection::send_list_entities_light_response); + return this->try_send_entity_info_(light, msg, "light", &APIConnection::send_list_entities_light_response); } void APIConnection::light_command(const LightCommandRequest &msg) { light::LightState *light = App.get_light_by_key(msg.key); @@ -520,7 +521,7 @@ bool APIConnection::try_send_sensor_info_(sensor::Sensor *sensor) { msg.force_update = sensor->get_force_update(); msg.device_class = sensor->get_device_class(); msg.state_class = static_cast(sensor->get_state_class()); - return this->try_send_entity_info_(sensor, msg, &APIConnection::send_list_entities_sensor_response); + return this->try_send_entity_info_(sensor, msg, "sensor", &APIConnection::send_list_entities_sensor_response); } #endif @@ -546,7 +547,7 @@ bool APIConnection::try_send_switch_info_(switch_::Switch *a_switch) { ListEntitiesSwitchResponse msg; msg.assumed_state = a_switch->assumed_state(); msg.device_class = a_switch->get_device_class(); - return this->try_send_entity_info_(a_switch, msg, &APIConnection::send_list_entities_switch_response); + return this->try_send_entity_info_(a_switch, msg, "switch", &APIConnection::send_list_entities_switch_response); } void APIConnection::switch_command(const SwitchCommandRequest &msg) { switch_::Switch *a_switch = App.get_switch_by_key(msg.key); @@ -583,7 +584,8 @@ bool APIConnection::try_send_text_sensor_state_(text_sensor::TextSensor *text_se bool APIConnection::try_send_text_sensor_info_(text_sensor::TextSensor *text_sensor) { ListEntitiesTextSensorResponse msg; msg.device_class = text_sensor->get_device_class(); - return this->try_send_entity_info_(text_sensor, msg, &APIConnection::send_list_entities_text_sensor_response); + return this->try_send_entity_info_(text_sensor, msg, "text_sensor", + &APIConnection::send_list_entities_text_sensor_response); } #endif @@ -652,7 +654,7 @@ bool APIConnection::try_send_climate_info_(climate::Climate *climate) { msg.supported_custom_presets.push_back(custom_preset); for (auto swing_mode : traits.get_supported_swing_modes()) msg.supported_swing_modes.push_back(static_cast(swing_mode)); - return this->try_send_entity_info_(climate, msg, &APIConnection::send_list_entities_climate_response); + return this->try_send_entity_info_(climate, msg, "climate", &APIConnection::send_list_entities_climate_response); } void APIConnection::climate_command(const ClimateCommandRequest &msg) { climate::Climate *climate = App.get_climate_by_key(msg.key); @@ -711,7 +713,7 @@ bool APIConnection::try_send_number_info_(number::Number *number) { msg.min_value = number->traits.get_min_value(); msg.max_value = number->traits.get_max_value(); msg.step = number->traits.get_step(); - return this->try_send_entity_info_(number, msg, &APIConnection::send_list_entities_number_response); + return this->try_send_entity_info_(number, msg, "number", &APIConnection::send_list_entities_number_response); } void APIConnection::number_command(const NumberCommandRequest &msg) { number::Number *number = App.get_number_by_key(msg.key); @@ -743,7 +745,7 @@ bool APIConnection::try_send_date_state_(datetime::DateEntity *date) { } bool APIConnection::try_send_date_info_(datetime::DateEntity *date) { ListEntitiesDateResponse msg; - return this->try_send_entity_info_(date, msg, &APIConnection::send_list_entities_date_response); + return this->try_send_entity_info_(date, msg, "date", &APIConnection::send_list_entities_date_response); } void APIConnection::date_command(const DateCommandRequest &msg) { datetime::DateEntity *date = App.get_date_by_key(msg.key); @@ -775,7 +777,7 @@ bool APIConnection::try_send_time_state_(datetime::TimeEntity *time) { } bool APIConnection::try_send_time_info_(datetime::TimeEntity *time) { ListEntitiesTimeResponse msg; - return this->try_send_entity_info_(time, msg, &APIConnection::send_list_entities_time_response); + return this->try_send_entity_info_(time, msg, "time", &APIConnection::send_list_entities_time_response); } void APIConnection::time_command(const TimeCommandRequest &msg) { datetime::TimeEntity *time = App.get_time_by_key(msg.key); @@ -808,7 +810,7 @@ bool APIConnection::try_send_datetime_state_(datetime::DateTimeEntity *datetime) } bool APIConnection::try_send_datetime_info_(datetime::DateTimeEntity *datetime) { ListEntitiesDateTimeResponse msg; - return this->try_send_entity_info_(datetime, msg, &APIConnection::send_list_entities_date_time_response); + return this->try_send_entity_info_(datetime, msg, "datetime", &APIConnection::send_list_entities_date_time_response); } void APIConnection::datetime_command(const DateTimeCommandRequest &msg) { datetime::DateTimeEntity *datetime = App.get_datetime_by_key(msg.key); @@ -842,7 +844,7 @@ bool APIConnection::try_send_text_info_(text::Text *text) { msg.min_length = text->traits.get_min_length(); msg.max_length = text->traits.get_max_length(); msg.pattern = text->traits.get_pattern(); - return this->try_send_entity_info_(text, msg, &APIConnection::send_list_entities_text_response); + return this->try_send_entity_info_(text, msg, "text", &APIConnection::send_list_entities_text_response); } void APIConnection::text_command(const TextCommandRequest &msg) { text::Text *text = App.get_text_by_key(msg.key); @@ -878,7 +880,7 @@ bool APIConnection::try_send_select_info_(select::Select *select) { ListEntitiesSelectResponse msg; for (const auto &option : select->traits.get_options()) msg.options.push_back(option); - return this->try_send_entity_info_(select, msg, &APIConnection::send_list_entities_select_response); + return this->try_send_entity_info_(select, msg, "select", &APIConnection::send_list_entities_select_response); } void APIConnection::select_command(const SelectCommandRequest &msg) { select::Select *select = App.get_select_by_key(msg.key); @@ -898,7 +900,7 @@ void esphome::api::APIConnection::send_button_info(button::Button *button) { bool esphome::api::APIConnection::try_send_button_info_(button::Button *button) { ListEntitiesButtonResponse msg; msg.device_class = button->get_device_class(); - return this->try_send_entity_info_(button, msg, &APIConnection::send_list_entities_button_response); + return this->try_send_entity_info_(button, msg, "button", &APIConnection::send_list_entities_button_response); } void esphome::api::APIConnection::button_command(const ButtonCommandRequest &msg) { button::Button *button = App.get_button_by_key(msg.key); @@ -932,7 +934,7 @@ bool APIConnection::try_send_lock_info_(lock::Lock *a_lock) { msg.assumed_state = a_lock->traits.get_assumed_state(); msg.supports_open = a_lock->traits.get_supports_open(); msg.requires_code = a_lock->traits.get_requires_code(); - return this->try_send_entity_info_(a_lock, msg, &APIConnection::send_list_entities_lock_response); + return this->try_send_entity_info_(a_lock, msg, "lock", &APIConnection::send_list_entities_lock_response); } void APIConnection::lock_command(const LockCommandRequest &msg) { lock::Lock *a_lock = App.get_lock_by_key(msg.key); @@ -975,7 +977,7 @@ bool APIConnection::try_send_valve_info_(valve::Valve *valve) { msg.assumed_state = traits.get_is_assumed_state(); msg.supports_position = traits.get_supports_position(); msg.supports_stop = traits.get_supports_stop(); - return this->try_send_entity_info_(valve, msg, &APIConnection::send_list_entities_valve_response); + return this->try_send_entity_info_(valve, msg, "valve", &APIConnection::send_list_entities_valve_response); } void APIConnection::valve_command(const ValveCommandRequest &msg) { valve::Valve *valve = App.get_valve_by_key(msg.key); @@ -1023,7 +1025,8 @@ bool APIConnection::try_send_media_player_info_(media_player::MediaPlayer *media media_format.sample_bytes = supported_format.sample_bytes; msg.supported_formats.push_back(media_format); } - return this->try_send_entity_info_(media_player, msg, &APIConnection::send_list_entities_media_player_response); + return this->try_send_entity_info_(media_player, msg, "media_player", + &APIConnection::send_list_entities_media_player_response); } void APIConnection::media_player_command(const MediaPlayerCommandRequest &msg) { media_player::MediaPlayer *media_player = App.get_media_player_by_key(msg.key); @@ -1062,7 +1065,7 @@ void APIConnection::send_camera_info(esp32_camera::ESP32Camera *camera) { } bool APIConnection::try_send_camera_info_(esp32_camera::ESP32Camera *camera) { ListEntitiesCameraResponse msg; - return this->try_send_entity_info_(camera, msg, &APIConnection::send_list_entities_camera_response); + return this->try_send_entity_info_(camera, msg, "camera", &APIConnection::send_list_entities_camera_response); } void APIConnection::camera_image(const CameraImageRequest &msg) { if (esp32_camera::global_esp32_camera == nullptr) @@ -1268,7 +1271,7 @@ bool APIConnection::try_send_alarm_control_panel_info_(alarm_control_panel::Alar msg.supported_features = a_alarm_control_panel->get_supported_features(); msg.requires_code = a_alarm_control_panel->get_requires_code(); msg.requires_code_to_arm = a_alarm_control_panel->get_requires_code_to_arm(); - return this->try_send_entity_info_(a_alarm_control_panel, msg, + return this->try_send_entity_info_(a_alarm_control_panel, msg, "alarm_control_panel", &APIConnection::send_list_entities_alarm_control_panel_response); } void APIConnection::alarm_control_panel_command(const AlarmControlPanelCommandRequest &msg) { @@ -1328,7 +1331,7 @@ bool APIConnection::try_send_event_info_(event::Event *event) { msg.device_class = event->get_device_class(); for (const auto &event_type : event->get_event_types()) msg.event_types.push_back(event_type); - return this->try_send_entity_info_(event, msg, &APIConnection::send_list_entities_event_response); + return this->try_send_entity_info_(event, msg, "event", &APIConnection::send_list_entities_event_response); } #endif @@ -1361,7 +1364,7 @@ bool APIConnection::try_send_update_state_(update::UpdateEntity *update) { bool APIConnection::try_send_update_info_(update::UpdateEntity *update) { ListEntitiesUpdateResponse msg; msg.device_class = update->get_device_class(); - return this->try_send_entity_info_(update, msg, &APIConnection::send_list_entities_update_response); + return this->try_send_entity_info_(update, msg, "update", &APIConnection::send_list_entities_update_response); } void APIConnection::update_command(const UpdateCommandRequest &msg) { update::UpdateEntity *update = App.get_update_by_key(msg.key); diff --git a/esphome/components/api/api_connection.h b/esphome/components/api/api_connection.h index a406629028..0e28e2edb0 100644 --- a/esphome/components/api/api_connection.h +++ b/esphome/components/api/api_connection.h @@ -497,7 +497,7 @@ class APIConnection : public APIServerConnection { * @return True if the message was sent successfully */ template - bool try_send_entity_info_(EntityT *entity, ResponseT &response, + bool try_send_entity_info_(EntityT *entity, ResponseT &response, const char *component_type, bool (APIServerConnectionBase::*send_response_func)(const ResponseT &)) { // Set common fields that are shared by all entity types response.key = entity->get_object_id_hash(); @@ -511,7 +511,7 @@ class APIConnection : public APIServerConnection { response.unique_id = entity->unique_id(); // Fall back to default if empty if (response.unique_id.empty()) - response.unique_id = get_default_unique_id(entity->get_component_type(), entity); + response.unique_id = get_default_unique_id(component_type, entity); // Set common EntityBase properties response.icon = entity->get_icon(); diff --git a/esphome/components/binary_sensor/binary_sensor.cpp b/esphome/components/binary_sensor/binary_sensor.cpp index 72842c1f5c..30fbe4f0b4 100644 --- a/esphome/components/binary_sensor/binary_sensor.cpp +++ b/esphome/components/binary_sensor/binary_sensor.cpp @@ -59,8 +59,6 @@ void BinarySensor::add_filters(const std::vector &filters) { bool BinarySensor::has_state() const { return this->has_state_; } bool BinarySensor::is_status_binary_sensor() const { return false; } -const char *BinarySensor::get_component_type() const { return "binary_sensor"; } - } // namespace binary_sensor } // namespace esphome diff --git a/esphome/components/binary_sensor/binary_sensor.h b/esphome/components/binary_sensor/binary_sensor.h index 9b5fb0dbe9..9ba7aeeeff 100644 --- a/esphome/components/binary_sensor/binary_sensor.h +++ b/esphome/components/binary_sensor/binary_sensor.h @@ -74,9 +74,6 @@ class BinarySensor : public EntityBase, public EntityBase_DeviceClass { virtual bool is_status_binary_sensor() const; - // Get the component type for this entity - const char *get_component_type() const override; - protected: CallbackManager state_callback_{}; Filter *filter_list_{nullptr}; diff --git a/esphome/components/button/button.cpp b/esphome/components/button/button.cpp index c4af6660a1..4c4cb7740c 100644 --- a/esphome/components/button/button.cpp +++ b/esphome/components/button/button.cpp @@ -13,7 +13,5 @@ void Button::press() { } void Button::add_on_press_callback(std::function &&callback) { this->press_callback_.add(std::move(callback)); } -const char *Button::get_component_type() const { return "button"; } - } // namespace button } // namespace esphome diff --git a/esphome/components/button/button.h b/esphome/components/button/button.h index 9fbcf67b64..9488eca221 100644 --- a/esphome/components/button/button.h +++ b/esphome/components/button/button.h @@ -40,8 +40,6 @@ class Button : public EntityBase, public EntityBase_DeviceClass { */ void add_on_press_callback(std::function &&callback); - const char *get_component_type() const override; - protected: /** You should implement this virtual method if you want to create your own button. */ diff --git a/esphome/components/climate/climate.cpp b/esphome/components/climate/climate.cpp index ff6ef22340..bc8d932089 100644 --- a/esphome/components/climate/climate.cpp +++ b/esphome/components/climate/climate.cpp @@ -566,8 +566,6 @@ bool Climate::set_custom_preset_(const std::string &preset) { return set_alternative(this->custom_preset, this->preset, preset); } -const char *Climate::get_component_type() const { return "climate"; } - void Climate::dump_traits_(const char *tag) { auto traits = this->get_traits(); ESP_LOGCONFIG(tag, "ClimateTraits:"); diff --git a/esphome/components/climate/climate.h b/esphome/components/climate/climate.h index fc31caff3f..d81702fb0c 100644 --- a/esphome/components/climate/climate.h +++ b/esphome/components/climate/climate.h @@ -169,8 +169,6 @@ class Climate : public EntityBase { public: Climate() {} - const char *get_component_type() const override; - /// The active mode of the climate device. ClimateMode mode{CLIMATE_MODE_OFF}; diff --git a/esphome/components/cover/cover.cpp b/esphome/components/cover/cover.cpp index e2083d5e78..d139bab8ee 100644 --- a/esphome/components/cover/cover.cpp +++ b/esphome/components/cover/cover.cpp @@ -207,7 +207,6 @@ optional Cover::restore_state_() { bool Cover::is_fully_open() const { return this->position == COVER_OPEN; } bool Cover::is_fully_closed() const { return this->position == COVER_CLOSED; } -const char *Cover::get_component_type() const { return "cover"; } CoverCall CoverRestoreState::to_call(Cover *cover) { auto call = cover->make_call(); diff --git a/esphome/components/cover/cover.h b/esphome/components/cover/cover.h index 2b6e6ea659..a7d017a64a 100644 --- a/esphome/components/cover/cover.h +++ b/esphome/components/cover/cover.h @@ -164,7 +164,6 @@ class Cover : public EntityBase, public EntityBase_DeviceClass { bool is_fully_closed() const; // Get the component type for this entity - const char *get_component_type() const override; protected: friend CoverCall; diff --git a/esphome/components/datetime/date_entity.h b/esphome/components/datetime/date_entity.h index bc71d4f67b..ce43c5639d 100644 --- a/esphome/components/datetime/date_entity.h +++ b/esphome/components/datetime/date_entity.h @@ -43,8 +43,6 @@ class DateEntity : public DateTimeBase { void publish_state(); DateCall make_call(); - const char *get_component_type() const override { return "date"; } - ESPTime state_as_esptime() const override { ESPTime obj; obj.year = this->year_; diff --git a/esphome/components/datetime/datetime_base.h b/esphome/components/datetime/datetime_base.h index ba2b47f457..dea34e6110 100644 --- a/esphome/components/datetime/datetime_base.h +++ b/esphome/components/datetime/datetime_base.h @@ -20,8 +20,6 @@ class DateTimeBase : public EntityBase { void add_on_state_callback(std::function &&callback) { this->state_callback_.add(std::move(callback)); } - const char *get_component_type() const override = 0; - #ifdef USE_TIME void set_rtc(time::RealTimeClock *rtc) { this->rtc_ = rtc; } time::RealTimeClock *get_rtc() const { return this->rtc_; } diff --git a/esphome/components/datetime/datetime_entity.h b/esphome/components/datetime/datetime_entity.h index 5fa87861ad..27db84cf7e 100644 --- a/esphome/components/datetime/datetime_entity.h +++ b/esphome/components/datetime/datetime_entity.h @@ -49,8 +49,6 @@ class DateTimeEntity : public DateTimeBase { void publish_state(); DateTimeCall make_call(); - const char *get_component_type() const override { return "datetime"; } - ESPTime state_as_esptime() const override; const uint16_t &year = year_; diff --git a/esphome/components/datetime/time_entity.h b/esphome/components/datetime/time_entity.h index e638f2f3ea..f7e0a7ddd9 100644 --- a/esphome/components/datetime/time_entity.h +++ b/esphome/components/datetime/time_entity.h @@ -44,8 +44,6 @@ class TimeEntity : public DateTimeBase { void publish_state(); TimeCall make_call(); - const char *get_component_type() const override { return "time"; } - ESPTime state_as_esptime() const override { ESPTime obj; obj.hour = this->hour_; diff --git a/esphome/components/event/event.cpp b/esphome/components/event/event.cpp index 561967d4c6..d27b3b378e 100644 --- a/esphome/components/event/event.cpp +++ b/esphome/components/event/event.cpp @@ -22,7 +22,5 @@ void Event::add_on_event_callback(std::functionevent_callback_.add(std::move(callback)); } -const char *Event::get_component_type() const { return "event"; } - } // namespace event } // namespace esphome diff --git a/esphome/components/event/event.h b/esphome/components/event/event.h index f4aba6d148..03c3c8d95a 100644 --- a/esphome/components/event/event.h +++ b/esphome/components/event/event.h @@ -30,8 +30,6 @@ class Event : public EntityBase, public EntityBase_DeviceClass { std::set get_event_types() const { return this->types_; } void add_on_event_callback(std::function &&callback); - const char *get_component_type() const override; - protected: CallbackManager event_callback_; std::set types_; diff --git a/esphome/components/fan/fan.cpp b/esphome/components/fan/fan.cpp index 353630420a..1d560d2fc6 100644 --- a/esphome/components/fan/fan.cpp +++ b/esphome/components/fan/fan.cpp @@ -205,7 +205,5 @@ void Fan::dump_traits_(const char *tag, const char *prefix) { } } -const char *Fan::get_component_type() const { return "fan"; } - } // namespace fan } // namespace esphome diff --git a/esphome/components/fan/fan.h b/esphome/components/fan/fan.h index 6d3b2c9bff..f5eae5a03d 100644 --- a/esphome/components/fan/fan.h +++ b/esphome/components/fan/fan.h @@ -133,7 +133,6 @@ class Fan : public EntityBase { void set_restore_mode(FanRestoreMode restore_mode) { this->restore_mode_ = restore_mode; } // Get the component type for this entity - const char *get_component_type() const override; protected: friend FanCall; diff --git a/esphome/components/light/light_state.cpp b/esphome/components/light/light_state.cpp index 8857cf38dd..16b78a17bd 100644 --- a/esphome/components/light/light_state.cpp +++ b/esphome/components/light/light_state.cpp @@ -11,8 +11,6 @@ static const char *const TAG = "light"; LightState::LightState(LightOutput *output) : output_(output) {} -const char *LightState::get_component_type() const { return "light"; } - LightTraits LightState::get_traits() { return this->output_->get_traits(); } LightCall LightState::turn_on() { return this->make_call().set_state(true); } LightCall LightState::turn_off() { return this->make_call().set_state(false); } diff --git a/esphome/components/light/light_state.h b/esphome/components/light/light_state.h index e84739010f..acba986f24 100644 --- a/esphome/components/light/light_state.h +++ b/esphome/components/light/light_state.h @@ -64,8 +64,6 @@ class LightState : public EntityBase, public Component { public: LightState(LightOutput *output); - const char *get_component_type() const override; - LightTraits get_traits(); /// Make a light state call diff --git a/esphome/components/lock/lock.cpp b/esphome/components/lock/lock.cpp index 46f53b2978..ddc5445349 100644 --- a/esphome/components/lock/lock.cpp +++ b/esphome/components/lock/lock.cpp @@ -57,8 +57,6 @@ void Lock::publish_state(LockState state) { void Lock::add_on_state_callback(std::function &&callback) { this->state_callback_.add(std::move(callback)); } -const char *Lock::get_component_type() const { return "lock"; } - void LockCall::perform() { ESP_LOGD(TAG, "'%s' - Setting", this->parent_->get_name().c_str()); this->validate_(); diff --git a/esphome/components/lock/lock.h b/esphome/components/lock/lock.h index 91fb631dc9..7a98187a4f 100644 --- a/esphome/components/lock/lock.h +++ b/esphome/components/lock/lock.h @@ -145,8 +145,6 @@ class Lock : public EntityBase { */ void add_on_state_callback(std::function &&callback); - const char *get_component_type() const override; - protected: friend LockCall; diff --git a/esphome/components/media_player/media_player.cpp b/esphome/components/media_player/media_player.cpp index 7cd84a7e9a..32da7ee265 100644 --- a/esphome/components/media_player/media_player.cpp +++ b/esphome/components/media_player/media_player.cpp @@ -137,7 +137,5 @@ void MediaPlayer::add_on_state_callback(std::function &&callback) { void MediaPlayer::publish_state() { this->state_callback_.call(); } -const char *MediaPlayer::get_component_type() const { return "media_player"; } - } // namespace media_player } // namespace esphome diff --git a/esphome/components/media_player/media_player.h b/esphome/components/media_player/media_player.h index 5398fedf44..ee5889901c 100644 --- a/esphome/components/media_player/media_player.h +++ b/esphome/components/media_player/media_player.h @@ -105,8 +105,6 @@ class MediaPlayer : public EntityBase { virtual MediaPlayerTraits get_traits() = 0; - const char *get_component_type() const override; - protected: friend MediaPlayerCall; diff --git a/esphome/components/number/number.cpp b/esphome/components/number/number.cpp index 22201c5998..fda4f43e34 100644 --- a/esphome/components/number/number.cpp +++ b/esphome/components/number/number.cpp @@ -17,7 +17,5 @@ void Number::add_on_state_callback(std::function &&callback) { this->state_callback_.add(std::move(callback)); } -const char *Number::get_component_type() const { return "number"; } - } // namespace number } // namespace esphome diff --git a/esphome/components/number/number.h b/esphome/components/number/number.h index bcd511458b..d839d12ad1 100644 --- a/esphome/components/number/number.h +++ b/esphome/components/number/number.h @@ -51,8 +51,6 @@ class Number : public EntityBase { /// Return whether this number has gotten a full state yet. bool has_state() const { return has_state_; } - const char *get_component_type() const override; - protected: friend class NumberCall; diff --git a/esphome/components/select/select.cpp b/esphome/components/select/select.cpp index 46cee71f96..806882ad94 100644 --- a/esphome/components/select/select.cpp +++ b/esphome/components/select/select.cpp @@ -58,7 +58,5 @@ optional Select::at(size_t index) const { } } -const char *Select::get_component_type() const { return "select"; } - } // namespace select } // namespace esphome diff --git a/esphome/components/select/select.h b/esphome/components/select/select.h index 331ef2a035..8ca9a69d1c 100644 --- a/esphome/components/select/select.h +++ b/esphome/components/select/select.h @@ -61,8 +61,6 @@ class Select : public EntityBase { void add_on_state_callback(std::function &&callback); - const char *get_component_type() const override; - protected: friend class SelectCall; diff --git a/esphome/components/sensor/sensor.cpp b/esphome/components/sensor/sensor.cpp index 8f56694daa..14a8b3d490 100644 --- a/esphome/components/sensor/sensor.cpp +++ b/esphome/components/sensor/sensor.cpp @@ -86,7 +86,6 @@ void Sensor::clear_filters() { float Sensor::get_state() const { return this->state; } float Sensor::get_raw_state() const { return this->raw_state; } std::string Sensor::unique_id() { return ""; } -const char *Sensor::get_component_type() const { return "sensor"; } void Sensor::internal_send_state_to_frontend(float state) { this->has_state_ = true; diff --git a/esphome/components/sensor/sensor.h b/esphome/components/sensor/sensor.h index e0376903ea..15a7459db1 100644 --- a/esphome/components/sensor/sensor.h +++ b/esphome/components/sensor/sensor.h @@ -146,7 +146,6 @@ class Sensor : public EntityBase, public EntityBase_DeviceClass, public EntityBa std::string unique_id() override; // Get the component type for this entity - const char *get_component_type() const override; void internal_send_state_to_frontend(float state); diff --git a/esphome/components/switch/switch.cpp b/esphome/components/switch/switch.cpp index 859f70b707..96611b0b87 100644 --- a/esphome/components/switch/switch.cpp +++ b/esphome/components/switch/switch.cpp @@ -62,7 +62,6 @@ void Switch::add_on_state_callback(std::function &&callback) { } void Switch::set_inverted(bool inverted) { this->inverted_ = inverted; } bool Switch::is_inverted() const { return this->inverted_; } -const char *Switch::get_component_type() const { return "switch"; } void log_switch(const char *tag, const char *prefix, const char *type, Switch *obj) { if (obj != nullptr) { diff --git a/esphome/components/switch/switch.h b/esphome/components/switch/switch.h index d55eceb019..2a0f59542e 100644 --- a/esphome/components/switch/switch.h +++ b/esphome/components/switch/switch.h @@ -113,7 +113,6 @@ class Switch : public EntityBase, public EntityBase_DeviceClass { void set_restore_mode(SwitchRestoreMode restore_mode) { this->restore_mode = restore_mode; } // Get the component type for this entity - const char *get_component_type() const override; protected: /** Write the given state to hardware. You should implement this diff --git a/esphome/components/text/text.cpp b/esphome/components/text/text.cpp index 195302d385..8f0242e747 100644 --- a/esphome/components/text/text.cpp +++ b/esphome/components/text/text.cpp @@ -22,7 +22,5 @@ void Text::add_on_state_callback(std::function &&callback) { this->state_callback_.add(std::move(callback)); } -const char *Text::get_component_type() const { return "text"; } - } // namespace text } // namespace esphome diff --git a/esphome/components/text/text.h b/esphome/components/text/text.h index 024aec3e5b..f71dde69ba 100644 --- a/esphome/components/text/text.h +++ b/esphome/components/text/text.h @@ -36,8 +36,6 @@ class Text : public EntityBase { void add_on_state_callback(std::function &&callback); - const char *get_component_type() const override; - protected: friend class TextCall; diff --git a/esphome/components/text_sensor/text_sensor.cpp b/esphome/components/text_sensor/text_sensor.cpp index 160c23ad76..f10cd50267 100644 --- a/esphome/components/text_sensor/text_sensor.cpp +++ b/esphome/components/text_sensor/text_sensor.cpp @@ -67,7 +67,6 @@ void TextSensor::internal_send_state_to_frontend(const std::string &state) { std::string TextSensor::unique_id() { return ""; } bool TextSensor::has_state() { return this->has_state_; } -const char *TextSensor::get_component_type() const { return "text_sensor"; } } // namespace text_sensor } // namespace esphome diff --git a/esphome/components/text_sensor/text_sensor.h b/esphome/components/text_sensor/text_sensor.h index 75b162b56d..5b7d1fdf43 100644 --- a/esphome/components/text_sensor/text_sensor.h +++ b/esphome/components/text_sensor/text_sensor.h @@ -72,7 +72,6 @@ class TextSensor : public EntityBase, public EntityBase_DeviceClass { void internal_send_state_to_frontend(const std::string &state); // Get the component type for this entity - const char *get_component_type() const override; protected: CallbackManager raw_callback_; ///< Storage for raw state callbacks. diff --git a/esphome/components/update/update_entity.cpp b/esphome/components/update/update_entity.cpp index 6d2a8d74b0..ed9a0480d8 100644 --- a/esphome/components/update/update_entity.cpp +++ b/esphome/components/update/update_entity.cpp @@ -34,7 +34,5 @@ void UpdateEntity::publish_state() { this->state_callback_.call(); } -const char *UpdateEntity::get_component_type() const { return "update"; } - } // namespace update } // namespace esphome diff --git a/esphome/components/update/update_entity.h b/esphome/components/update/update_entity.h index 51d3b6577f..cc269e288f 100644 --- a/esphome/components/update/update_entity.h +++ b/esphome/components/update/update_entity.h @@ -41,8 +41,6 @@ class UpdateEntity : public EntityBase, public EntityBase_DeviceClass { void add_on_state_callback(std::function &&callback) { this->state_callback_.add(std::move(callback)); } - const char *get_component_type() const override; - protected: UpdateState state_{UPDATE_STATE_UNKNOWN}; UpdateInfo update_info_; diff --git a/esphome/components/valve/valve.cpp b/esphome/components/valve/valve.cpp index 592237780e..d1ec17945a 100644 --- a/esphome/components/valve/valve.cpp +++ b/esphome/components/valve/valve.cpp @@ -165,8 +165,6 @@ optional Valve::restore_state_() { bool Valve::is_fully_open() const { return this->position == VALVE_OPEN; } bool Valve::is_fully_closed() const { return this->position == VALVE_CLOSED; } -const char *Valve::get_component_type() const { return "valve"; } - ValveCall ValveRestoreState::to_call(Valve *valve) { auto call = valve->make_call(); call.set_position(this->position); diff --git a/esphome/components/valve/valve.h b/esphome/components/valve/valve.h index 3c128d81bb..0e14a8d8f0 100644 --- a/esphome/components/valve/valve.h +++ b/esphome/components/valve/valve.h @@ -136,8 +136,6 @@ class Valve : public EntityBase, public EntityBase_DeviceClass { /// Helper method to check if the valve is fully closed. Equivalent to comparing .position against 0.0 bool is_fully_closed() const; - const char *get_component_type() const override; - protected: friend ValveCall; diff --git a/esphome/core/entity_base.h b/esphome/core/entity_base.h index 10c8a73095..f778de1514 100644 --- a/esphome/core/entity_base.h +++ b/esphome/core/entity_base.h @@ -33,10 +33,6 @@ class EntityBase { // that need custom unique IDs virtual std::string unique_id() { return ""; } - // Get the component type for this entity, must be overridden by entities - // Returns a static string stored in flash memory - virtual const char *get_component_type() const = 0; - // Get/set whether this Entity should be hidden from outside of ESPHome bool is_internal() const; void set_internal(bool internal);