diff --git a/components/jk_bms/jk_bms.cpp b/components/jk_bms/jk_bms.cpp index c589682a..83d6aec2 100644 --- a/components/jk_bms/jk_bms.cpp +++ b/components/jk_bms/jk_bms.cpp @@ -348,7 +348,7 @@ void JkBms::on_status_data_(const std::vector &data) { } void JkBms::update() { - this->read_registers(FUNCTION_READ_ALL, ADDRESS_READ_ALL); + this->query_balancer_status(); if (this->enable_fake_traffic_) { // Start: 0x4E, 0x57, 0x01, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x01 diff --git a/components/jk_modbus/jk_modbus.cpp b/components/jk_modbus/jk_modbus.cpp index 50578018..75ffdfaf 100644 --- a/components/jk_modbus/jk_modbus.cpp +++ b/components/jk_modbus/jk_modbus.cpp @@ -37,6 +37,9 @@ bool JkModbus::parse_jk_modbus_byte_(uint8_t byte) { this->rx_buffer_.push_back(byte); const uint8_t *raw = &this->rx_buffer_[0]; + // @FIXME + return false; + // Byte 0: Start sequence (0x4E) if (at == 0) return true; @@ -152,5 +155,19 @@ void JkModbus::read_registers(uint8_t function, uint8_t address) { this->flush(); } +void JkModbus::query_balancer_status() { + uint8_t frame[7]; + frame[0] = 0x55; + frame[1] = 0xAA; + frame[2] = 0x01; + frame[3] = 0xFF; + frame[4] = 0x00; + frame[5] = 0x00; + frame[6] = 0xFF; + + this->write_array(frame, 7); + this->flush(); +} + } // namespace jk_modbus } // namespace esphome diff --git a/components/jk_modbus/jk_modbus.h b/components/jk_modbus/jk_modbus.h index 96ee5f6d..9005a072 100644 --- a/components/jk_modbus/jk_modbus.h +++ b/components/jk_modbus/jk_modbus.h @@ -22,6 +22,7 @@ class JkModbus : public uart::UARTDevice, public Component { void send(uint8_t function, uint8_t address, uint8_t value); void read_registers(uint8_t function, uint8_t address); + void query_balancer_status(); protected: bool parse_jk_modbus_byte_(uint8_t byte); @@ -39,6 +40,7 @@ class JkModbusDevice { void send(int8_t function, uint8_t address, uint8_t value) { this->parent_->send(function, address, value); } void read_registers(uint8_t function, uint8_t address) { this->parent_->read_registers(function, address); } + void query_balancer_status() { this->parent_->query_balancer_status(); } protected: friend JkModbus;