ESPHome 2026.1.4
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::mqtt {
12
14 public:
15 explicit MQTTButtonComponent(button::Button *button);
16
17 // ========== INTERNAL METHODS ==========
18 // (In most use cases you won't need these)
19 void setup() override;
20 void dump_config() override;
21
23 bool send_initial_state() override { return true; }
24
25 void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override;
26
27 protected:
29 const char *component_type() const override;
30 const EntityBase *get_entity() const override;
31
33};
34
35} // namespace esphome::mqtt
36
37#endif
38#endif // USE_MQTT
Base class for all buttons.
Definition button.h:25
const EntityBase * get_entity() const override
void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override
const char * 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:23
MQTTButtonComponent(button::Button *button)
MQTTComponent is the base class for all components that interact with MQTT to expose certain function...
Simple Helper struct used for Home Assistant MQTT send_discovery().