bradcagle / dbus-btbattery

20 stars 3 forks source link

Issue get new JBD BMS working with internal Bluetooth #14

Open agilastic opened 5 months ago

agilastic commented 5 months ago

My old JBD-BMS works fine.

I upgraded my battery system with a new JBD BMS and new batteries.

./scan.py #results: Device a4:c1:37:53:21:45 (public), RSSI=-67 dB Flags = 05 Incomplete 16b Services = 0000ff00-0000-1000-8000-00805f9b34fb Complete Local Name = AP21S002P21200A Manufacturer = 45215337c1a4

I can't get it run. JBD might has changed something. Here is my output:

In jbdbt.py I uncommented print(hex_string) in line 132 and
and added at pos: Hack elif len(data) == 20: if self.cellData == None: pprint("self.CellData == None")

root@raspberrypi4:/opt/victronenergy/dbus-btbattery# /opt/victronenergy/dbus-btbattery/dbus-btbattery.py a4:c1:37:53:21:45 INFO:BluetoothBattery:Starting dbus-btbattery INFO:BluetoothBattery:dbus-btbattery v0.1.3 INFO:BluetoothBattery:Connecting a4:c1:37:53:21:45 INFO:BluetoothBattery:0.0013429630000700854 INFO:BluetoothBattery:0.002221575000021403 INFO:BluetoothBattery:Connected a4:c1:37:53:21:45 00 dd0400200d060d0e0d0d0d070d080d060d080d08 0d0a0d080d070d080d080d0a0d0c0d0afe8177 dd03002214db00005ca3753000002f7200000000 1000564f0110010b1e00000075305ca30000fa16 'self.CellData == None' Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner self.run() File "/opt/victronenergy/dbus-btbattery/jbdbt.py", line 106, in run while self.bt.waitForNotifications(4): File "/usr/lib/python3.8/site-packages/bluepy/btle.py", line 560, in waitForNotifications resp = self._getResp(['ntfy','ind'], timeout) File "/usr/lib/python3.8/site-packages/bluepy/btle.py", line 416, in _getResp self.delegate.handleNotification(hnd, data) File "/opt/victronenergy/dbus-btbattery/jbdbt.py", line 161, in handleNotification self.cellData = self.cellData + data TypeError: unsupported operand type(s) for +: 'NoneType' and 'bytes'

Any ideas?

agilastic commented 5 months ago

Ok I got it.
If you need more details what I've done, see my fork and last commit. Works so far: https://github.com/agilastic/dbus-btbattery/commit/1258e35d09016c18fe5d91922afc0c56fcdc931d

bradcagle commented 5 months ago

Great I'll take a look, and test with my BMSs here.

Thanks

dsrawding commented 5 months ago

FYI, I have two 2024 4s batteries with the new JDB BMSs. Had the same problem as agilastic. Added his changes and I'm up and running!