Merge branch 'master' into temp_storage

This commit is contained in:
Geoff Davis 2020-07-05 22:02:04 -07:00 committed by GitHub
commit 46e32a2021
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -81,7 +81,7 @@ climate::ClimateTraits MitsubishiHeatPump::traits() {
traits.set_supports_fan_mode_off(false); traits.set_supports_fan_mode_off(false);
traits.set_supports_fan_mode_auto(true); traits.set_supports_fan_mode_auto(true);
traits.set_supports_fan_mode_focus(false); traits.set_supports_fan_mode_focus(false);
traits.set_supports_fan_mode_diffuse(false); traits.set_supports_fan_mode_diffuse(true);
traits.set_supports_fan_mode_low(true); traits.set_supports_fan_mode_low(true);
traits.set_supports_fan_mode_medium(true); traits.set_supports_fan_mode_medium(true);
traits.set_supports_fan_mode_middle(true); traits.set_supports_fan_mode_middle(true);
@ -109,10 +109,12 @@ void MitsubishiHeatPump::control(const climate::ClimateCall &call) {
case climate::CLIMATE_MODE_COOL: case climate::CLIMATE_MODE_COOL:
hp->setModeSetting("COOL"); hp->setModeSetting("COOL");
hp->setPowerSetting("ON"); hp->setPowerSetting("ON");
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;
updated = true; updated = true;
break; break;
case climate::CLIMATE_MODE_HEAT: case climate::CLIMATE_MODE_HEAT:
@ -122,11 +124,13 @@ void MitsubishiHeatPump::control(const climate::ClimateCall &call) {
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;
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");
this->action = climate::CLIMATE_ACTION_DRYING;
updated = true; updated = true;
break; break;
case climate::CLIMATE_MODE_AUTO: case climate::CLIMATE_MODE_AUTO:
@ -136,16 +140,19 @@ void MitsubishiHeatPump::control(const climate::ClimateCall &call) {
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;
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");
this->action = climate::CLIMATE_ACTION_FAN;
updated = true; updated = true;
break; break;
case climate::CLIMATE_MODE_OFF: case climate::CLIMATE_MODE_OFF:
default: default:
hp->setPowerSetting("OFF"); hp->setPowerSetting("OFF");
this->action = climate::CLIMATE_ACTION_OFF;
updated = true; updated = true;
break; break;
} }
@ -171,23 +178,23 @@ void MitsubishiHeatPump::control(const climate::ClimateCall &call) {
updated = true; updated = true;
break; break;
case climate::CLIMATE_FAN_DIFFUSE: case climate::CLIMATE_FAN_DIFFUSE:
hp->setPowerSetting("QUIET"); hp->setFanSpeed("QUIET");
updated = true; updated = true;
break; break;
case climate::CLIMATE_FAN_LOW: case climate::CLIMATE_FAN_LOW:
hp->setPowerSetting("1"); hp->setFanSpeed("1");
updated = true; updated = true;
break; break;
case climate::CLIMATE_FAN_MEDIUM: case climate::CLIMATE_FAN_MEDIUM:
hp->setPowerSetting("2"); hp->setFanSpeed("2");
updated = true; updated = true;
break; break;
case climate::CLIMATE_FAN_MIDDLE: case climate::CLIMATE_FAN_MIDDLE:
hp->setPowerSetting("3"); hp->setFanSpeed("3");
updated = true; updated = true;
break; break;
case climate::CLIMATE_FAN_HIGH: case climate::CLIMATE_FAN_HIGH:
hp->setPowerSetting("4"); hp->setFanSpeed("4");
updated = true; updated = true;
break; break;
case climate::CLIMATE_FAN_ON: case climate::CLIMATE_FAN_ON:
@ -256,22 +263,27 @@ void MitsubishiHeatPump::hpSettingsChanged() {
heat_setpoint = currentSettings.temperature; heat_setpoint = currentSettings.temperature;
save(currentSettings.temperature, heat_storage); save(currentSettings.temperature, heat_storage);
} }
this->action = climate::CLIMATE_ACTION_IDLE;
} else if (strcmp(currentSettings.mode, "DRY") == 0) { } else if (strcmp(currentSettings.mode, "DRY") == 0) {
this->mode = climate::CLIMATE_MODE_DRY; this->mode = climate::CLIMATE_MODE_DRY;
this->action = climate::CLIMATE_ACTION_DRYING;
} else if (strcmp(currentSettings.mode, "COOL") == 0) { } else if (strcmp(currentSettings.mode, "COOL") == 0) {
this->mode = climate::CLIMATE_MODE_COOL; this->mode = climate::CLIMATE_MODE_COOL;
if (cool_setpoint != currentSettings.temperature) { if (cool_setpoint != currentSettings.temperature) {
cool_setpoint = currentSettings.temperature; cool_setpoint = currentSettings.temperature;
save(currentSettings.temperature, cool_storage); save(currentSettings.temperature, cool_storage);
} }
this->action = climate::CLIMATE_ACTION_IDLE;
} else if (strcmp(currentSettings.mode, "FAN") == 0) { } else if (strcmp(currentSettings.mode, "FAN") == 0) {
this->mode = climate::CLIMATE_MODE_FAN_ONLY; this->mode = climate::CLIMATE_MODE_FAN_ONLY;
this->action = climate::CLIMATE_ACTION_FAN;
} else if (strcmp(currentSettings.mode, "AUTO") == 0) { } else if (strcmp(currentSettings.mode, "AUTO") == 0) {
this->mode = climate::CLIMATE_MODE_AUTO; this->mode = climate::CLIMATE_MODE_AUTO;
if (auto_setpoint != currentSettings.temperature) { if (auto_setpoint != currentSettings.temperature) {
auto_setpoint = currentSettings.temperature; auto_setpoint = currentSettings.temperature;
save(currentSettings.temperature, auto_storage); save(currentSettings.temperature, auto_storage);
} }
this->action = climate::CLIMATE_ACTION_IDLE;
} else { } else {
ESP_LOGW( ESP_LOGW(
TAG, TAG,
@ -281,6 +293,7 @@ void MitsubishiHeatPump::hpSettingsChanged() {
} }
} else { } else {
this->mode = climate::CLIMATE_MODE_OFF; this->mode = climate::CLIMATE_MODE_OFF;
this->action = climate::CLIMATE_ACTION_OFF;
} }
ESP_LOGI(TAG, "Climate mode is: %i", this->mode); ESP_LOGI(TAG, "Climate mode is: %i", this->mode);
@ -308,10 +321,7 @@ void MitsubishiHeatPump::hpSettingsChanged() {
/* ******** HANDLE MITSUBISHI VANE CHANGES ******** /* ******** HANDLE MITSUBISHI VANE CHANGES ********
* const char* VANE_MAP[7] = {"AUTO", "1", "2", "3", "4", "5", "SWING"}; * const char* VANE_MAP[7] = {"AUTO", "1", "2", "3", "4", "5", "SWING"};
*/ */
if ( if (strcmp(currentSettings.vane, "SWING") == 0) {
(strcmp(currentSettings.vane, "AUTO") == 0)
|| (strcmp(currentSettings.vane, "SWING") == 0)
) {
this->swing_mode = climate::CLIMATE_SWING_VERTICAL; this->swing_mode = climate::CLIMATE_SWING_VERTICAL;
} }
else { else {
@ -327,33 +337,6 @@ void MitsubishiHeatPump::hpSettingsChanged() {
this->target_temperature = currentSettings.temperature; this->target_temperature = currentSettings.temperature;
ESP_LOGI(TAG, "Target temp is: %f", this->target_temperature); ESP_LOGI(TAG, "Target temp is: %f", this->target_temperature);
/*
* Compute running state from mode & temperatures
*/
switch (this->mode) {
case climate::CLIMATE_MODE_HEAT:
if (this->current_temperature < this->target_temperature) {
this->action = climate::CLIMATE_ACTION_HEATING;
}
else {
this->action = climate::CLIMATE_ACTION_IDLE;
}
break;
case climate::CLIMATE_MODE_COOL:
if (this->current_temperature > this->target_temperature) {
this->action = climate::CLIMATE_ACTION_COOLING;
}
else {
this->action = climate::CLIMATE_ACTION_IDLE;
}
break;
case climate::CLIMATE_MODE_DRY:
this->action = climate::CLIMATE_ACTION_DRYING;
default:
this->action = climate::CLIMATE_ACTION_OFF;
}
/* /*
* ******** Publish state back to ESPHome. ******** * ******** Publish state back to ESPHome. ********
*/ */
@ -365,6 +348,48 @@ void MitsubishiHeatPump::hpSettingsChanged() {
*/ */
void MitsubishiHeatPump::hpStatusChanged(heatpumpStatus currentStatus) { void MitsubishiHeatPump::hpStatusChanged(heatpumpStatus currentStatus) {
this->current_temperature = currentStatus.roomTemperature; this->current_temperature = currentStatus.roomTemperature;
switch (this->mode) {
case climate::CLIMATE_MODE_HEAT:
if (currentStatus.operating) {
this->action = climate::CLIMATE_ACTION_HEATING;
}
else {
this->action = climate::CLIMATE_ACTION_IDLE;
}
break;
case climate::CLIMATE_MODE_COOL:
if (currentStatus.operating) {
this->action = climate::CLIMATE_ACTION_COOLING;
}
else {
this->action = climate::CLIMATE_ACTION_IDLE;
}
break;
case climate::CLIMATE_MODE_AUTO:
this->action = climate::CLIMATE_ACTION_IDLE;
if (currentStatus.operating) {
if (this->current_temperature > this->target_temperature) {
this->action = climate::CLIMATE_ACTION_COOLING;
} else if (this->current_temperature < this->target_temperature) {
this->action = climate::CLIMATE_ACTION_HEATING;
}
}
break;
case climate::CLIMATE_MODE_DRY:
if (currentStatus.operating) {
this->action = climate::CLIMATE_ACTION_DRYING;
}
else {
this->action = climate::CLIMATE_ACTION_IDLE;
}
break;
case climate::CLIMATE_MODE_FAN_ONLY:
this->action = climate::CLIMATE_ACTION_FAN;
break;
default:
this->action = climate::CLIMATE_ACTION_OFF;
}
this->publish_state(); this->publish_state();
} }