mirror of
https://github.com/esphome/esphome.git
synced 2024-11-25 00:18:11 +01:00
Button code cleanup (#3242)
This commit is contained in:
parent
f59dbe4a88
commit
d26141151a
2 changed files with 3 additions and 7 deletions
|
@ -18,11 +18,7 @@ void Button::add_on_press_callback(std::function<void()> &&callback) { this->pre
|
||||||
uint32_t Button::hash_base() { return 1495763804UL; }
|
uint32_t Button::hash_base() { return 1495763804UL; }
|
||||||
|
|
||||||
void Button::set_device_class(const std::string &device_class) { this->device_class_ = device_class; }
|
void Button::set_device_class(const std::string &device_class) { this->device_class_ = device_class; }
|
||||||
std::string Button::get_device_class() {
|
std::string Button::get_device_class() { return this->device_class_; }
|
||||||
if (this->device_class_.has_value())
|
|
||||||
return *this->device_class_;
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace button
|
} // namespace button
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
|
|
@ -45,12 +45,12 @@ class Button : public EntityBase {
|
||||||
protected:
|
protected:
|
||||||
/** You should implement this virtual method if you want to create your own button.
|
/** 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;
|
uint32_t hash_base() override;
|
||||||
|
|
||||||
CallbackManager<void()> press_callback_{};
|
CallbackManager<void()> press_callback_{};
|
||||||
optional<std::string> device_class_{};
|
std::string device_class_{};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace button
|
} // namespace button
|
||||||
|
|
Loading…
Reference in a new issue