1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-04 20:32:21 +01:00

Add preset, custom_preset and custom_fan_mode support to climate (#1471)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
Lumpusz
2021-06-04 12:04:54 +02:00
committed by GitHub
parent 7bc51582f0
commit ebadaa9660
30 changed files with 931 additions and 96 deletions

View File

@@ -118,8 +118,8 @@ template<> const char *proto_enum_to_string<enums::ClimateMode>(enums::ClimateMo
switch (value) {
case enums::CLIMATE_MODE_OFF:
return "CLIMATE_MODE_OFF";
case enums::CLIMATE_MODE_AUTO:
return "CLIMATE_MODE_AUTO";
case enums::CLIMATE_MODE_HEAT_COOL:
return "CLIMATE_MODE_HEAT_COOL";
case enums::CLIMATE_MODE_COOL:
return "CLIMATE_MODE_COOL";
case enums::CLIMATE_MODE_HEAT:
@@ -128,6 +128,8 @@ template<> const char *proto_enum_to_string<enums::ClimateMode>(enums::ClimateMo
return "CLIMATE_MODE_FAN_ONLY";
case enums::CLIMATE_MODE_DRY:
return "CLIMATE_MODE_DRY";
case enums::CLIMATE_MODE_AUTO:
return "CLIMATE_MODE_AUTO";
default:
return "UNKNOWN";
}
@@ -188,6 +190,26 @@ template<> const char *proto_enum_to_string<enums::ClimateAction>(enums::Climate
return "UNKNOWN";
}
}
template<> const char *proto_enum_to_string<enums::ClimatePreset>(enums::ClimatePreset value) {
switch (value) {
case enums::CLIMATE_PRESET_ECO:
return "CLIMATE_PRESET_ECO";
case enums::CLIMATE_PRESET_AWAY:
return "CLIMATE_PRESET_AWAY";
case enums::CLIMATE_PRESET_BOOST:
return "CLIMATE_PRESET_BOOST";
case enums::CLIMATE_PRESET_COMFORT:
return "CLIMATE_PRESET_COMFORT";
case enums::CLIMATE_PRESET_HOME:
return "CLIMATE_PRESET_HOME";
case enums::CLIMATE_PRESET_SLEEP:
return "CLIMATE_PRESET_SLEEP";
case enums::CLIMATE_PRESET_ACTIVITY:
return "CLIMATE_PRESET_ACTIVITY";
default:
return "UNKNOWN";
}
}
bool HelloRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
switch (field_id) {
case 1: {
@@ -2647,6 +2669,10 @@ bool ListEntitiesClimateResponse::decode_varint(uint32_t field_id, ProtoVarInt v
this->supported_swing_modes.push_back(value.as_enum<enums::ClimateSwingMode>());
return true;
}
case 16: {
this->supported_presets.push_back(value.as_enum<enums::ClimatePreset>());
return true;
}
default:
return false;
}
@@ -2665,6 +2691,14 @@ bool ListEntitiesClimateResponse::decode_length(uint32_t field_id, ProtoLengthDe
this->unique_id = value.as_string();
return true;
}
case 15: {
this->supported_custom_fan_modes.push_back(value.as_string());
return true;
}
case 17: {
this->supported_custom_presets.push_back(value.as_string());
return true;
}
default:
return false;
}
@@ -2712,6 +2746,15 @@ void ListEntitiesClimateResponse::encode(ProtoWriteBuffer buffer) const {
for (auto &it : this->supported_swing_modes) {
buffer.encode_enum<enums::ClimateSwingMode>(14, it, true);
}
for (auto &it : this->supported_custom_fan_modes) {
buffer.encode_string(15, it, true);
}
for (auto &it : this->supported_presets) {
buffer.encode_enum<enums::ClimatePreset>(16, it, true);
}
for (auto &it : this->supported_custom_presets) {
buffer.encode_string(17, it, true);
}
}
void ListEntitiesClimateResponse::dump_to(std::string &out) const {
char buffer[64];
@@ -2781,6 +2824,24 @@ void ListEntitiesClimateResponse::dump_to(std::string &out) const {
out.append(proto_enum_to_string<enums::ClimateSwingMode>(it));
out.append("\n");
}
for (const auto &it : this->supported_custom_fan_modes) {
out.append(" supported_custom_fan_modes: ");
out.append("'").append(it).append("'");
out.append("\n");
}
for (const auto &it : this->supported_presets) {
out.append(" supported_presets: ");
out.append(proto_enum_to_string<enums::ClimatePreset>(it));
out.append("\n");
}
for (const auto &it : this->supported_custom_presets) {
out.append(" supported_custom_presets: ");
out.append("'").append(it).append("'");
out.append("\n");
}
out.append("}");
}
bool ClimateStateResponse::decode_varint(uint32_t field_id, ProtoVarInt value) {
@@ -2805,6 +2866,24 @@ bool ClimateStateResponse::decode_varint(uint32_t field_id, ProtoVarInt value) {
this->swing_mode = value.as_enum<enums::ClimateSwingMode>();
return true;
}
case 12: {
this->preset = value.as_enum<enums::ClimatePreset>();
return true;
}
default:
return false;
}
}
bool ClimateStateResponse::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
switch (field_id) {
case 11: {
this->custom_fan_mode = value.as_string();
return true;
}
case 13: {
this->custom_preset = value.as_string();
return true;
}
default:
return false;
}
@@ -2846,6 +2925,9 @@ void ClimateStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_enum<enums::ClimateAction>(8, this->action);
buffer.encode_enum<enums::ClimateFanMode>(9, this->fan_mode);
buffer.encode_enum<enums::ClimateSwingMode>(10, this->swing_mode);
buffer.encode_string(11, this->custom_fan_mode);
buffer.encode_enum<enums::ClimatePreset>(12, this->preset);
buffer.encode_string(13, this->custom_preset);
}
void ClimateStateResponse::dump_to(std::string &out) const {
char buffer[64];
@@ -2894,6 +2976,18 @@ void ClimateStateResponse::dump_to(std::string &out) const {
out.append(" swing_mode: ");
out.append(proto_enum_to_string<enums::ClimateSwingMode>(this->swing_mode));
out.append("\n");
out.append(" custom_fan_mode: ");
out.append("'").append(this->custom_fan_mode).append("'");
out.append("\n");
out.append(" preset: ");
out.append(proto_enum_to_string<enums::ClimatePreset>(this->preset));
out.append("\n");
out.append(" custom_preset: ");
out.append("'").append(this->custom_preset).append("'");
out.append("\n");
out.append("}");
}
bool ClimateCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
@@ -2942,6 +3036,36 @@ bool ClimateCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value)
this->swing_mode = value.as_enum<enums::ClimateSwingMode>();
return true;
}
case 16: {
this->has_custom_fan_mode = value.as_bool();
return true;
}
case 18: {
this->has_preset = value.as_bool();
return true;
}
case 19: {
this->preset = value.as_enum<enums::ClimatePreset>();
return true;
}
case 20: {
this->has_custom_preset = value.as_bool();
return true;
}
default:
return false;
}
}
bool ClimateCommandRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) {
switch (field_id) {
case 17: {
this->custom_fan_mode = value.as_string();
return true;
}
case 21: {
this->custom_preset = value.as_string();
return true;
}
default:
return false;
}
@@ -2984,6 +3108,12 @@ void ClimateCommandRequest::encode(ProtoWriteBuffer buffer) const {
buffer.encode_enum<enums::ClimateFanMode>(13, this->fan_mode);
buffer.encode_bool(14, this->has_swing_mode);
buffer.encode_enum<enums::ClimateSwingMode>(15, this->swing_mode);
buffer.encode_bool(16, this->has_custom_fan_mode);
buffer.encode_string(17, this->custom_fan_mode);
buffer.encode_bool(18, this->has_preset);
buffer.encode_enum<enums::ClimatePreset>(19, this->preset);
buffer.encode_bool(20, this->has_custom_preset);
buffer.encode_string(21, this->custom_preset);
}
void ClimateCommandRequest::dump_to(std::string &out) const {
char buffer[64];
@@ -3051,6 +3181,30 @@ void ClimateCommandRequest::dump_to(std::string &out) const {
out.append(" swing_mode: ");
out.append(proto_enum_to_string<enums::ClimateSwingMode>(this->swing_mode));
out.append("\n");
out.append(" has_custom_fan_mode: ");
out.append(YESNO(this->has_custom_fan_mode));
out.append("\n");
out.append(" custom_fan_mode: ");
out.append("'").append(this->custom_fan_mode).append("'");
out.append("\n");
out.append(" has_preset: ");
out.append(YESNO(this->has_preset));
out.append("\n");
out.append(" preset: ");
out.append(proto_enum_to_string<enums::ClimatePreset>(this->preset));
out.append("\n");
out.append(" has_custom_preset: ");
out.append(YESNO(this->has_custom_preset));
out.append("\n");
out.append(" custom_preset: ");
out.append("'").append(this->custom_preset).append("'");
out.append("\n");
out.append("}");
}