ESPHome
2024.11.0
esphome
esphome
components
mqtt
mqtt_button.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
esphome/core/defines.h
"
4
5
#ifdef USE_MQTT
6
#ifdef USE_BUTTON
7
8
#include "
esphome/components/button/button.h
"
9
#include "
mqtt_component.h
"
10
11
namespace
esphome
{
12
namespace
mqtt {
13
14
class
MQTTButtonComponent
:
public
mqtt::MQTTComponent
{
15
public
:
16
explicit
MQTTButtonComponent
(
button::Button
*button);
17
18
// ========== INTERNAL METHODS ==========
19
// (In most use cases you won't need these)
20
void
setup
()
override
;
21
void
dump_config
()
override
;
22
24
bool
send_initial_state
()
override
{
return
true
; }
25
26
void
send_discovery
(JsonObject root,
mqtt::SendDiscoveryConfig
&config)
override
;
27
28
protected
:
30
std::string
component_type
()
const override
;
31
const
EntityBase
*
get_entity
()
const override
;
32
33
button::Button
*
button_
;
34
};
35
36
}
// namespace mqtt
37
}
// namespace esphome
38
39
#endif
40
#endif // USE_MQTT
esphome::mqtt::MQTTButtonComponent::MQTTButtonComponent
MQTTButtonComponent(button::Button *button)
Definition:
mqtt_button.cpp:16
esphome::mqtt::MQTTButtonComponent::send_initial_state
bool send_initial_state() override
Buttons do not send a state so just return true.
Definition:
mqtt_button.h:24
esphome::button::Button
Base class for all buttons.
Definition:
button.h:29
esphome::mqtt::MQTTButtonComponent::button_
button::Button * button_
Definition:
mqtt_button.h:33
esphome::mqtt::MQTTButtonComponent::setup
void setup() override
Definition:
mqtt_button.cpp:18
mqtt_component.h
button.h
esphome::mqtt::MQTTButtonComponent::component_type
std::string component_type() const override
"button" component type.
Definition:
mqtt_button.cpp:39
esphome::mqtt::MQTTButtonComponent::dump_config
void dump_config() override
Definition:
mqtt_button.cpp:28
defines.h
esphome::mqtt::SendDiscoveryConfig
Simple Helper struct used for Home Assistant MQTT send_discovery().
Definition:
mqtt_component.h:18
esphome::EntityBase
Definition:
entity_base.h:16
esphome::mqtt::MQTTButtonComponent
Definition:
mqtt_button.h:14
esphome::mqtt::MQTTButtonComponent::send_discovery
void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override
Definition:
mqtt_button.cpp:33
esphome
Implementation of SPI Controller mode.
Definition:
a01nyub.cpp:7
esphome::mqtt::MQTTButtonComponent::get_entity
const EntityBase * get_entity() const override
Definition:
mqtt_button.cpp:40
esphome::mqtt::MQTTComponent
MQTTComponent is the base class for all components that interact with MQTT to expose certain function...
Definition:
mqtt_component.h:61
Generated by
1.8.13