mirror of
https://github.com/geoffdavis/esphome-mitsubishiheatpump
synced 2024-08-30 18:12:13 +00:00
fix mode discrepancies when using IR control
Fixed a problem that the mode is returned to the original mode when the temperature is changed with HA after changing the mode with the infrared remote controller.
This commit is contained in:
parent
a3c4f92aac
commit
3fd616ad6f
67
espmhp.cpp
67
espmhp.cpp
@ -104,60 +104,73 @@ void MitsubishiHeatPump::control(const climate::ClimateCall &call) {
|
|||||||
ESP_LOGV(TAG, "Control called.");
|
ESP_LOGV(TAG, "Control called.");
|
||||||
|
|
||||||
bool updated = false;
|
bool updated = false;
|
||||||
|
bool has_mode = call.get_mode().has_value();
|
||||||
bool has_temp = call.get_target_temperature().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();
|
this->mode = *call.get_mode();
|
||||||
switch (*call.get_mode()) {
|
}
|
||||||
case climate::CLIMATE_MODE_COOL:
|
switch (this->mode) {
|
||||||
hp->setModeSetting("COOL");
|
case climate::CLIMATE_MODE_COOL:
|
||||||
hp->setPowerSetting("ON");
|
hp->setModeSetting("COOL");
|
||||||
|
hp->setPowerSetting("ON");
|
||||||
|
|
||||||
|
if (has_mode){
|
||||||
if (cool_setpoint.has_value() && !has_temp) {
|
if (cool_setpoint.has_value() && !has_temp) {
|
||||||
hp->setTemperature(cool_setpoint.value());
|
hp->setTemperature(cool_setpoint.value());
|
||||||
this->target_temperature = cool_setpoint.value();
|
this->target_temperature = cool_setpoint.value();
|
||||||
}
|
}
|
||||||
this->action = climate::CLIMATE_ACTION_IDLE;
|
this->action = climate::CLIMATE_ACTION_IDLE;
|
||||||
updated = true;
|
updated = true;
|
||||||
break;
|
}
|
||||||
case climate::CLIMATE_MODE_HEAT:
|
break;
|
||||||
hp->setModeSetting("HEAT");
|
case climate::CLIMATE_MODE_HEAT:
|
||||||
hp->setPowerSetting("ON");
|
hp->setModeSetting("HEAT");
|
||||||
|
hp->setPowerSetting("ON");
|
||||||
|
if (has_mode){
|
||||||
if (heat_setpoint.has_value() && !has_temp) {
|
if (heat_setpoint.has_value() && !has_temp) {
|
||||||
hp->setTemperature(heat_setpoint.value());
|
hp->setTemperature(heat_setpoint.value());
|
||||||
this->target_temperature = heat_setpoint.value();
|
this->target_temperature = heat_setpoint.value();
|
||||||
}
|
}
|
||||||
this->action = climate::CLIMATE_ACTION_IDLE;
|
this->action = climate::CLIMATE_ACTION_IDLE;
|
||||||
updated = true;
|
updated = true;
|
||||||
break;
|
}
|
||||||
case climate::CLIMATE_MODE_DRY:
|
break;
|
||||||
hp->setModeSetting("DRY");
|
case climate::CLIMATE_MODE_DRY:
|
||||||
hp->setPowerSetting("ON");
|
hp->setModeSetting("DRY");
|
||||||
|
hp->setPowerSetting("ON");
|
||||||
|
if (has_mode){
|
||||||
this->action = climate::CLIMATE_ACTION_DRYING;
|
this->action = climate::CLIMATE_ACTION_DRYING;
|
||||||
updated = true;
|
updated = true;
|
||||||
break;
|
}
|
||||||
case climate::CLIMATE_MODE_AUTO:
|
break;
|
||||||
hp->setModeSetting("AUTO");
|
case climate::CLIMATE_MODE_AUTO:
|
||||||
hp->setPowerSetting("ON");
|
hp->setModeSetting("AUTO");
|
||||||
|
hp->setPowerSetting("ON");
|
||||||
|
if (has_mode){
|
||||||
if (auto_setpoint.has_value() && !has_temp) {
|
if (auto_setpoint.has_value() && !has_temp) {
|
||||||
hp->setTemperature(auto_setpoint.value());
|
hp->setTemperature(auto_setpoint.value());
|
||||||
this->target_temperature = auto_setpoint.value();
|
this->target_temperature = auto_setpoint.value();
|
||||||
}
|
}
|
||||||
this->action = climate::CLIMATE_ACTION_IDLE;
|
this->action = climate::CLIMATE_ACTION_IDLE;
|
||||||
updated = true;
|
}
|
||||||
break;
|
updated = true;
|
||||||
case climate::CLIMATE_MODE_FAN_ONLY:
|
break;
|
||||||
hp->setModeSetting("FAN");
|
case climate::CLIMATE_MODE_FAN_ONLY:
|
||||||
hp->setPowerSetting("ON");
|
hp->setModeSetting("FAN");
|
||||||
|
hp->setPowerSetting("ON");
|
||||||
|
if (has_mode){
|
||||||
this->action = climate::CLIMATE_ACTION_FAN;
|
this->action = climate::CLIMATE_ACTION_FAN;
|
||||||
updated = true;
|
updated = true;
|
||||||
break;
|
}
|
||||||
case climate::CLIMATE_MODE_OFF:
|
break;
|
||||||
default:
|
case climate::CLIMATE_MODE_OFF:
|
||||||
|
default:
|
||||||
|
if (has_mode){
|
||||||
hp->setPowerSetting("OFF");
|
hp->setPowerSetting("OFF");
|
||||||
this->action = climate::CLIMATE_ACTION_OFF;
|
this->action = climate::CLIMATE_ACTION_OFF;
|
||||||
updated = true;
|
updated = true;
|
||||||
break;
|
}
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_temp){
|
if (has_temp){
|
||||||
|
Loading…
Reference in New Issue
Block a user