Files
esphome-dev/esphome/components/mqtt/mqtt_fan.h
T
wifwucite fd836e982e Mqtt topics to support numeric fan speed (#1859)
* numeric speed added

* when dumping config for MQTT components log a note when skipped due to is_internal

* added new topics to paython code validation/generation

* reformatted with black

* formatting corrected

* use dump_config_ mechanism to skip internal components

* use dump_config_ mechanism to skip internal components

* style issues resolved

* do_dump_config removed

* formatting fixed

* formatting fixed

* Drop parent dump_config() calls

Co-authored-by: Oxan van Leeuwen <oxan@oxanvanleeuwen.nl>
2021-09-22 13:42:58 +02:00

55 lines
1.3 KiB
C++

#pragma once
#include "esphome/core/defines.h"
#ifdef USE_MQTT
#ifdef USE_FAN
#include "esphome/components/fan/fan_state.h"
#include "mqtt_component.h"
namespace esphome {
namespace mqtt {
class MQTTFanComponent : public mqtt::MQTTComponent {
public:
explicit MQTTFanComponent(fan::FanState *state);
MQTT_COMPONENT_CUSTOM_TOPIC(oscillation, command)
MQTT_COMPONENT_CUSTOM_TOPIC(oscillation, state)
MQTT_COMPONENT_CUSTOM_TOPIC(speed_level, command)
MQTT_COMPONENT_CUSTOM_TOPIC(speed_level, state)
MQTT_COMPONENT_CUSTOM_TOPIC(speed, command)
MQTT_COMPONENT_CUSTOM_TOPIC(speed, state)
void send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) override;
// ========== INTERNAL METHODS ==========
// (In most use cases you won't need these)
/// Setup the fan subscriptions and discovery.
void setup() override;
void dump_config() override;
/// Send the full current state to MQTT.
bool send_initial_state() override;
bool publish_state();
/// 'fan' component type for discovery.
std::string component_type() const override;
fan::FanState *get_state() const;
bool is_internal() override;
protected:
std::string friendly_name() const override;
fan::FanState *state_;
};
} // namespace mqtt
} // namespace esphome
#endif
#endif // USE_MQTT