ESPHome  2024.11.3
mqtt_event.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_EVENT
7 
9 #include "mqtt_component.h"
10 
11 namespace esphome {
12 namespace mqtt {
13 
15  public:
16  explicit MQTTEventComponent(event::Event *event);
17 
18  void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override;
19 
20  void setup() override;
21 
22  void dump_config() override;
23 
25  bool send_initial_state() override { return true; }
26 
27  protected:
28  bool publish_event_(const std::string &event_type);
29  std::string component_type() const override;
30  const EntityBase *get_entity() const override;
31 
33 };
34 
35 } // namespace mqtt
36 } // namespace esphome
37 
38 #endif
39 #endif // USE_MQTT
std::string component_type() const override
Definition: mqtt_event.cpp:47
MQTTEventComponent(event::Event *event)
Definition: mqtt_event.cpp:16
const EntityBase * get_entity() const override
Definition: mqtt_event.cpp:48
Simple Helper struct used for Home Assistant MQTT send_discovery().
void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override
Definition: mqtt_event.cpp:18
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
bool send_initial_state() override
Events do not send a state so just return true.
Definition: mqtt_event.h:25
bool publish_event_(const std::string &event_type)
Definition: mqtt_event.cpp:42
MQTTComponent is the base class for all components that interact with MQTT to expose certain function...