ESPHome
2023.3.2
|
Base class for all buttons. More...
#include <button.h>
Public Member Functions | |
Button () | |
Button (const std::string &name) | |
void | press () |
Press this button. More... | |
void | add_on_press_callback (std::function< void()> &&callback) |
Set callback for state changes. More... | |
void | set_device_class (const std::string &device_class) |
Set the Home Assistant device class (see button::device_class). More... | |
std::string | get_device_class () |
Get the device class for this button. More... | |
![]() | |
EntityBase () | |
EntityBase (std::string name) | |
const std::string & | get_name () const |
void | set_name (const std::string &name) |
const std::string & | get_object_id () |
uint32_t | get_object_id_hash () |
bool | is_internal () const |
void | set_internal (bool internal) |
bool | is_disabled_by_default () const |
void | set_disabled_by_default (bool disabled_by_default) |
EntityCategory | get_entity_category () const |
void | set_entity_category (EntityCategory entity_category) |
const std::string & | get_icon () const |
void | set_icon (const std::string &name) |
Protected Member Functions | |
virtual void | press_action ()=0 |
You should implement this virtual method if you want to create your own button. More... | |
![]() | |
virtual uint32_t | hash_base () |
The hash_base() function has been deprecated. More... | |
void | calc_object_id_ () |
Protected Attributes | |
CallbackManager< void()> | press_callback_ {} |
std::string | device_class_ {} |
![]() | |
std::string | name_ |
std::string | object_id_ |
std::string | icon_ |
uint32_t | object_id_hash_ |
bool | internal_ {false} |
bool | disabled_by_default_ {false} |
EntityCategory | entity_category_ {ENTITY_CATEGORY_NONE} |
Base class for all buttons.
A button is just a momentary switch that does not have a state, only a trigger.
|
explicit |
Definition at line 10 of file button.cpp.
|
explicit |
Definition at line 9 of file button.cpp.
void esphome::button::Button::add_on_press_callback | ( | std::function< void()> && | callback | ) |
Set callback for state changes.
callback | The void() callback. |
Definition at line 17 of file button.cpp.
std::string esphome::button::Button::get_device_class | ( | ) |
Get the device class for this button.
Definition at line 20 of file button.cpp.
void esphome::button::Button::press | ( | ) |
Press this button.
This is called by the front-end.
For implementing buttons, please override press_action.
Definition at line 12 of file button.cpp.
|
protectedpure virtual |
You should implement this virtual method if you want to create your own button.
Implemented in esphome::wake_on_lan::WakeOnLanButton, esphome::output::OutputButton, esphome::safe_mode::SafeModeButton, esphome::copy::CopyButton, esphome::factory_reset::FactoryResetButton, esphome::restart::RestartButton, esphome::shutdown::ShutdownButton, and esphome::template_::TemplateButton.
void esphome::button::Button::set_device_class | ( | const std::string & | device_class | ) |
Set the Home Assistant device class (see button::device_class).
Definition at line 19 of file button.cpp.
|
protected |
|
protected |