mirror of
https://github.com/esphome/esphome.git
synced 2025-10-29 14:13:51 +00:00
missed
This commit is contained in:
@@ -401,7 +401,7 @@ uint16_t APIConnection::try_send_fan_state(EntityBase *entity, APIConnection *co
|
||||
bool is_single) {
|
||||
auto *fan = static_cast<fan::Fan *>(entity);
|
||||
FanStateResponse msg;
|
||||
auto traits = fan->get_traits();
|
||||
const auto &traits = fan->get_traits();
|
||||
msg.state = fan->state;
|
||||
if (traits.supports_oscillation())
|
||||
msg.oscillating = fan->oscillating;
|
||||
@@ -418,7 +418,7 @@ uint16_t APIConnection::try_send_fan_info(EntityBase *entity, APIConnection *con
|
||||
bool is_single) {
|
||||
auto *fan = static_cast<fan::Fan *>(entity);
|
||||
ListEntitiesFanResponse msg;
|
||||
auto traits = fan->get_traits();
|
||||
const auto &traits = fan->get_traits();
|
||||
msg.supports_oscillation = traits.supports_oscillation();
|
||||
msg.supports_speed = traits.supports_speed();
|
||||
msg.supports_direction = traits.supports_direction();
|
||||
|
||||
@@ -16,7 +16,7 @@ class BinaryFan : public Component, public fan::Fan {
|
||||
void set_oscillating(output::BinaryOutput *oscillating) { this->oscillating_ = oscillating; }
|
||||
void set_direction(output::BinaryOutput *direction) { this->direction_ = direction; }
|
||||
|
||||
fan::FanTraits get_traits() override;
|
||||
const fan::FanTraits &get_traits() override;
|
||||
|
||||
protected:
|
||||
void control(const fan::FanCall &call) override;
|
||||
|
||||
@@ -12,7 +12,7 @@ class CopyFan : public fan::Fan, public Component {
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
|
||||
fan::FanTraits get_traits() override;
|
||||
const fan::FanTraits &get_traits() override;
|
||||
|
||||
protected:
|
||||
void control(const fan::FanCall &call) override;
|
||||
|
||||
@@ -16,8 +16,9 @@ enum class DemoFanType {
|
||||
class DemoFan : public fan::Fan, public Component {
|
||||
public:
|
||||
void set_type(DemoFanType type) { type_ = type; }
|
||||
fan::FanTraits get_traits() override {
|
||||
fan::FanTraits traits{};
|
||||
const fan::FanTraits &get_traits() override {
|
||||
// Note: Demo fan builds traits dynamically, so we store it as a member
|
||||
this->traits_ = fan::FanTraits{};
|
||||
|
||||
// oscillation
|
||||
// speed
|
||||
@@ -27,22 +28,22 @@ class DemoFan : public fan::Fan, public Component {
|
||||
case DemoFanType::TYPE_1:
|
||||
break;
|
||||
case DemoFanType::TYPE_2:
|
||||
traits.set_oscillation(true);
|
||||
this->traits_.set_oscillation(true);
|
||||
break;
|
||||
case DemoFanType::TYPE_3:
|
||||
traits.set_direction(true);
|
||||
traits.set_speed(true);
|
||||
traits.set_supported_speed_count(5);
|
||||
this->traits_.set_direction(true);
|
||||
this->traits_.set_speed(true);
|
||||
this->traits_.set_supported_speed_count(5);
|
||||
break;
|
||||
case DemoFanType::TYPE_4:
|
||||
traits.set_direction(true);
|
||||
traits.set_speed(true);
|
||||
traits.set_supported_speed_count(100);
|
||||
traits.set_oscillation(true);
|
||||
this->traits_.set_direction(true);
|
||||
this->traits_.set_speed(true);
|
||||
this->traits_.set_supported_speed_count(100);
|
||||
this->traits_.set_oscillation(true);
|
||||
break;
|
||||
}
|
||||
|
||||
return traits;
|
||||
return this->traits_;
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -60,6 +61,7 @@ class DemoFan : public fan::Fan, public Component {
|
||||
}
|
||||
|
||||
DemoFanType type_;
|
||||
fan::FanTraits traits_;
|
||||
};
|
||||
|
||||
} // namespace demo
|
||||
|
||||
@@ -17,7 +17,7 @@ class TuyaFan : public Component, public fan::Fan {
|
||||
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;
|
||||
const fan::FanTraits &get_traits() override;
|
||||
|
||||
protected:
|
||||
void control(const fan::FanCall &call) override;
|
||||
|
||||
Reference in New Issue
Block a user