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