mirror of
https://github.com/esphome/esphome.git
synced 2026-10-14 10:12:52 +00:00
[heatpumpir] Add Eco and Boost presets and fix fan speeds on Mitsubishi Heavy ZJ and ZMP (#16877)
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
This commit is contained in:
co-authored by
J. Nick Koston
parent
5a90bceba0
commit
3472ac3dcc
@@ -127,6 +127,13 @@ void HeatpumpIRClimate::setup() {
|
||||
}
|
||||
}
|
||||
|
||||
void HeatpumpIRClimate::control(const climate::ClimateCall &call) {
|
||||
// Picking a fan speed ends HiPower or Econo, as it does on the remote
|
||||
if (this->has_fan_byte_presets_() && call.get_fan_mode().has_value() && !call.get_preset().has_value())
|
||||
this->preset = climate::CLIMATE_PRESET_NONE;
|
||||
climate_ir::ClimateIR::control(call);
|
||||
}
|
||||
|
||||
void HeatpumpIRClimate::transmit_state() {
|
||||
uint8_t power_mode_cmd;
|
||||
uint8_t operating_mode_cmd;
|
||||
@@ -190,8 +197,9 @@ void HeatpumpIRClimate::transmit_state() {
|
||||
}
|
||||
|
||||
// MitsubishiMSCHeatpumpIR only knows FAN_1..FAN_3 and sends anything else as auto,
|
||||
// so low/medium/high have to start at FAN_1 there instead of FAN_2.
|
||||
const bool three_speed_fan = this->protocol_ == PROTOCOL_MITSUBISHI_MSC;
|
||||
// so low/medium/high have to start at FAN_1 there instead of FAN_2. Mitsubishi Heavy
|
||||
// ZJ and ZMP also stop at FAN_3 and use FAN_4 and FAN_5 for HiPower and Econo.
|
||||
const bool three_speed_fan = this->protocol_ == PROTOCOL_MITSUBISHI_MSC || this->has_fan_byte_presets_();
|
||||
switch (this->fan_mode.value_or(climate::CLIMATE_FAN_AUTO)) {
|
||||
case climate::CLIMATE_FAN_LOW:
|
||||
fan_speed_cmd = three_speed_fan ? FAN_1 : FAN_2;
|
||||
@@ -208,6 +216,19 @@ void HeatpumpIRClimate::transmit_state() {
|
||||
break;
|
||||
}
|
||||
|
||||
if (this->has_fan_byte_presets_()) {
|
||||
switch (this->preset.value_or(climate::CLIMATE_PRESET_NONE)) {
|
||||
case climate::CLIMATE_PRESET_BOOST:
|
||||
fan_speed_cmd = FAN_4; // HiPower
|
||||
break;
|
||||
case climate::CLIMATE_PRESET_ECO:
|
||||
fan_speed_cmd = FAN_5; // Econo
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (this->mode) {
|
||||
case climate::CLIMATE_MODE_COOL:
|
||||
power_mode_cmd = POWER_ON;
|
||||
|
||||
@@ -104,10 +104,8 @@ class HeatpumpIRClimate final : public climate_ir::ClimateIR {
|
||||
void setup() override;
|
||||
void set_protocol(Protocol protocol) {
|
||||
this->protocol_ = protocol;
|
||||
if (protocol == PROTOCOL_MITSUBISHI_HEAVY_ZMP) {
|
||||
this->presets_.insert(climate::CLIMATE_PRESET_NONE);
|
||||
this->presets_.insert(climate::CLIMATE_PRESET_ECO);
|
||||
this->presets_.insert(climate::CLIMATE_PRESET_BOOST);
|
||||
if (this->has_fan_byte_presets_()) {
|
||||
this->presets_ = {climate::CLIMATE_PRESET_NONE, climate::CLIMATE_PRESET_ECO, climate::CLIMATE_PRESET_BOOST};
|
||||
}
|
||||
}
|
||||
void set_horizontal_default(HorizontalDirection horizontal_direction) {
|
||||
@@ -122,8 +120,13 @@ class HeatpumpIRClimate final : public climate_ir::ClimateIR {
|
||||
|
||||
protected:
|
||||
HeatpumpIR *heatpump_ir_;
|
||||
void control(const climate::ClimateCall &call) override;
|
||||
/// Transmit via IR the state of this climate controller.
|
||||
void transmit_state() override;
|
||||
/// Mitsubishi Heavy ZJ and ZMP carry HiPower and Econo in the fan byte as FAN_4 and FAN_5
|
||||
bool has_fan_byte_presets_() const {
|
||||
return this->protocol_ == PROTOCOL_MITSUBISHI_HEAVY_ZJ || this->protocol_ == PROTOCOL_MITSUBISHI_HEAVY_ZMP;
|
||||
}
|
||||
/// Handle received IR data from the remote control.
|
||||
bool on_receive(remote_base::RemoteReceiveData data) override;
|
||||
Protocol protocol_;
|
||||
|
||||
@@ -7,6 +7,14 @@ climate:
|
||||
min_temperature: 18
|
||||
max_temperature: 30
|
||||
transmitter_id: xmitr
|
||||
- platform: heatpumpir
|
||||
protocol: mitsubishi_heavy_zj
|
||||
horizontal_default: left
|
||||
vertical_default: mup
|
||||
name: HeatpumpIR Climate Mitsubishi ZJ
|
||||
min_temperature: 18
|
||||
max_temperature: 30
|
||||
transmitter_id: xmitr
|
||||
- platform: heatpumpir
|
||||
protocol: mitsubishi_heavy_zmp
|
||||
horizontal_default: left
|
||||
|
||||
Reference in New Issue
Block a user