ESPHome 2025.5.0
Loading...
Searching...
No Matches
mqtt_button.h
Go to the documentation of this file.
1#pragma once
2
4
5#ifdef USE_MQTT
6#ifdef USE_BUTTON
7
9#include "mqtt_component.h"
10
11namespace esphome {
12namespace mqtt {
13
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
34};
35
36} // namespace mqtt
37} // namespace esphome
38
39#endif
40#endif // USE_MQTT
Base class for all buttons.
Definition button.h:29
const EntityBase * get_entity() const override
void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override
std::string component_type() const override
"button" component type.
bool send_initial_state() override
Buttons do not send a state so just return true.
Definition mqtt_button.h:24
MQTTButtonComponent(button::Button *button)
MQTTComponent is the base class for all components that interact with MQTT to expose certain function...
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
Simple Helper struct used for Home Assistant MQTT send_discovery().