Open RonnyKempe opened 3 months ago
Had the same problem + on top I had some line ending issue in parsing pylontech output and had to change the line delimiter to CR (\r or 0x0D). The integration seems to be hardcoded to one specific version of pylontech firmware.
I started to code support for more versions, but ran into some design problems combinded with lack of time and give up for now...
As quick fix: 1) create in your /config/esphome new folder (my is called my_components) 2) clone the pylontech extension into it, so you'll see file /config/esphome/my_components/pylontech/pylontech.cpp 3) in you yaml add this section to override original pylontech component with your local copy. I placed it after esphome: and esp32: sections:
external_components:
- source:
type: local
path: my_components
components: [pylontech]
In the code, I changed in the pylontech.cpp:
a) (I don't think you need it, as your lines are read correctly) constant for line ending:
static const uint8_t ASCII_LF = 0x0D;
b) parsing line change to:
const int parsed = sscanf( // NOLINT
buffer.c_str(), "%d %d %d %d %d %d %d %d %7s %7s %7s %7s %d%% %*d-%*d-%*d %*d:%*d:%*d %*s %*s %5*s %*s", // NOLINT
&l.bat_num, &l.volt, &l.curr, &l.tempr, &l.tlow, &l.thigh, &l.vlow, &l.vhigh, l.base_st, l.volt_st, // NOLINT
l.curr_st, l.temp_st, &l.coulomb/*, mostempr_s*/); // NOLINT
c) and few lines below, change:
if (parsed != 14) {
to
if (parsed != 13) {
The problem
Plyontech Component seems to have problems parsing the Answer from my 4 Year old Pylontech Stack. This is returned from the Master Battery 19:19:48 [D] [pylontech:081] invalid bat_num in line Power Volt Curr Tempr Tlow Thigh Vlow Vhigh Base.St Volt.St Curr.St Temp.St Coulomb Time B.V.St B.T.St
19:19:48 [W] [pylontech:085] invalid line: found only 13 items in 1 50831 0 30000 28000 29000 3378 3392 Idle Normal Normal Normal 105% 2024-06-08 01:21:48 Normal Normal
19:19:48 [W] [pylontech:085] invalid line: found only 13 items in 2 50820 0 30000 28000 29000 3379 3391 Idle Normal Normal Normal 106% 2024-06-08 01:21:47 Normal Normal
19:19:48 [W] [pylontech:085] invalid line: found only 13 items in 3 50818 0 29000 27000 27000 3377 3390 Idle Normal Normal Normal 107% 2024-06-08 01:21:47 Normal Normal
But expected seems to be // Power Volt Curr Tempr Tlow Thigh Vlow Vhigh Base.St Volt.St Curr.St Temp.St Coulomb Time B.V.St B.T.St MosTempr M.T.St // 1 50548 8910 25000 24200 25000 3368 3371 Charge Normal Normal Normal 97% 2021-06-30 20:49:45 Normal Normal 22700 Normal
Whats missing is "MosTempr" and "M.T.St"
Which version of ESPHome has the issue?
2024.5.5
What type of installation are you using?
Home Assistant Add-on
Which version of Home Assistant has the issue?
all
What platform are you using?
ESP8266
Board
wemos
Component causing the issue
Pylontech
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
No response