ESPHome 2025.5.0
Loading...
Searching...
No Matches
mqtt_fan.h
Go to the documentation of this file.
1#pragma once
2
4
5#ifdef USE_MQTT
6#ifdef USE_FAN
7
9#include "mqtt_component.h"
10
11namespace esphome {
12namespace mqtt {
13
15 public:
17
20 MQTT_COMPONENT_CUSTOM_TOPIC(oscillation, command)
22 MQTT_COMPONENT_CUSTOM_TOPIC(speed_level, command)
26
27 void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override;
28
29 // ========== INTERNAL METHODS ==========
30 // (In most use cases you won't need these)
32 void setup() override;
33
34 void dump_config() override;
35
37 bool send_initial_state() override;
38 bool publish_state();
40 std::string component_type() const override;
41
42 fan::Fan *get_state() const;
43
44 protected:
45 const EntityBase *get_entity() const override;
46
47 fan::Fan *state_;
48};
49
50} // namespace mqtt
51} // namespace esphome
52
53#endif
54#endif // USE_MQTT
MQTTComponent is the base class for all components that interact with MQTT to expose certain function...
fan::Fan * get_state() const
Definition mqtt_fan.cpp:18
const EntityBase * get_entity() const override
Definition mqtt_fan.cpp:20
state state state state void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override
Definition mqtt_fan.cpp:139
bool send_initial_state() override
Send the full current state to MQTT.
Definition mqtt_fan.cpp:137
std::string component_type() const override
'fan' component type for discovery.
Definition mqtt_fan.cpp:19
void setup() override
Setup the fan subscriptions and discovery.
Definition mqtt_fan.cpp:22
MQTT_COMPONENT_CUSTOM_TOPIC(direction, command) MQTT_COMPONENT_CUSTOM_TOPIC(direction
MQTTFanComponent(fan::Fan *state)
Definition mqtt_fan.cpp:16
FanDirection direction
Definition fan.h:3
bool state
Definition fan.h:0
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().