2020-03-12 01:24:05 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "esphome/core/component.h"
|
|
|
|
#include "esphome/components/tuya/tuya.h"
|
|
|
|
#include "esphome/components/fan/fan_state.h"
|
|
|
|
|
|
|
|
namespace esphome {
|
|
|
|
namespace tuya {
|
|
|
|
|
|
|
|
class TuyaFan : public Component {
|
|
|
|
public:
|
2021-05-04 04:11:24 +02:00
|
|
|
TuyaFan(Tuya *parent, fan::FanState *fan, int speed_count) : parent_(parent), fan_(fan), speed_count_(speed_count) {}
|
2020-03-12 01:24:05 +01:00
|
|
|
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; }
|
2021-05-05 06:24:31 +02:00
|
|
|
void set_direction_id(uint8_t direction_id) { this->direction_id_ = direction_id; }
|
2020-03-12 01:24:05 +01:00
|
|
|
void write_state();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void update_speed_(uint32_t value);
|
|
|
|
void update_switch_(uint32_t value);
|
|
|
|
void update_oscillation_(uint32_t value);
|
2021-05-05 06:24:31 +02:00
|
|
|
void update_direction_(uint32_t value);
|
2020-03-12 01:24:05 +01:00
|
|
|
|
|
|
|
Tuya *parent_;
|
|
|
|
optional<uint8_t> speed_id_{};
|
|
|
|
optional<uint8_t> switch_id_{};
|
|
|
|
optional<uint8_t> oscillation_id_{};
|
2021-05-05 06:24:31 +02:00
|
|
|
optional<uint8_t> direction_id_{};
|
2020-03-12 01:24:05 +01:00
|
|
|
fan::FanState *fan_;
|
2021-05-04 04:11:24 +02:00
|
|
|
int speed_count_{};
|
2020-03-12 01:24:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace tuya
|
|
|
|
} // namespace esphome
|