Support ANT BMS (legacy BLE protocol)#468
Conversation
|
Hi! Thanks for your contribution. Just a quick feedback as I'm low on time at the moment: yes, the high/low voltage was already in my thoughts as well, so let's introduce them, but I will need to implement them also for other BMSs (the readout, not the backup). Same for cycles, I do agree, that this calculation makes sense. |
|
Hello Patrick, I've taken a bit of time to look at the tests and I see they follow a common structure so I'll just copy/adapt to the new protocol the existing implementation(s). I think I'm going to push this sooner than later so that I can 'pop' this from my tasks stack ;) BTW, I also have some ideas/requests about the component functionality (i.e. adding BMS config features) but we'll discuss this in a dedicated thread. I see this repository has no 'Discussions' enabled so I'll maybe open an issue for the matter. Davide |
patman15
left a comment
There was a problem hiding this comment.
Code already now looks pretty good to me, thanks for the great work! I'm still a bit unsure about the 'data' variables in your _notification_handler but after a hard week I miss the energy to understand your logic. I'll probably come back to that one or fix it later myself. Thanks again and I only request a few changes.
|
Hey, for the |
|
mypy should still be complaining but once the code from #476 will be merged in it should be ok. |
…ternal '_add_missing_values'
|
Good to go! |
* adapt naming - `AdvertisementPattern` to `MatcherPattern` - `reconnect` to `keep_alive` * remove dummy example * fix removal of 0 values in _temp_values() (#480) * Add Seplos `SP1??B*` pattern (#482) * Feature align aiobmsble (#481) * adapt naming - `AdvertisementPattern` to `MatcherPattern` - `reconnect` to `keep_alive` * remove dummy example * Add detection of LiTime 24V BMS type based on serial number (#484) * Fix operator precedence (#485) * fix removal of 0 values in _temp_values() * fix operator precedence * Support ANT BMS (legacy BLE protocol) (#468) * Support ANT BMS (legacy BLE protocol) * Refine frame parsing for ant_bms_legacy * Add basic testing for ant_bms_legacy * Rename plugin ant_bms_legacy to ant_legacy_bms to comply with component conventions * Fix ant_legacy_bms test coverage * Fix compliancy with bms_ble repository design * Add 'total_charge' value (#476) to results * Remove 'dead' code * Remove unused import * Fix temperature sensors count * Remove cell high/low voltage parsing and calc 'delta_voltage' from internal '_add_missing_values' * Remove local reference to self._data in member function body * Fix 'BaseBMS._temp_values' operator precedence * Fix imported symbol * Fix missing comma after manual merge * fix pylint issues * fix design_capacity / temp sensors * add typing * Update ant_legacy_bms.py * align constants * test to check design capacity provision * rename legacy bms * Update README.md --------- Co-authored-by: patman15 <14628713+patman15@users.noreply.github.com> * update to 1.21.0 --------- Co-authored-by: krahabb <13969600+krahabb@users.noreply.github.com>
* migrate to aiobmsble * disable mypy * fix device discovery for aiobmsble * add test for v2 config entry not yet correct * complete test coverage * Update aiobmsble to 0.2.2 * disable fuzz tests * update for new retry-connector * update requirements * Update fuzzing.yaml * Update manifest.json * Update README.md * Feature align aiobmsble (#488) * adapt naming - `AdvertisementPattern` to `MatcherPattern` - `reconnect` to `keep_alive` * remove dummy example * fix removal of 0 values in _temp_values() (#480) * Add Seplos `SP1??B*` pattern (#482) * Feature align aiobmsble (#481) * adapt naming - `AdvertisementPattern` to `MatcherPattern` - `reconnect` to `keep_alive` * remove dummy example * Add detection of LiTime 24V BMS type based on serial number (#484) * Fix operator precedence (#485) * fix removal of 0 values in _temp_values() * fix operator precedence * Support ANT BMS (legacy BLE protocol) (#468) * Support ANT BMS (legacy BLE protocol) * Refine frame parsing for ant_bms_legacy * Add basic testing for ant_bms_legacy * Rename plugin ant_bms_legacy to ant_legacy_bms to comply with component conventions * Fix ant_legacy_bms test coverage * Fix compliancy with bms_ble repository design * Add 'total_charge' value (#476) to results * Remove 'dead' code * Remove unused import * Fix temperature sensors count * Remove cell high/low voltage parsing and calc 'delta_voltage' from internal '_add_missing_values' * Remove local reference to self._data in member function body * Fix 'BaseBMS._temp_values' operator precedence * Fix imported symbol * Fix missing comma after manual merge * fix pylint issues * fix design_capacity / temp sensors * add typing * Update ant_legacy_bms.py * align constants * test to check design capacity provision * rename legacy bms * Update README.md --------- Co-authored-by: patman15 <14628713+patman15@users.noreply.github.com> * update to 1.21.0 --------- Co-authored-by: krahabb <13969600+krahabb@users.noreply.github.com> * fix ant_leg_bms inclusion * Update CONTRIBUTING.md * Update README.md --------- Co-authored-by: krahabb <13969600+krahabb@users.noreply.github.com>
|
@krahabb I moved all plugins to a new library https://github.com/patman15/aiobmsble/ |
|
Thank you @patman15, |
This PR addresses an issue I'm having with an ANT BMS.
After searching the net I've seen through https://github.com/syssi/esphome-ant-bms that it looks like there are 2 versions of these devices at least on the protocol/software side and the 'legacy' one is nicely managed in the repository (the
*_old_blesource files)By using the advertised data of my ANT BMS I've come around a slightly different matcher with the following keys:
where, as can be seen, the difference with respect to the actual ANT matcher lies in the
manufacturer_idkeyI hope this is enough to cover any other ANT implementing this protocol but we'll see...
I've checked ruff and mypy on the code but I'm still in a 'draft' stage at the moment (missing tests for sure)
This early submission is to make you aware I'm working on this and I'd like to discuss some adjustments regarding the BaseBMS model.
More specifically, I've added some custom keys to the
_FIELDSdefinitions in order to leverage the automatic parse of the frame done byBaseBMS._decode_databut these keys are not defined in theBMSsampleTypedDict (hence mypy complaining).If these keys prove to not be relevant in the overall integration architecture I'd quickly cleanup the
_FIELDSand do theint.from_byteslocally in the custom plugin.The keys I'm talking about are:
I think the
cell_high_voltageandcell_low_voltagecould be interesting for the general architecture. They're related todelta_voltagebut providing those two would give more insights about the cells without the need to expose the full array of cells (See #441)The
total_cycled_chargeinstead is a somewhat duplicate ofcycles. It carries the total amount of charge exchanged by the battery/bms in its life and it is then related to cycles with:If you like them we could better define these new key names or, if not, as stated, I'll just drop them from the _FIELDS and use them only in internal decoding.