Skip to content

Commit

Permalink
idk anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
KazWolfe committed May 27, 2024
1 parent a171a6f commit f0dde84
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
19 changes: 13 additions & 6 deletions esphome/components/mitsubishi_uart/mitsubishi_uart-climatecall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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());
}
Expand All @@ -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());
Expand Down
3 changes: 3 additions & 0 deletions esphome/components/mitsubishi_uart/mitsubishi_uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f0dde84

Please sign in to comment.