diff --git a/esphome/components/button/button.cpp b/esphome/components/button/button.cpp index d57b46e9aa..0a5c6567bc 100644 --- a/esphome/components/button/button.cpp +++ b/esphome/components/button/button.cpp @@ -18,11 +18,7 @@ void Button::add_on_press_callback(std::function &&callback) { this->pre uint32_t Button::hash_base() { return 1495763804UL; } void Button::set_device_class(const std::string &device_class) { this->device_class_ = device_class; } -std::string Button::get_device_class() { - if (this->device_class_.has_value()) - return *this->device_class_; - return ""; -} +std::string Button::get_device_class() { return this->device_class_; } } // namespace button } // namespace esphome diff --git a/esphome/components/button/button.h b/esphome/components/button/button.h index b21a96b8e1..f60c2a2bc5 100644 --- a/esphome/components/button/button.h +++ b/esphome/components/button/button.h @@ -45,12 +45,12 @@ class Button : public EntityBase { protected: /** You should implement this virtual method if you want to create your own button. */ - virtual void press_action(){}; + virtual void press_action() = 0; uint32_t hash_base() override; CallbackManager press_callback_{}; - optional device_class_{}; + std::string device_class_{}; }; } // namespace button