helgeerbe / OpenDTU-OnBattery

Software for ESP32 to talk to Hoymiles Inverters and Victrons MPPT battery chargers (Ve.Direct)
GNU General Public License v2.0
253 stars 56 forks source link

feature: refactor PylontechCanBattery to be more generic #1064

Closed AndreasBoehm closed 5 days ago

AndreasBoehm commented 5 days ago

I bought a Pytes V5 battery and even though it should talk 'Pylontech'-protocol via CAN its not 100% supported right now. CAN messages look more like the BYD protocol: https://github.com/dfch/BydCanProtocol/tree/main?tab=readme-ov-file

To allow us to support different protocols i started to extract 'BatteryCanReceiver' as a a common base for all CAN batteries.

The main struggle right now is how we can keep the dummy data for the Pylontech working.

Please let me know if i went the right path with this and also if you have any idea how we can keep the dummy data working without ugly hacks.

AndreasBoehm commented 5 days ago

Builds are failing with error Exception: firmware binary too large: 1972016 > 1966080, I am surprised because it did work in Visual Studio Code.

schlimmchen commented 5 days ago

Maybe you are using an old version of the web app, which is slightly smaller? It is correct that the builds are failing. Let me remove generic and generic_esp32 from the build actions until we figured out how to address the overflowing sketch partition. Give me some time to find out what needs to be done.

schlimmchen commented 5 days ago

Correction: I think (hope) that you are building generic_esp32s3_usb, and that build does not fail. However, it is cancelled immediately when generic or generic_esp32 fails (whichever fails first).

I updated the development branch (see cb0f8f20) and rebased this PR onto that version of the development branch. And it seems to work as I'd hoped: the new PR build run is only building the ESP32-S3 firmwares (no need to touch the build.yml in the master branch).

AndreasBoehm commented 5 days ago

Thanks for your help @schlimmchen

Waiting for your comments on the code changes

AndreasBoehm commented 5 days ago

Yes, this PR is focused on the refactoring alone. Short lived PRs help to avoid merge conflicts and potentially motivate others to build new CAN protocol implementations as well.