mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-05 20:38:27 +02:00
Co-authored-by: Frank Riley <fhriley@gmail.com>
This commit is contained in:
@@ -8,18 +8,15 @@ namespace tuya {
|
||||
static const char *TAG = "tuya.fan";
|
||||
|
||||
void TuyaFan::setup() {
|
||||
auto traits = fan::FanTraits(this->oscillation_id_.has_value(), this->speed_id_.has_value(), false, 3);
|
||||
auto traits =
|
||||
fan::FanTraits(this->oscillation_id_.has_value(), this->speed_id_.has_value(), false, this->speed_count_);
|
||||
this->fan_->set_traits(traits);
|
||||
|
||||
if (this->speed_id_.has_value()) {
|
||||
this->parent_->register_listener(*this->speed_id_, [this](TuyaDatapoint datapoint) {
|
||||
auto call = this->fan_->make_call();
|
||||
if (datapoint.value_enum == 0x0)
|
||||
call.set_speed(1);
|
||||
else if (datapoint.value_enum == 0x1)
|
||||
call.set_speed(2);
|
||||
else if (datapoint.value_enum == 0x2)
|
||||
call.set_speed(3);
|
||||
if (datapoint.value_enum < this->speed_count_)
|
||||
call.set_speed(datapoint.value_enum + 1);
|
||||
else
|
||||
ESP_LOGCONFIG(TAG, "Speed has invalid value %d", datapoint.value_enum);
|
||||
ESP_LOGD(TAG, "MCU reported speed of: %d", datapoint.value_enum);
|
||||
@@ -47,6 +44,7 @@ void TuyaFan::setup() {
|
||||
|
||||
void TuyaFan::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "Tuya Fan:");
|
||||
ESP_LOGCONFIG(TAG, " Speed count %d", this->speed_count_);
|
||||
if (this->speed_id_.has_value())
|
||||
ESP_LOGCONFIG(TAG, " Speed has datapoint ID %u", *this->speed_id_);
|
||||
if (this->switch_id_.has_value())
|
||||
|
||||
Reference in New Issue
Block a user