diff --git a/esphome/components/mitsubishi_uart/mitsubishi_uart-climatecall.cpp b/esphome/components/mitsubishi_uart/mitsubishi_uart-climatecall.cpp index fc1527ea4e6a..b6e911d875b8 100644 --- a/esphome/components/mitsubishi_uart/mitsubishi_uart-climatecall.cpp +++ b/esphome/components/mitsubishi_uart/mitsubishi_uart-climatecall.cpp @@ -79,16 +79,23 @@ void MitsubishiUART::control(const climate::ClimateCall &call) { target_temperature = call.get_target_temperature().value(); set_request_packet.set_target_temperature(call.get_target_temperature().value()); - // FIXME: (Do not merge while this is present!) - // HACK: Sync temperature to the appropriate state + // update our MHK tracking setpoints accordingly switch (mode) { - case climate::CLIMATE_MODE_HEAT: - target_temperature_low = target_temperature; - break; case climate::CLIMATE_MODE_COOL: case climate::CLIMATE_MODE_DRY: - target_temperature_high = target_temperature; + this->last_cool_setpoint_ = target_temperature; break; + case climate::CLIMATE_MODE_HEAT: + this->last_heat_setpoint_ = target_temperature; + break; + case climate::CLIMATE_MODE_HEAT_COOL: + if (this->get_traits().get_supports_two_point_target_temperature()) { + this->last_heat_setpoint_ = target_temperature_low; + this->last_cool_setpoint_ = target_temperature_high; + } else { + // this->last_heat_setpoint_ = target_temperature; + // this->last_cool_setpoint_ = target_temperature; + } default: break; } diff --git a/esphome/components/mitsubishi_uart/mitsubishi_uart-packetprocessing.cpp b/esphome/components/mitsubishi_uart/mitsubishi_uart-packetprocessing.cpp index 340bff611c75..ed59e0aab4a1 100644 --- a/esphome/components/mitsubishi_uart/mitsubishi_uart-packetprocessing.cpp +++ b/esphome/components/mitsubishi_uart/mitsubishi_uart-packetprocessing.cpp @@ -118,6 +118,18 @@ void MitsubishiUART::process_packet(const SettingsGetResponsePacket &packet) { target_temperature = packet.get_target_temp(); publish_on_update_ |= (old_target_temperature != target_temperature); + switch (mode) { + case climate::CLIMATE_MODE_COOL: + case climate::CLIMATE_MODE_DRY: + this->last_cool_setpoint_ = target_temperature; + break; + case climate::CLIMATE_MODE_HEAT: + this->last_heat_setpoint_ = target_temperature; + break; + default: + break; + } + // Fan static bool fan_changed = false; switch (packet.get_fan()) { @@ -390,8 +402,8 @@ void MitsubishiUART::process_packet(const KumoThermostatHelloPacket &packet) { void MitsubishiUART::process_packet(const KumoThermostatStateSyncPacket &packet) { ESP_LOGV(TAG, "Processing inbound %s", packet.to_string().c_str()); - if (packet.get_flags() & 0x08) this->target_temperature_low = packet.get_heat_setpoint(); - if (packet.get_flags() & 0x10) this->target_temperature_high = packet.get_cool_setpoint(); + if (packet.get_flags() & 0x08) this->last_heat_setpoint_ = packet.get_heat_setpoint(); + if (packet.get_flags() & 0x10) this->last_cool_setpoint_ = packet.get_cool_setpoint(); ts_bridge_->send_packet(SetResponsePacket()); } @@ -412,8 +424,8 @@ void MitsubishiUART::process_packet(const SetResponsePacket &packet) { void MitsubishiUART::handle_kumo_adapter_state_get_request(const GetRequestPacket &packet) { auto response = KumoCloudStateSyncPacket(); - response.set_heat_setpoint(this->target_temperature_low); - response.set_cool_setpoint(this->target_temperature_high); + response.set_heat_setpoint(this->last_heat_setpoint_); + response.set_cool_setpoint(this->last_cool_setpoint_); if (this->time_source != nullptr) { response.set_timestamp(this->time_source->now()); diff --git a/esphome/components/mitsubishi_uart/mitsubishi_uart.h b/esphome/components/mitsubishi_uart/mitsubishi_uart.h index 993854260f20..6c34d46910fe 100644 --- a/esphome/components/mitsubishi_uart/mitsubishi_uart.h +++ b/esphome/components/mitsubishi_uart/mitsubishi_uart.h @@ -194,6 +194,9 @@ class MitsubishiUART : public PollingComponent, public climate::Climate, public void send_if_active_(const Packet &packet); bool active_mode_ = true; + + float last_cool_setpoint_ = NAN; + float last_heat_setpoint_ = NAN; }; struct MUARTPreferences {