mirror of
https://github.com/geoffdavis/esphome-mitsubishiheatpump
synced 2024-08-30 18:12:13 +00:00
Merge pull request #11 from pgenera/better_action
Get running state from heatpump
This commit is contained in:
commit
b86ce7ddcd
83
espmhp.cpp
83
espmhp.cpp
@ -108,31 +108,37 @@ 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");
|
||||||
|
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");
|
||||||
|
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:
|
||||||
hp->setModeSetting("AUTO");
|
hp->setModeSetting("AUTO");
|
||||||
hp->setPowerSetting("ON");
|
hp->setPowerSetting("ON");
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
@ -142,7 +148,7 @@ void MitsubishiHeatPump::control(const climate::ClimateCall &call) {
|
|||||||
ESP_LOGV(
|
ESP_LOGV(
|
||||||
"control", "Sending target temp: %.1f",
|
"control", "Sending target temp: %.1f",
|
||||||
*call.get_target_temperature()
|
*call.get_target_temperature()
|
||||||
)
|
);
|
||||||
hp->setTemperature(*call.get_target_temperature());
|
hp->setTemperature(*call.get_target_temperature());
|
||||||
this->target_temperature = *call.get_target_temperature();
|
this->target_temperature = *call.get_target_temperature();
|
||||||
updated = true;
|
updated = true;
|
||||||
@ -239,14 +245,19 @@ void MitsubishiHeatPump::hpSettingsChanged() {
|
|||||||
if (strcmp(currentSettings.power, "ON") == 0) {
|
if (strcmp(currentSettings.power, "ON") == 0) {
|
||||||
if (strcmp(currentSettings.mode, "HEAT") == 0) {
|
if (strcmp(currentSettings.mode, "HEAT") == 0) {
|
||||||
this->mode = climate::CLIMATE_MODE_HEAT;
|
this->mode = climate::CLIMATE_MODE_HEAT;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
this->action = climate::CLIMATE_ACTION_IDLE;
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGW(
|
ESP_LOGW(
|
||||||
TAG,
|
TAG,
|
||||||
@ -256,6 +267,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);
|
||||||
@ -299,33 +311,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. ********
|
||||||
*/
|
*/
|
||||||
@ -337,6 +322,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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user