Open mavenius opened 1 month ago
Instead of porting the code over, just grab the log output from running the rover client and rebuild the payload (subbing in the device Id and checksum.)
Port https://github.com/cyrils/renogy-bt/blob/main/renogybt/RoverClient.py to esphome
Hi, is there a code for ported Python? I am not experienced enough to understand it and migrate it myself.
@riker65 I'm manually converting the Python requests and responses into ESPHome/C++ to port over the functionality.
Great Will check and try to understand
Thx
I tried to understand but failed:
how to enhance BTW these C++ functions (GetBatteryRequest and HandleBatteryData) to read a register for voltage hold in 0101 Register .
MAybe you could guide a little and just start with one register for voltage of controller. Than I could elaborate a little more.
I am a C++ dummy ...
Wondering why it is so complicated. There is similar function for modbus controller. https://community.home-assistant.io/t/renogy-wander-with-esphome/385909/21 `platform: modbus_controller modbus_controller_id: renogy_wanderer name: “Battery Volts” id: battery_volts
register_type: read address: 0x101 unit_of_measurement: “V” value_type: U_WORD`
unfortunately no similar implementation for BLE_Client
Hi I am trying to migrate your request to the rover, with different modbus registers.
I am wondering about your implementation
why do you start with hex 13B2 (Decimal 5042) with the vector?
I think 5042 is referencing current
int16_t current; std::memcpy(¤t, &x[2], sizeof(current));
but &2 is 5044 should be remaining capacity
vector<uint8_t> GetBatteryRequest(uint8_t batteryNumber) { // vector<uint8_t> dataBytes = { batteryNumber, 0x03, 0x13, 0xB2, 0x00, 0x06 }; // from chat hex 0100 to 0122 this should be vector<uint8_t> dataBytes = { batteryNumber, 0x03, 0x01, 0x00, 0x00, 0x23 };
voltage looks good but I can not confirm.
Migrating to Rover charger I did
vector
but with hex 101 I should get voltage from uint16_t voltage; std::memcpy(&voltage, &x[1], 2);
but value is not correct.
Any ideas what I need to adjust?
Thanks
I had to change the vector for the charger
this one is working for normal information
vector
for flashed history another vector and function is needed
// Parse the current int16_t current; // std::memcpy(¤t, &x[3], sizeof(current)); std::memcpy(¤t, &x[7], 2); current = ntohs(current); // Convert from network byte order to host byte order ESP_LOGD("HandleBatteryData current x7-2!!!!", "current: %d", current); // Parse the voltage uint16_t voltage; std::memcpy(&voltage, &x[5], 2); voltage = ntohs(voltage); // Convert from network byte order to host byte order ESP_LOGD("HandleBatteryData x5,2: VOLTAGE ", "voltage: %d", voltage);
Sweet!
I actually have a converted version of the Rover logic running on an ESP, and it looks good so far:
I'll update the repo ASAP; likely tomorrow.
On Sun, Sep 8, 2024, 11:30 riker04 @.***> wrote:
I had to change the vector for the charger this one is working for normal information vector
dataBytes = { batteryNumber, 0x03, 0x01, 0x00, 0x00, 0x23 }; for flashed history another vector and function is needed
// Parse the current int16_t current; // std::memcpy(¤t, &x[3], sizeof(current)); std::memcpy(¤t, &x[7], 2); current = ntohs(current); // Convert from network byte order to host byte order ESP_LOGD("HandleBatteryData current x7-2!!!!", "current: %d", current); // Parse the voltage uint16_t voltage; std::memcpy(&voltage, &x[5], 2); voltage = ntohs(voltage); // Convert from network byte order to host byte order ESP_LOGD("HandleBatteryData x5,2: VOLTAGE ", "voltage: %d", voltage);
— Reply to this email directly, view it on GitHub https://github.com/mavenius/renogy-bt-esphome/issues/3#issuecomment-2336727157, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABO65BERDWJ6KMDPJEYEUILZVRUQFAVCNFSM6AAAAABMQS6DQWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZWG4ZDOMJVG4 . You are receiving this because you authored the thread.Message ID: @.***>
Port https://github.com/cyrils/renogy-bt/blob/main/renogybt/RoverClient.py to esphome