mirror of
https://github.com/esphome/esphome.git
synced 2025-11-17 15:26:01 +00:00
Add climate dry fan (#845)
* add climate dry fan * clang-format * updates, add swing mode, add back compat with old ha * revert client-config add swing * sort const.py * fix missing retur
This commit is contained in:
committed by
Otto Winter
parent
4f8f59f705
commit
1814e4a46b
@@ -12,11 +12,60 @@ climate::ClimateTraits ClimateIR::traits() {
|
||||
traits.set_supports_auto_mode(true);
|
||||
traits.set_supports_cool_mode(this->supports_cool_);
|
||||
traits.set_supports_heat_mode(this->supports_heat_);
|
||||
traits.set_supports_dry_mode(this->supports_dry_);
|
||||
traits.set_supports_fan_only_mode(this->supports_fan_only_);
|
||||
traits.set_supports_two_point_target_temperature(false);
|
||||
traits.set_supports_away(false);
|
||||
traits.set_visual_min_temperature(this->minimum_temperature_);
|
||||
traits.set_visual_max_temperature(this->maximum_temperature_);
|
||||
traits.set_visual_temperature_step(this->temperature_step_);
|
||||
for (auto fan_mode : this->fan_modes_) {
|
||||
switch (fan_mode) {
|
||||
case climate::CLIMATE_FAN_AUTO:
|
||||
traits.set_supports_fan_mode_auto(true);
|
||||
break;
|
||||
case climate::CLIMATE_FAN_DIFFUSE:
|
||||
traits.set_supports_fan_mode_diffuse(true);
|
||||
break;
|
||||
case climate::CLIMATE_FAN_FOCUS:
|
||||
traits.set_supports_fan_mode_focus(true);
|
||||
break;
|
||||
case climate::CLIMATE_FAN_HIGH:
|
||||
traits.set_supports_fan_mode_high(true);
|
||||
break;
|
||||
case climate::CLIMATE_FAN_LOW:
|
||||
traits.set_supports_fan_mode_low(true);
|
||||
break;
|
||||
case climate::CLIMATE_FAN_MEDIUM:
|
||||
traits.set_supports_fan_mode_medium(true);
|
||||
break;
|
||||
case climate::CLIMATE_FAN_MIDDLE:
|
||||
traits.set_supports_fan_mode_middle(true);
|
||||
break;
|
||||
case climate::CLIMATE_FAN_OFF:
|
||||
traits.set_supports_fan_mode_off(true);
|
||||
break;
|
||||
case climate::CLIMATE_FAN_ON:
|
||||
traits.set_supports_fan_mode_on(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (auto swing_mode : this->swing_modes_) {
|
||||
switch (swing_mode) {
|
||||
case climate::CLIMATE_SWING_OFF:
|
||||
traits.set_supports_swing_mode_off(true);
|
||||
break;
|
||||
case climate::CLIMATE_SWING_BOTH:
|
||||
traits.set_supports_swing_mode_both(true);
|
||||
break;
|
||||
case climate::CLIMATE_SWING_VERTICAL:
|
||||
traits.set_supports_swing_mode_vertical(true);
|
||||
break;
|
||||
case climate::CLIMATE_SWING_HORIZONTAL:
|
||||
traits.set_supports_swing_mode_horizontal(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return traits;
|
||||
}
|
||||
|
||||
@@ -40,6 +89,8 @@ void ClimateIR::setup() {
|
||||
// initialize target temperature to some value so that it's not NAN
|
||||
this->target_temperature =
|
||||
roundf(clamp(this->current_temperature, this->minimum_temperature_, this->maximum_temperature_));
|
||||
this->fan_mode = climate::CLIMATE_FAN_AUTO;
|
||||
this->swing_mode = climate::CLIMATE_SWING_OFF;
|
||||
}
|
||||
// Never send nan to HA
|
||||
if (isnan(this->target_temperature))
|
||||
@@ -51,7 +102,10 @@ void ClimateIR::control(const climate::ClimateCall &call) {
|
||||
this->mode = *call.get_mode();
|
||||
if (call.get_target_temperature().has_value())
|
||||
this->target_temperature = *call.get_target_temperature();
|
||||
|
||||
if (call.get_fan_mode().has_value())
|
||||
this->fan_mode = *call.get_fan_mode();
|
||||
if (call.get_swing_mode().has_value())
|
||||
this->swing_mode = *call.get_swing_mode();
|
||||
this->transmit_state();
|
||||
this->publish_state();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user