7 static const char *
const TAG =
"tuya.fan";
13 ESP_LOGV(TAG,
"MCU reported speed of: %d", datapoint.value_enum);
14 if (datapoint.value_enum >= this->speed_count_) {
15 ESP_LOGE(TAG,
"Speed has invalid value %d", datapoint.value_enum);
17 this->speed = datapoint.value_enum + 1;
18 this->publish_state();
21 ESP_LOGV(TAG,
"MCU reported speed of: %d", datapoint.value_int);
22 this->speed = datapoint.value_int;
23 this->publish_state();
25 this->speed_type_ = datapoint.
type;
30 ESP_LOGV(TAG,
"MCU reported switch is: %s", ONOFF(datapoint.
value_bool));
39 ESP_LOGV(TAG,
"MCU reported oscillation is: %s", ONOFF(datapoint.
value_bool));
48 ESP_LOGD(TAG,
"MCU reported reverse direction is: %s", ONOFF(datapoint.
value_bool));
57 restored->to_call(*this).perform();
62 LOG_FAN(
"",
"Tuya Fan",
this);
64 ESP_LOGCONFIG(TAG,
" Speed has datapoint ID %u", *this->
speed_id_);
67 ESP_LOGCONFIG(TAG,
" Switch has datapoint ID %u", *this->
switch_id_);
70 ESP_LOGCONFIG(TAG,
" Oscillation has datapoint ID %u", *this->
oscillation_id_);
73 ESP_LOGCONFIG(TAG,
" Direction has datapoint ID %u", *this->
direction_id_);
bool state
The current on/off state of the fan.
bool oscillating
The current oscillation state of the fan.
fan::FanTraits get_traits() override
void set_enum_datapoint_value(uint8_t datapoint_id, uint8_t value)
FanDirection direction
The current direction of the fan.
optional< FanDirection > get_direction() const
optional< int > get_speed() const
optional< FanRestoreState > restore_state_()
void register_listener(uint8_t datapoint_id, const std::function< void(TuyaDatapoint)> &func)
void add_on_initialized_callback(std::function< void()> callback)
optional< uint8_t > switch_id_
optional< bool > get_state() const
optional< bool > get_oscillating() const
void control(const fan::FanCall &call) override
optional< uint8_t > oscillation_id_
void set_boolean_datapoint_value(uint8_t datapoint_id, bool value)
void dump_config() override
void set_integer_datapoint_value(uint8_t datapoint_id, uint32_t value)
TuyaDatapointType speed_type_
TuyaDatapointType oscillation_type_
Implementation of SPI Controller mode.
optional< uint8_t > direction_id_
optional< uint8_t > speed_id_