Files
esphome-dev/esphome/components/tuya/fan/tuya_fan.h
T
Oxan van Leeuwen 2a84db7f85 Refactor fan platform to resemble climate/cover platforms (#2848)
Co-authored-by: Oxan van Leeuwen <oxan@oxanvanleeuwen.nl>
Co-authored-by: rob-deutsch <robzyb+altgithub@gmail.com>
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
2022-01-23 22:21:54 +13:00

35 lines
1.0 KiB
C++

#pragma once
#include "esphome/core/component.h"
#include "esphome/components/tuya/tuya.h"
#include "esphome/components/fan/fan.h"
namespace esphome {
namespace tuya {
class TuyaFan : public Component, public fan::Fan {
public:
TuyaFan(Tuya *parent, int speed_count) : parent_(parent), speed_count_(speed_count) {}
void setup() override;
void dump_config() override;
void set_speed_id(uint8_t speed_id) { this->speed_id_ = speed_id; }
void set_switch_id(uint8_t switch_id) { this->switch_id_ = switch_id; }
void set_oscillation_id(uint8_t oscillation_id) { this->oscillation_id_ = oscillation_id; }
void set_direction_id(uint8_t direction_id) { this->direction_id_ = direction_id; }
fan::FanTraits get_traits() override;
protected:
void control(const fan::FanCall &call) override;
Tuya *parent_;
optional<uint8_t> speed_id_{};
optional<uint8_t> switch_id_{};
optional<uint8_t> oscillation_id_{};
optional<uint8_t> direction_id_{};
int speed_count_{};
};
} // namespace tuya
} // namespace esphome