Skip to content

Commit

Permalink
Merge pull request #21 from nao-pon/fix_temp_change
Browse files Browse the repository at this point in the history
fix mode discrepancies when using IR control
  • Loading branch information
geoffdavis committed Apr 28, 2021
2 parents 27c5f16 + 3fd616a commit 0386623
Showing 1 changed file with 40 additions and 27 deletions.
67 changes: 40 additions & 27 deletions espmhp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,60 +104,73 @@ void MitsubishiHeatPump::control(const climate::ClimateCall &call) {
ESP_LOGV(TAG, "Control called.");

bool updated = false;
bool has_mode = call.get_mode().has_value();
bool has_temp = call.get_target_temperature().has_value();
if (call.get_mode().has_value()){
if (has_mode){
this->mode = *call.get_mode();
switch (*call.get_mode()) {
case climate::CLIMATE_MODE_COOL:
hp->setModeSetting("COOL");
hp->setPowerSetting("ON");
}
switch (this->mode) {
case climate::CLIMATE_MODE_COOL:
hp->setModeSetting("COOL");
hp->setPowerSetting("ON");

if (has_mode){
if (cool_setpoint.has_value() && !has_temp) {
hp->setTemperature(cool_setpoint.value());
this->target_temperature = cool_setpoint.value();
}
this->action = climate::CLIMATE_ACTION_IDLE;
updated = true;
break;
case climate::CLIMATE_MODE_HEAT:
hp->setModeSetting("HEAT");
hp->setPowerSetting("ON");
}
break;
case climate::CLIMATE_MODE_HEAT:
hp->setModeSetting("HEAT");
hp->setPowerSetting("ON");
if (has_mode){
if (heat_setpoint.has_value() && !has_temp) {
hp->setTemperature(heat_setpoint.value());
this->target_temperature = heat_setpoint.value();
}
this->action = climate::CLIMATE_ACTION_IDLE;
updated = true;
break;
case climate::CLIMATE_MODE_DRY:
hp->setModeSetting("DRY");
hp->setPowerSetting("ON");
}
break;
case climate::CLIMATE_MODE_DRY:
hp->setModeSetting("DRY");
hp->setPowerSetting("ON");
if (has_mode){
this->action = climate::CLIMATE_ACTION_DRYING;
updated = true;
break;
case climate::CLIMATE_MODE_AUTO:
hp->setModeSetting("AUTO");
hp->setPowerSetting("ON");
}
break;
case climate::CLIMATE_MODE_AUTO:
hp->setModeSetting("AUTO");
hp->setPowerSetting("ON");
if (has_mode){
if (auto_setpoint.has_value() && !has_temp) {
hp->setTemperature(auto_setpoint.value());
this->target_temperature = auto_setpoint.value();
}
this->action = climate::CLIMATE_ACTION_IDLE;
updated = true;
break;
case climate::CLIMATE_MODE_FAN_ONLY:
hp->setModeSetting("FAN");
hp->setPowerSetting("ON");
}
updated = true;
break;
case climate::CLIMATE_MODE_FAN_ONLY:
hp->setModeSetting("FAN");
hp->setPowerSetting("ON");
if (has_mode){
this->action = climate::CLIMATE_ACTION_FAN;
updated = true;
break;
case climate::CLIMATE_MODE_OFF:
default:
}
break;
case climate::CLIMATE_MODE_OFF:
default:
if (has_mode){
hp->setPowerSetting("OFF");
this->action = climate::CLIMATE_ACTION_OFF;
updated = true;
break;
}
}
break;
}

if (has_temp){
Expand Down

0 comments on commit 0386623

Please sign in to comment.