1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-06 01:51:49 +00:00
This commit is contained in:
J. Nick Koston
2025-10-28 22:47:36 -05:00
parent 47cbe74453
commit bb99f68d33
6 changed files with 13 additions and 17 deletions

View File

@@ -425,7 +425,7 @@ message ListEntitiesFanResponse {
bool disabled_by_default = 9; bool disabled_by_default = 9;
string icon = 10 [(field_ifdef) = "USE_ENTITY_ICON"]; string icon = 10 [(field_ifdef) = "USE_ENTITY_ICON"];
EntityCategory entity_category = 11; EntityCategory entity_category = 11;
repeated string supported_preset_modes = 12 [(container_pointer_no_template) = "FixedVector<const char *>"]; repeated string supported_preset_modes = 12 [(container_pointer_no_template) = "std::vector<const char *>"];
uint32 device_id = 13 [(field_ifdef) = "USE_DEVICES"]; uint32 device_id = 13 [(field_ifdef) = "USE_DEVICES"];
} }
// Deprecated in API version 1.6 - only used in deprecated fields // Deprecated in API version 1.6 - only used in deprecated fields

View File

@@ -725,7 +725,7 @@ class ListEntitiesFanResponse final : public InfoResponseProtoMessage {
bool supports_speed{false}; bool supports_speed{false};
bool supports_direction{false}; bool supports_direction{false};
int32_t supported_speed_count{0}; int32_t supported_speed_count{0};
const FixedVector<const char *> *supported_preset_modes{}; const std::vector<const char *> *supported_preset_modes{};
void encode(ProtoWriteBuffer buffer) const override; void encode(ProtoWriteBuffer buffer) const override;
void calculate_size(ProtoSize &size) const override; void calculate_size(ProtoSize &size) const override;
#ifdef HAS_PROTO_MESSAGE_DUMP #ifdef HAS_PROTO_MESSAGE_DUMP

View File

@@ -1,16 +1,10 @@
#pragma once #pragma once
#include "esphome/core/helpers.h" #include <vector>
#include <initializer_list> #include <initializer_list>
namespace esphome { namespace esphome {
#ifdef USE_API
namespace api {
class APIConnection;
} // namespace api
#endif
namespace fan { namespace fan {
class FanTraits { class FanTraits {
@@ -36,11 +30,13 @@ class FanTraits {
/// Set whether this fan supports changing direction /// Set whether this fan supports changing direction
void set_direction(bool direction) { this->direction_ = direction; } void set_direction(bool direction) { this->direction_ = direction; }
/// Return the preset modes supported by the fan. /// Return the preset modes supported by the fan.
const FixedVector<const char *> &supported_preset_modes() const { return this->preset_modes_; } const std::vector<const char *> &supported_preset_modes() const { return this->preset_modes_; }
/// Set the preset modes supported by the fan (from initializer list). /// Set the preset modes supported by the fan (from initializer list).
void set_supported_preset_modes(const std::initializer_list<const char *> &preset_modes); void set_supported_preset_modes(std::initializer_list<const char *> preset_modes) {
/// Set the preset modes supported by the fan (from FixedVector). this->preset_modes_ = preset_modes;
void set_supported_preset_modes(const FixedVector<const char *> &preset_modes); }
/// Set the preset modes supported by the fan (from vector).
void set_supported_preset_modes(const std::vector<const char *> &preset_modes) { this->preset_modes_ = preset_modes; }
/// Return if preset modes are supported /// Return if preset modes are supported
bool supports_preset_modes() const { return !this->preset_modes_.empty(); } bool supports_preset_modes() const { return !this->preset_modes_.empty(); }
@@ -49,7 +45,7 @@ class FanTraits {
bool speed_{false}; bool speed_{false};
bool direction_{false}; bool direction_{false};
int speed_count_{}; int speed_count_{};
FixedVector<const char *> preset_modes_{}; std::vector<const char *> preset_modes_{};
}; };
} // namespace fan } // namespace fan

View File

@@ -36,7 +36,7 @@ class HBridgeFan : public Component, public fan::Fan {
int speed_count_{}; int speed_count_{};
DecayMode decay_mode_{DECAY_MODE_SLOW}; DecayMode decay_mode_{DECAY_MODE_SLOW};
fan::FanTraits traits_; fan::FanTraits traits_;
FixedVector<const char *> preset_modes_{}; std::vector<const char *> preset_modes_{};
void control(const fan::FanCall &call) override; void control(const fan::FanCall &call) override;
void write_state_(); void write_state_();

View File

@@ -28,7 +28,7 @@ class SpeedFan : public Component, public fan::Fan {
output::BinaryOutput *direction_{nullptr}; output::BinaryOutput *direction_{nullptr};
int speed_count_{}; int speed_count_{};
fan::FanTraits traits_; fan::FanTraits traits_;
FixedVector<const char *> preset_modes_{}; std::vector<const char *> preset_modes_{};
}; };
} // namespace speed } // namespace speed

View File

@@ -24,7 +24,7 @@ class TemplateFan : public Component, public fan::Fan {
bool has_direction_{false}; bool has_direction_{false};
int speed_count_{0}; int speed_count_{0};
fan::FanTraits traits_; fan::FanTraits traits_;
FixedVector<const char *> preset_modes_{}; std::vector<const char *> preset_modes_{};
}; };
} // namespace template_ } // namespace template_