Skip to content

Commit ce89c9e

Browse files
author
Hovhannes Tumanyan
committed
Merge branch 'pr-42'
2 parents b0d3127 + 7ccf864 commit ce89c9e

3 files changed

Lines changed: 13 additions & 8 deletions

File tree

esphome/components/navien/navien.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ void NavienBase::send_scheduled_recirculation_off_cmd() {
209209
}
210210

211211
void Navien::on_error(){
212+
ESP_LOGW(TAG, "Communications interrupted, resetting states!");
212213
this->target_temp_sensor->publish_state(0);
213214
this->outlet_temp_sensor->publish_state(0);
214215
this->inlet_temp_sensor->publish_state(0);
@@ -343,13 +344,14 @@ void NavienBase::send_scheduled_recirculation_off_cmd() {
343344
this->panel_version_sensor->publish_state(this->state.panel_version);
344345
}
345346

346-
void Navien::update() {
347-
ESP_LOGV(TAG, "Conn Status: received: %d, updated: %d", this->received_cnt, this->updated_cnt);
348-
349-
// Call receive on navien_link_ to process UART data
350-
if (navien_link_) {
347+
void Navien::loop() {
348+
if (navien_link_ && src_ == 0) {
351349
navien_link_->receive();
352350
}
351+
}
352+
353+
void Navien::update() {
354+
ESP_LOGV(TAG, "Conn Status: received: %d, updated: %d", this->received_cnt, this->updated_cnt);
353355

354356
// here we track how many packets were received
355357
// since the last update

esphome/components/navien/navien.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ namespace navien {
273273

274274
virtual float get_setup_priority() const { return setup_priority::HARDWARE; }
275275
virtual void setup() override;
276+
void loop() override;
276277
void update() override;
277278
void dump_config() override;
278279

esphome/components/navien/navien_link.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ void NavienLink::parse_packet(){
118118
crc_c = NavienLink::checksum(this->recv_buffer.raw_data, HDR_SIZE + this->recv_buffer.hdr.len, CHECKSUM_SEED_62);
119119
if (crc_c != crc_r){
120120
ESP_LOGE(TAG, "SRC:0x%02X Control Packet checksum error: 0x%02X (calc) != 0x%02X (recv), seed=0x%02X", this->recv_buffer.hdr.src, crc_c, crc_r, CHECKSUM_SEED_62);
121+
this->on_error();
121122
NavienLink::print_buffer(this->recv_buffer.raw_data, HDR_SIZE + this->recv_buffer.hdr.len + 1);
122123
break;
123124
}
@@ -169,7 +170,8 @@ void NavienLink::receive() {
169170
return;
170171
}
171172
if (!uart->read_array(this->recv_buffer.raw_data, HDR_SIZE)) {
172-
ESP_LOGV(TAG, "Failed to read header");
173+
ESP_LOGW(TAG, "Failed to read header");
174+
this->on_error();
173175
break;
174176
}
175177
this->recv_state = HEADER_PARSED;
@@ -185,7 +187,8 @@ void NavienLink::receive() {
185187
return;
186188
}
187189
if (!uart->read_array(this->recv_buffer.raw_data + HDR_SIZE, len)) {
188-
ESP_LOGV(TAG, "Failed to read %d bytes", len);
190+
ESP_LOGW(TAG, "Failed to read %d bytes", len);
191+
this->on_error();
189192
break;
190193
}
191194
ESP_LOGV(TAG, "Got Packet => %d bytes", len + HDR_SIZE);
@@ -208,7 +211,6 @@ void NavienLink::receive() {
208211
uart->write_array(NAVILINK_PRESENT, sizeof(NAVILINK_PRESENT));
209212
// NavienLink::print_buffer(NAVILINK_PRESENT, sizeof(NAVILINK_PRESENT));
210213
}
211-
this->on_error();
212214
}
213215

214216
// Navien::print_buffer(this->recv_buffer.raw_data, len + HDR_SIZE);

0 commit comments

Comments
 (0)