Skip to content

Commit

Permalink
debug (action on climate component)
Browse files Browse the repository at this point in the history
  • Loading branch information
echavet committed Jan 19, 2024
1 parent 0c57c6f commit bb26247
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 49 deletions.
45 changes: 45 additions & 0 deletions components/cn105/climateControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,51 @@ void CN105Climate::controlMode() {
}


void CN105Climate::setActionIfOperatingTo(climate::ClimateAction action) {
if (currentStatus.operating) {
this->action = action;
} else {
this->action = climate::CLIMATE_ACTION_IDLE;
}
ESP_LOGD(TAG, "setting action to -> %d", this->action);
}

void CN105Climate::setActionIfOperatingAndCompressorIsActiveTo(climate::ClimateAction action) {
if (currentStatus.compressorFrequency <= 0) {
this->action = climate::CLIMATE_ACTION_IDLE;
} else {
this->setActionIfOperatingTo(action);
}
}

void CN105Climate::updateAction() {
ESP_LOGV(TAG, "updating action back to espHome...");
switch (this->mode) {
case climate::CLIMATE_MODE_HEAT:
this->setActionIfOperatingAndCompressorIsActiveTo(climate::CLIMATE_ACTION_HEATING);
break;
case climate::CLIMATE_MODE_COOL:
this->setActionIfOperatingAndCompressorIsActiveTo(climate::CLIMATE_ACTION_COOLING);
break;
case climate::CLIMATE_MODE_HEAT_COOL:
this->setActionIfOperatingAndCompressorIsActiveTo(
(this->current_temperature > this->target_temperature ?
climate::CLIMATE_ACTION_COOLING :
climate::CLIMATE_ACTION_HEATING));
break;
case climate::CLIMATE_MODE_DRY:
this->setActionIfOperatingAndCompressorIsActiveTo(climate::CLIMATE_ACTION_DRYING);
break;
case climate::CLIMATE_MODE_FAN_ONLY:
this->action = climate::CLIMATE_ACTION_FAN;
break;
default:
this->action = climate::CLIMATE_ACTION_OFF;
}

ESP_LOGD(TAG, "Climate mode is: %i", this->mode);
ESP_LOGD(TAG, "Climate action is: %i", this->action);
}

climate::ClimateTraits CN105Climate::traits() {
// Définir les caractéristiques de ton climatiseur ici
Expand Down
4 changes: 3 additions & 1 deletion components/cn105/hp_readings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,16 @@ void CN105Climate::statusChanged(heatpumpStatus status) {
currentStatus.roomTemperature = status.roomTemperature;
this->current_temperature = currentStatus.roomTemperature;

this->updateAction(); // update action info on HA climate component

this->publish_state();
this->compressor_frequency_sensor->publish_state(currentStatus.compressorFrequency);
}


void CN105Climate::publishStateToHA(heatpumpSettings settings) {
checkPowerAndModeSettings(settings);
this->updateAction();
this->updateAction(); // update action info on HA climate component
checkFanSettings(settings);
checkVaneSettings(settings);
// HA Temp
Expand Down
48 changes: 0 additions & 48 deletions components/cn105/hp_writings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,54 +54,6 @@ void CN105Climate::statusChanged() {
this->publish_state();
}

void CN105Climate::setActionIfOperatingTo(climate::ClimateAction action) {
if (currentStatus.operating) {
this->action = action;
} else {
this->action = climate::CLIMATE_ACTION_IDLE;
}
ESP_LOGD(TAG, "setting action to -> %d", this->action);
}

void CN105Climate::setActionIfOperatingAndCompressorIsActiveTo(climate::ClimateAction action) {
if (currentStatus.compressorFrequency <= 0) {
this->action = climate::CLIMATE_ACTION_IDLE;
} else {
this->setActionIfOperatingTo(action);
}
}

void CN105Climate::updateAction() {
ESP_LOGV(TAG, "updating action back to espHome...");
switch (this->mode) {
case climate::CLIMATE_MODE_HEAT:
this->setActionIfOperatingAndCompressorIsActiveTo(climate::CLIMATE_ACTION_HEATING);
break;
case climate::CLIMATE_MODE_COOL:
this->setActionIfOperatingAndCompressorIsActiveTo(climate::CLIMATE_ACTION_COOLING);
break;
case climate::CLIMATE_MODE_HEAT_COOL:
this->setActionIfOperatingAndCompressorIsActiveTo(
(this->current_temperature > this->target_temperature ?
climate::CLIMATE_ACTION_COOLING :
climate::CLIMATE_ACTION_HEATING));
break;
case climate::CLIMATE_MODE_DRY:
this->setActionIfOperatingAndCompressorIsActiveTo(climate::CLIMATE_ACTION_DRYING);
break;
case climate::CLIMATE_MODE_FAN_ONLY:
this->action = climate::CLIMATE_ACTION_FAN;
break;
default:
this->action = climate::CLIMATE_ACTION_OFF;
}

ESP_LOGD(TAG, "Climate mode is: %i", this->mode);
ESP_LOGD(TAG, "Climate action is: %i", this->action);
}



void CN105Climate::prepareInfoPacket(uint8_t* packet, int length) {
ESP_LOGV(TAG, "preparing info packet...");

Expand Down

0 comments on commit bb26247

Please sign in to comment.