Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions esphome/components/navien/navien.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@ namespace navien {
static const char *TAG = "navien.sensor";

void Navien::setup() {
ESP_LOGCONFIG(TAG, "Setting rs485 into receive mode");
// Set the rs485 into receive mode
pinMode(D5, OUTPUT);
digitalWrite(D5, LOW);

// Set the driver into regular mode (from undefined startup)
ESP_LOGCONFIG(TAG, "Activating TTL/CMOS buffer");
pinMode(D6, OUTPUT);
digitalWrite(D6, HIGH);
}

void Navien::update() {
Expand Down Expand Up @@ -163,7 +154,7 @@ void Navien::parse_packet(){
break;
}

// ESP_LOGV(TAG, "Calculated checksum over %d bytes => 0x%02X", HDR_SIZE + this->recv_buffer.hdr.len, crc);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with this change, but it should not have been broken the compilation since the line is commented.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I found that with an older revision where it was still uncommented. So I just transferred my fix to this line even though it's now commented out.

// ESP_LOGV(TAG, "Calculated checksum over %d bytes => 0x%02X", HDR_SIZE + this->recv_buffer.hdr.len, crc_c);

}

Expand Down Expand Up @@ -223,7 +214,7 @@ void Navien::loop() {
}
}

void Navien::send_cmd(const uint8_t * buffer, uint8 len){
void Navien::send_cmd(const uint8_t * buffer, uint8_t len){
if (buffer && len)
this->write_array(buffer, len);
}
Expand Down Expand Up @@ -316,6 +307,7 @@ uint8_t Navien::checksum(const uint8_t * buffer, uint8_t len, uint16_t seed){
return result;
}

#ifdef USE_SWITCH
void NavienOnOffSwitch::setup() {
ESP_LOGCONFIG(TAG, "Setting up Switch '%s'...", this->name_.c_str());

Expand Down Expand Up @@ -344,6 +336,7 @@ void NavienOnOffSwitch::write_state(bool state) {
void NavienOnOffSwitch::dump_config(){
ESP_LOGCONFIG(TAG, "Empty custom switch");
}
#endif

} // namespace navien
} // namespace esphome
9 changes: 7 additions & 2 deletions esphome/components/navien/navien.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

#include "esphome/core/component.h"
#include "esphome/components/sensor/sensor.h"
#ifdef USE_SWITCH
#include "esphome/components/switch/switch.h"
#endif
#include "esphome/components/uart/uart.h"

namespace esphome {
Expand Down Expand Up @@ -226,7 +229,7 @@ class Navien : public PollingComponent, public uart::UARTDevice {
void send_turn_off_cmd();

protected:
void send_cmd(const uint8_t * buffer, uint8 len);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

void send_cmd(const uint8_t * buffer, uint8_t len);

protected:
// Keeps track of the state machine and iterates through
Expand Down Expand Up @@ -259,6 +262,7 @@ class Navien : public PollingComponent, public uart::UARTDevice {
sensor::Sensor *water_flow_sensor;
};

#ifdef USE_SWITCH
class NavienOnOffSwitch : public switch_::Switch, public Component {
protected:
Navien * parent;
Expand All @@ -269,6 +273,7 @@ class NavienOnOffSwitch : public switch_::Switch, public Component {
void write_state(bool state) override;
void dump_config() override;
};

#endif

} // namespace navien
} // namespace esphome
11 changes: 11 additions & 0 deletions esphome/navien.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ api:
ota:


output:
# Set the rs485 into receive mode
- platform: gpio
pin: GPIO14
inverted: true
id: uart_rs485_receive_mode
# Set the driver into regular mode (from undefined startup)
- platform: gpio
pin: GPIO12
id: uart_driver_regular_mode

uart:
# tx_pin: TX
# rx_pin: RX
Expand Down