Merge branch 'release/1.3.1'

This commit is contained in:
Geoff Davis 2021-04-28 10:53:48 -07:00
commit b6b47f2f5e
2 changed files with 45 additions and 30 deletions

View File

@ -7,12 +7,13 @@
* Author: Phil Genera @pgenera on Github. * Author: Phil Genera @pgenera on Github.
* Author: Barry Loong @loongyh on GitHub. * Author: Barry Loong @loongyh on GitHub.
* Author: @am-io on Github. * Author: @am-io on Github.
* Author: @nao-pon on Github.
* Last Updated: 2020-07-06 * Last Updated: 2020-07-06
* License: BSD * License: BSD
* *
* Requirements: * Requirements:
* - https://github.com/SwiCago/HeatPump * - https://github.com/SwiCago/HeatPump
* - ESPHome 1.15.0-dev or greater * - ESPHome 1.15.0 or greater
*/ */
#include "espmhp.h" #include "espmhp.h"
@ -104,60 +105,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()) { }
switch (this->mode) {
case climate::CLIMATE_MODE_COOL: case climate::CLIMATE_MODE_COOL:
hp->setModeSetting("COOL"); hp->setModeSetting("COOL");
hp->setPowerSetting("ON"); 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; break;
case climate::CLIMATE_MODE_HEAT: case climate::CLIMATE_MODE_HEAT:
hp->setModeSetting("HEAT"); hp->setModeSetting("HEAT");
hp->setPowerSetting("ON"); 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; break;
case climate::CLIMATE_MODE_DRY: case climate::CLIMATE_MODE_DRY:
hp->setModeSetting("DRY"); hp->setModeSetting("DRY");
hp->setPowerSetting("ON"); hp->setPowerSetting("ON");
if (has_mode){
this->action = climate::CLIMATE_ACTION_DRYING; this->action = climate::CLIMATE_ACTION_DRYING;
updated = true; updated = true;
}
break; break;
case climate::CLIMATE_MODE_AUTO: case climate::CLIMATE_MODE_AUTO:
hp->setModeSetting("AUTO"); hp->setModeSetting("AUTO");
hp->setPowerSetting("ON"); 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; updated = true;
break; break;
case climate::CLIMATE_MODE_FAN_ONLY: case climate::CLIMATE_MODE_FAN_ONLY:
hp->setModeSetting("FAN"); hp->setModeSetting("FAN");
hp->setPowerSetting("ON"); hp->setPowerSetting("ON");
if (has_mode){
this->action = climate::CLIMATE_ACTION_FAN; this->action = climate::CLIMATE_ACTION_FAN;
updated = true; updated = true;
}
break; break;
case climate::CLIMATE_MODE_OFF: case climate::CLIMATE_MODE_OFF:
default: 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){

View File

@ -5,12 +5,13 @@
* *
* Author: Geoff Davis <geoff@geoffdavis.com> * Author: Geoff Davis <geoff@geoffdavis.com>
* Author: Phil Genera @pgenera on Github. * Author: Phil Genera @pgenera on Github.
* Last Updated: 2020-07-06 * Author: @nao-pon on Github
* Last Updated: 2021-04-28
* License: BSD * License: BSD
* *
* Requirements: * Requirements:
* - https://github.com/SwiCago/HeatPump * - https://github.com/SwiCago/HeatPump
* - ESPHome 1.15.0-dev or greater * - ESPHome 1.15.0 or greater
*/ */
#define USE_CALLBACKS #define USE_CALLBACKS