ESPHome 2026.2.4
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::mqtt {
12
14 public:
16
19 MQTT_COMPONENT_CUSTOM_TOPIC(oscillation, command)
21 MQTT_COMPONENT_CUSTOM_TOPIC(speed_level, command)
25
26 void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override;
27
28 // ========== INTERNAL METHODS ==========
29 // (In most use cases you won't need these)
31 void setup() override;
32
33 void dump_config() override;
34
36 bool send_initial_state() override;
37 bool publish_state();
39 const char *component_type() const override;
40
41 fan::Fan *get_state() const;
42
43 protected:
44 const EntityBase *get_entity() const override;
45
46 fan::Fan *state_;
47};
48
49} // namespace esphome::mqtt
50
51#endif
52#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:26
const EntityBase * get_entity() const override
state state state state void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override
Definition mqtt_fan.cpp:153
bool send_initial_state() override
Send the full current state to MQTT.
Definition mqtt_fan.cpp:151
void setup() override
Setup the fan subscriptions and discovery.
MQTT_COMPONENT_CUSTOM_TOPIC(direction, command) MQTT_COMPONENT_CUSTOM_TOPIC(direction
const char * component_type() const override
'fan' component type for discovery.
MQTTFanComponent(fan::Fan *state)
Definition mqtt_fan.cpp:24
FanDirection direction
Definition fan.h:5
bool state
Definition fan.h:2
Simple Helper struct used for Home Assistant MQTT send_discovery().