diff --git a/esphome/components/ld2410/button/__init__.py b/esphome/components/ld2410/button/__init__.py index 21618babe79..97167ea81ba 100644 --- a/esphome/components/ld2410/button/__init__.py +++ b/esphome/components/ld2410/button/__init__.py @@ -15,29 +15,25 @@ from esphome.const import ( ) from esphome.types import ConfigType -from .. import CONF_LD2410_ID, LD2410Component, ld2410_ns - -FactoryResetButton = ld2410_ns.class_("FactoryResetButton", button.Button) -QueryButton = ld2410_ns.class_("QueryButton", button.Button) -RestartButton = ld2410_ns.class_("RestartButton", button.Button) +from .. import CONF_LD2410_ID, LD2410Component CONFIG_SCHEMA = { cv.GenerateID(CONF_ID): cv.declare_id(cg.EntityBase), cv.GenerateID(CONF_LD2410_ID): cv.use_id(LD2410Component), cv.Optional(CONF_FACTORY_RESET): button.button_schema( - FactoryResetButton, + button.ApplyButton, device_class=DEVICE_CLASS_RESTART, entity_category=ENTITY_CATEGORY_CONFIG, icon=ICON_RESTART_ALERT, ), cv.Optional(CONF_RESTART): button.button_schema( - RestartButton, + button.ApplyButton, device_class=DEVICE_CLASS_RESTART, entity_category=ENTITY_CATEGORY_DIAGNOSTIC, icon=ICON_RESTART, ), cv.Optional(CONF_QUERY_PARAMS): button.button_schema( - QueryButton, + button.ApplyButton, entity_category=ENTITY_CATEGORY_DIAGNOSTIC, icon=ICON_DATABASE, ), @@ -47,6 +43,10 @@ CONFIG_SCHEMA = { async def to_code(config: ConfigType) -> None: hub = await cg.get_variable(config[CONF_LD2410_ID]) buttons = button.sub_buttons(config, parent=hub) - await buttons(CONF_FACTORY_RESET, hub.set_factory_reset_button) - await buttons(CONF_RESTART, hub.set_restart_button) - await buttons(CONF_QUERY_PARAMS, hub.set_query_button) + await buttons( + CONF_FACTORY_RESET, hub.set_factory_reset_button, apply="factory_reset()" + ) + await buttons( + CONF_RESTART, hub.set_restart_button, apply="restart_and_read_all_info()" + ) + await buttons(CONF_QUERY_PARAMS, hub.set_query_button, apply="read_all_info()") diff --git a/esphome/components/ld2410/button/factory_reset_button.cpp b/esphome/components/ld2410/button/factory_reset_button.cpp deleted file mode 100644 index 0223df70868..00000000000 --- a/esphome/components/ld2410/button/factory_reset_button.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "factory_reset_button.h" - -namespace esphome::ld2410 { - -void FactoryResetButton::press_action() { this->parent_->factory_reset(); } - -} // namespace esphome::ld2410 diff --git a/esphome/components/ld2410/button/factory_reset_button.h b/esphome/components/ld2410/button/factory_reset_button.h deleted file mode 100644 index 1da7c813375..00000000000 --- a/esphome/components/ld2410/button/factory_reset_button.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include "esphome/components/button/button.h" -#include "../ld2410.h" - -namespace esphome::ld2410 { - -class FactoryResetButton final : public button::Button, public Parented { - public: - FactoryResetButton() = default; - - protected: - void press_action() override; -}; - -} // namespace esphome::ld2410 diff --git a/esphome/components/ld2410/button/query_button.cpp b/esphome/components/ld2410/button/query_button.cpp deleted file mode 100644 index 4085dc3d11e..00000000000 --- a/esphome/components/ld2410/button/query_button.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "query_button.h" - -namespace esphome::ld2410 { - -void QueryButton::press_action() { this->parent_->read_all_info(); } - -} // namespace esphome::ld2410 diff --git a/esphome/components/ld2410/button/query_button.h b/esphome/components/ld2410/button/query_button.h deleted file mode 100644 index 4f3f147e673..00000000000 --- a/esphome/components/ld2410/button/query_button.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include "esphome/components/button/button.h" -#include "../ld2410.h" - -namespace esphome::ld2410 { - -class QueryButton final : public button::Button, public Parented { - public: - QueryButton() = default; - - protected: - void press_action() override; -}; - -} // namespace esphome::ld2410 diff --git a/esphome/components/ld2410/button/restart_button.cpp b/esphome/components/ld2410/button/restart_button.cpp deleted file mode 100644 index 0d5002d3c63..00000000000 --- a/esphome/components/ld2410/button/restart_button.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "restart_button.h" - -namespace esphome::ld2410 { - -void RestartButton::press_action() { this->parent_->restart_and_read_all_info(); } - -} // namespace esphome::ld2410 diff --git a/esphome/components/ld2410/button/restart_button.h b/esphome/components/ld2410/button/restart_button.h deleted file mode 100644 index 70e0a74c9a5..00000000000 --- a/esphome/components/ld2410/button/restart_button.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include "esphome/components/button/button.h" -#include "../ld2410.h" - -namespace esphome::ld2410 { - -class RestartButton final : public button::Button, public Parented { - public: - RestartButton() = default; - - protected: - void press_action() override; -}; - -} // namespace esphome::ld2410