We have two SuperVolt batteries in use. With battery 1 this addon worked just fine. With battery 2 it did not work and gave an error saying something along the lines of "Invalid length: 20".
While developing my own program to read the SuperVolt batteries I encountered the same issue and after some debugging and contacting SuperVolt customer support found out that certain SuperVolt batteries do not send the response as a single string, but in multiple chunks:
To fix this I adapted the _notification_handler in supervolt.py to now check if the received string is complete and if not piece it together each time a new chunk comes in.
Checking if the response is simply done by checking if it starts with a colon and ends with a tilde.
I also added a comment about this behavior to document this rare behavior and why this handling is needed.
Testing
We tested this on a Raspberry Pi 4 and verified that both batteries now work as expected with this addon.
Problem
We have two SuperVolt batteries in use. With battery 1 this addon worked just fine. With battery 2 it did not work and gave an error saying something along the lines of "Invalid length: 20". While developing my own program to read the SuperVolt batteries I encountered the same issue and after some debugging and contacting SuperVolt customer support found out that certain SuperVolt batteries do not send the response as a single string, but in multiple chunks:
Instead of:
Solution
To fix this I adapted the _notification_handler in
supervolt.py
to now check if the received string is complete and if not piece it together each time a new chunk comes in. Checking if the response is simply done by checking if it starts with a colon and ends with a tilde. I also added a comment about this behavior to document this rare behavior and why this handling is needed.Testing
We tested this on a Raspberry Pi 4 and verified that both batteries now work as expected with this addon.