Skip to content

Commit

Permalink
Fixed phase change while waiting for answer
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavlo Dudnytskyi committed Oct 17, 2023
1 parent 364d920 commit e464400
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions components/haier/haier_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ HaierClimateBase::HaierClimateBase()
HaierClimateBase::~HaierClimateBase() {}

void HaierClimateBase::set_phase(ProtocolPhases phase) {
if (this->haier_protocol_.is_waiting_for_answer()) {
ESP_LOGW(TAG, "Changing phase while waiting for answer: %s => %s", phase_to_string_(this->protocol_phase_), phase_to_string_(phase));
}
if (this->protocol_phase_ != phase) {
ESP_LOGV(TAG, "Phase transition: %s => %s", phase_to_string_(this->protocol_phase_), phase_to_string_(phase));
this->protocol_phase_ = phase;
Expand Down Expand Up @@ -246,10 +249,10 @@ void HaierClimateBase::loop() {
this->last_valid_status_timestamp_ = now;
}
};
if ((this->protocol_phase_ == ProtocolPhases::IDLE) ||
(this->protocol_phase_ == ProtocolPhases::SENDING_STATUS_REQUEST) ||
(this->protocol_phase_ == ProtocolPhases::SENDING_UPDATE_SIGNAL_REQUEST) ||
(this->protocol_phase_ == ProtocolPhases::SENDING_SIGNAL_LEVEL)) {
if ((this->protocol_phase_ == ProtocolPhases::IDLE) || (!this->haier_protocol_.is_waiting_for_answer() &&
((this->protocol_phase_ == ProtocolPhases::SENDING_STATUS_REQUEST) ||
(this->protocol_phase_ == ProtocolPhases::SENDING_UPDATE_SIGNAL_REQUEST) ||
(this->protocol_phase_ == ProtocolPhases::SENDING_SIGNAL_LEVEL)))) {
// If control message or action is pending we should send it ASAP unless we are in initialisation
// procedure or waiting for an answer
if (this->action_request_ != ActionRequest::NO_ACTION) {
Expand Down

0 comments on commit e464400

Please sign in to comment.