mirror of
https://github.com/esphome/esphome.git
synced 2025-09-07 05:42:20 +01:00
Add support for fan preset modes (#5694)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
@@ -1375,6 +1375,10 @@ bool ListEntitiesFanResponse::decode_length(uint32_t field_id, ProtoLengthDelimi
|
||||
this->icon = value.as_string();
|
||||
return true;
|
||||
}
|
||||
case 12: {
|
||||
this->supported_preset_modes.push_back(value.as_string());
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -1401,6 +1405,9 @@ void ListEntitiesFanResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_bool(9, this->disabled_by_default);
|
||||
buffer.encode_string(10, this->icon);
|
||||
buffer.encode_enum<enums::EntityCategory>(11, this->entity_category);
|
||||
for (auto &it : this->supported_preset_modes) {
|
||||
buffer.encode_string(12, it, true);
|
||||
}
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
void ListEntitiesFanResponse::dump_to(std::string &out) const {
|
||||
@@ -1451,6 +1458,12 @@ void ListEntitiesFanResponse::dump_to(std::string &out) const {
|
||||
out.append(" entity_category: ");
|
||||
out.append(proto_enum_to_string<enums::EntityCategory>(this->entity_category));
|
||||
out.append("\n");
|
||||
|
||||
for (const auto &it : this->supported_preset_modes) {
|
||||
out.append(" supported_preset_modes: ");
|
||||
out.append("'").append(it).append("'");
|
||||
out.append("\n");
|
||||
}
|
||||
out.append("}");
|
||||
}
|
||||
#endif
|
||||
@@ -1480,6 +1493,16 @@ bool FanStateResponse::decode_varint(uint32_t field_id, ProtoVarInt value) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool FanStateResponse::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
|
||||
switch (field_id) {
|
||||
case 7: {
|
||||
this->preset_mode = value.as_string();
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool FanStateResponse::decode_32bit(uint32_t field_id, Proto32Bit value) {
|
||||
switch (field_id) {
|
||||
case 1: {
|
||||
@@ -1497,6 +1520,7 @@ void FanStateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_enum<enums::FanSpeed>(4, this->speed);
|
||||
buffer.encode_enum<enums::FanDirection>(5, this->direction);
|
||||
buffer.encode_int32(6, this->speed_level);
|
||||
buffer.encode_string(7, this->preset_mode);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
void FanStateResponse::dump_to(std::string &out) const {
|
||||
@@ -1527,6 +1551,10 @@ void FanStateResponse::dump_to(std::string &out) const {
|
||||
sprintf(buffer, "%" PRId32, this->speed_level);
|
||||
out.append(buffer);
|
||||
out.append("\n");
|
||||
|
||||
out.append(" preset_mode: ");
|
||||
out.append("'").append(this->preset_mode).append("'");
|
||||
out.append("\n");
|
||||
out.append("}");
|
||||
}
|
||||
#endif
|
||||
@@ -1572,6 +1600,20 @@ bool FanCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
|
||||
this->speed_level = value.as_int32();
|
||||
return true;
|
||||
}
|
||||
case 12: {
|
||||
this->has_preset_mode = value.as_bool();
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool FanCommandRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
|
||||
switch (field_id) {
|
||||
case 13: {
|
||||
this->preset_mode = value.as_string();
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -1598,6 +1640,8 @@ void FanCommandRequest::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_enum<enums::FanDirection>(9, this->direction);
|
||||
buffer.encode_bool(10, this->has_speed_level);
|
||||
buffer.encode_int32(11, this->speed_level);
|
||||
buffer.encode_bool(12, this->has_preset_mode);
|
||||
buffer.encode_string(13, this->preset_mode);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
void FanCommandRequest::dump_to(std::string &out) const {
|
||||
@@ -1648,6 +1692,14 @@ void FanCommandRequest::dump_to(std::string &out) const {
|
||||
sprintf(buffer, "%" PRId32, this->speed_level);
|
||||
out.append(buffer);
|
||||
out.append("\n");
|
||||
|
||||
out.append(" has_preset_mode: ");
|
||||
out.append(YESNO(this->has_preset_mode));
|
||||
out.append("\n");
|
||||
|
||||
out.append(" preset_mode: ");
|
||||
out.append("'").append(this->preset_mode).append("'");
|
||||
out.append("\n");
|
||||
out.append("}");
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user