Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JiKong BMS timout during initialization #90

Closed
5 tasks done
SkeLLLa opened this issue Nov 17, 2024 · 22 comments · Fixed by #96
Closed
5 tasks done

JiKong BMS timout during initialization #90

SkeLLLa opened this issue Nov 17, 2024 · 22 comments · Fixed by #96
Assignees
Labels
bug Something isn't working

Comments

@SkeLLLa
Copy link

SkeLLLa commented Nov 17, 2024

Checklist

  • I have tried the latest version of BMS_BLE-HA.
  • I have enabled debug logging for my installation.
  • This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).
  • This issue is not a duplicate issue of any previous issue.
  • I have filled out the issue template to the best of my ability.

Provide the type of BMS you used:

Jikong Smart BMS

Describe the issue

I've installed this integration in addition to batmon to see if it works. Initially it wasn't picking up battery at all, but eventually (maybe after upgrading to 1.9.1 and upgrading HA to latest version) I've received a notification that the battery was discovered.

So I've added the battery, however it failed during initialization step. I suspect that the problem is somewhere on my end, since batmon addon didn't work either. However if my debug info will help to make this integration better or fix some issues for other users, I'll be glad to help.

I also suspect that my BMS might not satisfy the requirement "(HW version >=11 required)", but didn't know how to check that.

I see that there's a timeout issue there, so might be it's possible to configure bigger timeout values somehow?

Reproduction steps

1. Add integration to HA, and enable debug logs
2. Wait until battery is discovered
3. Add the battery to integration
4. Battery starts initialization but fails with timeout error.

Debug logs

2024-11-17 12:24:36.248 DEBUG (MainThread) [custom_components.bms_ble] Setup of <ConfigEntry entry_id=01JCWNPAZRY0AZ2JZ2HE9BZJ7K version=1 domain=bms_ble title=12v420a state=ConfigEntryState.SETUP_IN_PROGRESS unique_id=C8:47:80:14:D0:C2>
2024-11-17 12:24:36.249 DEBUG (MainThread) [custom_components.bms_ble] Initializing coordinator for 12v420a (C8:47:80:14:D0:C2) as Jikong Smart BMS
2024-11-17 12:24:36.249 DEBUG (MainThread) [custom_components.bms_ble] device data: {'name': '12v420a', 'address': 'C8:47:80:14:D0:C2', 'rssi': -72, 'manufacturer_data': {2917: b'\x88\xa0\xc8G\x80\x14\xd0\xc2'}, 'service_data': {}, 'service_uuids': ['00001800-0000-1000-8000-00805f9b34fb', '00001801-0000-1000-8000-00805f9b34fb', '0000180a-0000-1000-8000-00805f9b34fb', '0000180f-0000-1000-8000-00805f9b34fb', '0000ffe0-0000-1000-8000-00805f9b34fb', 'f000ffc0-0451-4000-b000-000000000000'], 'source': 'DC:A6:32:DA:44:EC', 'advertisement': AdvertisementData(local_name='12v420a', manufacturer_data={2917: b'\x88\xa0\xc8G\x80\x14\xd0\xc2'}, service_uuids=['00001800-0000-1000-8000-00805f9b34fb', '00001801-0000-1000-8000-00805f9b34fb', '0000180a-0000-1000-8000-00805f9b34fb', '0000180f-0000-1000-8000-00805f9b34fb', '0000ffe0-0000-1000-8000-00805f9b34fb', 'f000ffc0-0451-4000-b000-000000000000'], rssi=-72), 'device': BLEDevice(C8:47:80:14:D0:C2, 12v420a), 'connectable': True, 'time': 4465821.940952145, 'tx_power': None}
2024-11-17 12:24:36.250 DEBUG (MainThread) [custom_components.bms_ble] 12v420a: BMS data update
2024-11-17 12:24:36.250 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] Connecting BMS (12v420a)
2024-11-17 12:24:36.251 DEBUG (MainThread) [bleak_retry_connector] C8:47:80:14:D0:C2 - C8:47:80:14:D0:C2: Connection attempt: 1
2024-11-17 12:24:39.971 DEBUG (MainThread) [bleak_retry_connector] C8:47:80:14:D0:C2 - C8:47:80:14:D0:C2: Connected after 1 attempts
2024-11-17 12:24:39.971 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a19-0000-1000-8000-00805f9b34fb (#40): ['read', 'notify']
2024-11-17 12:24:39.971 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a27-0000-1000-8000-00805f9b34fb (#27): ['read']
2024-11-17 12:24:39.972 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a50-0000-1000-8000-00805f9b34fb (#37): ['read']
2024-11-17 12:24:39.972 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a28-0000-1000-8000-00805f9b34fb (#31): ['read']
2024-11-17 12:24:39.972 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a2a-0000-1000-8000-00805f9b34fb (#35): ['read']
2024-11-17 12:24:39.973 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a25-0000-1000-8000-00805f9b34fb (#25): ['read']
2024-11-17 12:24:39.973 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a26-0000-1000-8000-00805f9b34fb (#29): ['read']
2024-11-17 12:24:39.973 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a23-0000-1000-8000-00805f9b34fb (#33): ['read']
2024-11-17 12:24:39.973 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a24-0000-1000-8000-00805f9b34fb (#23): ['read']
2024-11-17 12:24:39.973 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a29-0000-1000-8000-00805f9b34fb (#21): ['read']
2024-11-17 12:24:39.974 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 0000ffe1-0000-1000-8000-00805f9b34fb (#17): ['write-without-response', 'write', 'notify']
2024-11-17 12:24:39.974 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 0000ffe2-0000-1000-8000-00805f9b34fb (#15): ['write-without-response']
2024-11-17 12:24:39.974 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a05-0000-1000-8000-00805f9b34fb (#11): ['read', 'indicate']
2024-11-17 12:24:39.974 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered f000ffc2-0451-4000-b000-000000000000 (#48): ['write-without-response', 'write', 'notify']
2024-11-17 12:24:39.975 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered f000ffc1-0451-4000-b000-000000000000 (#44): ['write-without-response', 'write', 'notify']
2024-11-17 12:24:39.975 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a04-0000-1000-8000-00805f9b34fb (#8): ['read']
2024-11-17 12:24:39.975 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a01-0000-1000-8000-00805f9b34fb (#4): ['read', 'write']
2024-11-17 12:24:39.975 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a00-0000-1000-8000-00805f9b34fb (#2): ['read', 'write']
2024-11-17 12:24:39.976 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a02-0000-1000-8000-00805f9b34fb (#6): ['read']
2024-11-17 12:24:39.976 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Using characteristics handle #17 (notify), #17 (write)
2024-11-17 12:24:50.578 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) request cell info
2024-11-17 12:24:51.478 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Rx BLE data (start): bytearray(b'U\xaa\xeb\x90\x03\x98JK_B2A8S20P\x00\x00\x00\x00\x0011.XA\x00\x00\x0011.48\x00\x00\x00\xe4\xa7F\x00\x07\x00\x00\x0012v420a\x00\x00\x00\x00\x00\x00\x00\x00\x001234\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00240704\x00\x00404092C2262\x00000\x00Input Userdata\x00\x00140703\x00\x00\x00\x00')
2024-11-17 12:24:51.480 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Rx BLE data (cnt.): bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
2024-11-17 12:24:51.873 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Rx BLE data (cnt.): bytearray(b'\xfe\xf9\xff\xff\x1f-\x00\x02\x00\x00\x00\x00\x90\x1f\x00\x00\x00\x00\xc0\xd8\xe72\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\t\x00\x00\x00d\x00\x00\x00_\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
2024-11-17 12:24:52.265 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Rx BLE data (cnt.): bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfe\xbf!\x06\x00\x00\x00\x00\x00\x00\x00\x00\xcd')
2024-11-17 12:24:52.266 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Rx BLE data (cnt.): bytearray(b'\xaaU\x90\xeb\xc8\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00D')
2024-11-17 12:24:54.740 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Rx BLE data (start): bytearray(b'U\xaa\xeb\x90\x01\x98\xac\r\x00\x00(\n\x00\x00\xc2\x0b\x00\x00\x10\x0e\x00\x00z\r\x00\x00\n\x00\x00\x00\x84\r\x00\x00\xb8\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc4\t\x00\x00@\r\x03\x00\x1e\x00\x00\x00<\x00\x00\x00@\r\x03\x00,\x01\x00\x00<\x00\x00\x00<\x00\x00\x00\xd0\x07\x00\x00&\x02\x00\x00\xf4\x01\x00\x00&\x02\x00\x00\xf4\x01\x00\x00\x14\x00\x00\x002\x00\x00\x00\xe8\x03\x00\x00 \x03\x00\x00\x04\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00')
2024-11-17 12:24:55.041 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Rx BLE data (cnt.): bytearray(b'\x00\x00\xa0h\x06\x00\xdc\x05\x00\x00\xe4\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
2024-11-17 12:25:01.768 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] Disconnected from BMS (12v420a)
2024-11-17 12:25:03.167 DEBUG (MainThread) [custom_components.bms_ble] 12v420a: device communication timed out
2024-11-17 12:25:03.167 DEBUG (MainThread) [custom_components.bms_ble] Finished fetching 12v420a data in 26.917 seconds (success: False)
2024-11-17 12:25:03.168 DEBUG (MainThread) [custom_components.bms_ble] 12v420a: shuting down BMS device
2024-11-17 12:25:22.161 DEBUG (MainThread) [custom_components.bms_ble] Setup of <ConfigEntry entry_id=01JCWNPAZRY0AZ2JZ2HE9BZJ7K version=1 domain=bms_ble title=12v420a state=ConfigEntryState.SETUP_IN_PROGRESS unique_id=C8:47:80:14:D0:C2>
2024-11-17 12:25:22.162 DEBUG (MainThread) [custom_components.bms_ble] Initializing coordinator for 12v420a (C8:47:80:14:D0:C2) as Jikong Smart BMS
2024-11-17 12:25:22.163 DEBUG (MainThread) [custom_components.bms_ble] device data: {'name': '12v420a', 'address': 'C8:47:80:14:D0:C2', 'rssi': -71, 'manufacturer_data': {2917: b'\x88\xa0\xc8G\x80\x14\xd0\xc2'}, 'service_data': {}, 'service_uuids': ['00001800-0000-1000-8000-00805f9b34fb', '00001801-0000-1000-8000-00805f9b34fb', '0000180a-0000-1000-8000-00805f9b34fb', '0000180f-0000-1000-8000-00805f9b34fb', '0000ffe0-0000-1000-8000-00805f9b34fb', 'f000ffc0-0451-4000-b000-000000000000'], 'source': 'DC:A6:32:DA:44:EC', 'advertisement': AdvertisementData(local_name='12v420a', manufacturer_data={2917: b'\x88\xa0\xc8G\x80\x14\xd0\xc2'}, service_uuids=['00001800-0000-1000-8000-00805f9b34fb', '00001801-0000-1000-8000-00805f9b34fb', '0000180a-0000-1000-8000-00805f9b34fb', '0000180f-0000-1000-8000-00805f9b34fb', '0000ffe0-0000-1000-8000-00805f9b34fb', 'f000ffc0-0451-4000-b000-000000000000'], rssi=-71), 'device': BLEDevice(C8:47:80:14:D0:C2, 12v420a), 'connectable': True, 'time': 4465870.600427386, 'tx_power': None}
2024-11-17 12:25:22.164 DEBUG (MainThread) [custom_components.bms_ble] 12v420a: BMS data update
2024-11-17 12:25:22.165 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] Connecting BMS (12v420a)
2024-11-17 12:25:22.165 DEBUG (MainThread) [bleak_retry_connector] C8:47:80:14:D0:C2 - C8:47:80:14:D0:C2: Connection attempt: 1
2024-11-17 12:25:24.836 DEBUG (MainThread) [bleak_retry_connector] C8:47:80:14:D0:C2 - C8:47:80:14:D0:C2: Connected after 1 attempts
2024-11-17 12:25:24.836 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a19-0000-1000-8000-00805f9b34fb (#40): ['read', 'notify']
2024-11-17 12:25:24.837 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a27-0000-1000-8000-00805f9b34fb (#27): ['read']
2024-11-17 12:25:24.837 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a50-0000-1000-8000-00805f9b34fb (#37): ['read']
2024-11-17 12:25:24.838 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a28-0000-1000-8000-00805f9b34fb (#31): ['read']
2024-11-17 12:25:24.838 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a2a-0000-1000-8000-00805f9b34fb (#35): ['read']
2024-11-17 12:25:24.838 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a25-0000-1000-8000-00805f9b34fb (#25): ['read']
2024-11-17 12:25:24.839 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a26-0000-1000-8000-00805f9b34fb (#29): ['read']
2024-11-17 12:25:24.839 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a23-0000-1000-8000-00805f9b34fb (#33): ['read']
2024-11-17 12:25:24.839 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a24-0000-1000-8000-00805f9b34fb (#23): ['read']
2024-11-17 12:25:24.840 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a29-0000-1000-8000-00805f9b34fb (#21): ['read']
2024-11-17 12:25:24.840 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 0000ffe1-0000-1000-8000-00805f9b34fb (#17): ['write-without-response', 'write', 'notify']
2024-11-17 12:25:24.840 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 0000ffe2-0000-1000-8000-00805f9b34fb (#15): ['write-without-response']
2024-11-17 12:25:24.841 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a05-0000-1000-8000-00805f9b34fb (#11): ['read', 'indicate']
2024-11-17 12:25:24.842 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered f000ffc2-0451-4000-b000-000000000000 (#48): ['write-without-response', 'write', 'notify']
2024-11-17 12:25:24.842 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered f000ffc1-0451-4000-b000-000000000000 (#44): ['write-without-response', 'write', 'notify']
2024-11-17 12:25:24.842 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a04-0000-1000-8000-00805f9b34fb (#8): ['read']
2024-11-17 12:25:24.842 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a01-0000-1000-8000-00805f9b34fb (#4): ['read', 'write']
2024-11-17 12:25:24.842 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a00-0000-1000-8000-00805f9b34fb (#2): ['read', 'write']
2024-11-17 12:25:24.843 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a02-0000-1000-8000-00805f9b34fb (#6): ['read']
2024-11-17 12:25:24.843 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Using characteristics handle #17 (notify), #17 (write)
2024-11-17 12:25:35.158 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) request cell info
2024-11-17 12:25:37.934 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Rx BLE data (start): bytearray(b'U\xaa\xeb\x90\x03\x9eJK_B2A8S20P\x00\x00\x00\x00\x0011.XA\x00\x00\x0011.48\x00\x00\x00\xe4\xa7F\x00\x07\x00\x00\x0012v420a\x00\x00\x00\x00\x00\x00\x00\x00\x001234\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00240704\x00\x00404092C2262\x00000\x00Input Userdata\x00\x00140703\x00\x00\x00\x00')
2024-11-17 12:25:38.027 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Rx BLE data (cnt.): bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
2024-11-17 12:25:41.497 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Rx BLE data (cnt.): bytearray(b'\xfe\xf9\xff\xff\x1f-\x00\x02\x00\x00\x00\x00\x90\x1f\x00\x00\x00\x00\xc0\xd8\xe72\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\t\x00\x00\x00d\x00\x00\x00_\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
2024-11-17 12:25:42.996 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Rx BLE data (cnt.): bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfe\xbf!\x06\x00\x00\x00\x00\x00\x00\x00\x00\xd3')
2024-11-17 12:25:43.877 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Rx BLE data (cnt.): bytearray(b'\xaaU\x90\xeb\xc8\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00D')
2024-11-17 12:25:52.391 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] Disconnected from BMS (12v420a)
2024-11-17 12:25:55.265 DEBUG (MainThread) [custom_components.bms_ble] 12v420a: device communication timed out
2024-11-17 12:25:55.266 DEBUG (MainThread) [custom_components.bms_ble] Finished fetching 12v420a data in 33.102 seconds (success: False)
2024-11-17 12:25:55.266 DEBUG (MainThread) [custom_components.bms_ble] 12v420a: shuting down BMS device
2024-11-17 12:26:00.683 DEBUG (MainThread) [custom_components.bms_ble] Setup of <ConfigEntry entry_id=01JCWNPAZRY0AZ2JZ2HE9BZJ7K version=1 domain=bms_ble title=12v420a state=ConfigEntryState.SETUP_IN_PROGRESS unique_id=C8:47:80:14:D0:C2>
2024-11-17 12:26:00.684 DEBUG (MainThread) [custom_components.bms_ble] Initializing coordinator for 12v420a (C8:47:80:14:D0:C2) as Jikong Smart BMS
2024-11-17 12:26:00.685 DEBUG (MainThread) [custom_components.bms_ble] device data: {'name': '12v420a', 'address': 'C8:47:80:14:D0:C2', 'rssi': -72, 'manufacturer_data': {2917: b'\x88\xa0\xc8G\x80\x14\xd0\xc2'}, 'service_data': {}, 'service_uuids': ['00001800-0000-1000-8000-00805f9b34fb', '00001801-0000-1000-8000-00805f9b34fb', '0000180a-0000-1000-8000-00805f9b34fb', '0000180f-0000-1000-8000-00805f9b34fb', '0000ffe0-0000-1000-8000-00805f9b34fb', 'f000ffc0-0451-4000-b000-000000000000'], 'source': 'DC:A6:32:DA:44:EC', 'advertisement': AdvertisementData(local_name='12v420a', manufacturer_data={2917: b'\x88\xa0\xc8G\x80\x14\xd0\xc2'}, service_uuids=['00001800-0000-1000-8000-00805f9b34fb', '00001801-0000-1000-8000-00805f9b34fb', '0000180a-0000-1000-8000-00805f9b34fb', '0000180f-0000-1000-8000-00805f9b34fb', '0000ffe0-0000-1000-8000-00805f9b34fb', 'f000ffc0-0451-4000-b000-000000000000'], rssi=-72), 'device': BLEDevice(C8:47:80:14:D0:C2, 12v420a), 'connectable': True, 'time': 4465909.784000312, 'tx_power': None}
2024-11-17 12:26:00.685 DEBUG (MainThread) [custom_components.bms_ble] 12v420a: BMS data update
2024-11-17 12:26:00.685 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] Connecting BMS (12v420a)
2024-11-17 12:26:00.686 DEBUG (MainThread) [bleak_retry_connector] C8:47:80:14:D0:C2 - C8:47:80:14:D0:C2: Connection attempt: 1
2024-11-17 12:26:04.131 DEBUG (MainThread) [bleak_retry_connector] C8:47:80:14:D0:C2 - C8:47:80:14:D0:C2: Connected after 1 attempts
2024-11-17 12:26:04.131 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a19-0000-1000-8000-00805f9b34fb (#40): ['read', 'notify']
2024-11-17 12:26:04.132 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a27-0000-1000-8000-00805f9b34fb (#27): ['read']
2024-11-17 12:26:04.132 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a50-0000-1000-8000-00805f9b34fb (#37): ['read']
2024-11-17 12:26:04.132 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a28-0000-1000-8000-00805f9b34fb (#31): ['read']
2024-11-17 12:26:04.132 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a2a-0000-1000-8000-00805f9b34fb (#35): ['read']
2024-11-17 12:26:04.132 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a25-0000-1000-8000-00805f9b34fb (#25): ['read']
2024-11-17 12:26:04.133 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a26-0000-1000-8000-00805f9b34fb (#29): ['read']
2024-11-17 12:26:04.133 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a23-0000-1000-8000-00805f9b34fb (#33): ['read']
2024-11-17 12:26:04.133 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a24-0000-1000-8000-00805f9b34fb (#23): ['read']
2024-11-17 12:26:04.133 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a29-0000-1000-8000-00805f9b34fb (#21): ['read']
2024-11-17 12:26:04.133 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 0000ffe1-0000-1000-8000-00805f9b34fb (#17): ['write-without-response', 'write', 'notify']
2024-11-17 12:26:04.134 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 0000ffe2-0000-1000-8000-00805f9b34fb (#15): ['write-without-response']
2024-11-17 12:26:04.134 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a05-0000-1000-8000-00805f9b34fb (#11): ['read', 'indicate']
2024-11-17 12:26:04.134 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered f000ffc2-0451-4000-b000-000000000000 (#48): ['write-without-response', 'write', 'notify']
2024-11-17 12:26:04.134 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered f000ffc1-0451-4000-b000-000000000000 (#44): ['write-without-response', 'write', 'notify']
2024-11-17 12:26:04.134 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a04-0000-1000-8000-00805f9b34fb (#8): ['read']
2024-11-17 12:26:04.135 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a01-0000-1000-8000-00805f9b34fb (#4): ['read', 'write']
2024-11-17 12:26:04.135 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a00-0000-1000-8000-00805f9b34fb (#2): ['read', 'write']
2024-11-17 12:26:04.135 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Discovered 00002a02-0000-1000-8000-00805f9b34fb (#6): ['read']
2024-11-17 12:26:04.135 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Using characteristics handle #17 (notify), #17 (write)
2024-11-17 12:26:13.540 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) request cell info
2024-11-17 12:26:15.939 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Rx BLE data (start): bytearray(b'U\xaa\xeb\x90\x03\xa3JK_B2A8S20P\x00\x00\x00\x00\x0011.XA\x00\x00\x0011.48\x00\x00\x00\xe4\xa7F\x00\x07\x00\x00\x0012v420a\x00\x00\x00\x00\x00\x00\x00\x00\x001234\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00240704\x00\x00404092C2262\x00000\x00Input Userdata\x00\x00140703\x00\x00\x00\x00')
2024-11-17 12:26:15.941 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Rx BLE data (cnt.): bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
2024-11-17 12:26:17.701 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Rx BLE data (cnt.): bytearray(b'\xfe\xf9\xff\xff\x1f-\x00\x02\x00\x00\x00\x00\x90\x1f\x00\x00\x00\x00\xc0\xd8\xe72\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\t\x00\x00\x00d\x00\x00\x00_\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
2024-11-17 12:26:18.771 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Rx BLE data (cnt.): bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfe\xbf!\x06\x00\x00\x00\x00\x00\x00\x00\x00\xd8')
2024-11-17 12:26:20.158 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Rx BLE data (cnt.): bytearray(b'\xaaU\x90\xeb\xc8\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00D')
2024-11-17 12:26:23.571 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Rx BLE data (start): bytearray(b'U\xaa\xeb\x90\x01\xa3\xac\r\x00\x00(\n\x00\x00\xc2\x0b\x00\x00\x10\x0e\x00\x00z\r\x00\x00\n\x00\x00\x00\x84\r\x00\x00\xb8\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc4\t\x00\x00@\r\x03\x00\x1e\x00\x00\x00<\x00\x00\x00@\r\x03\x00,\x01\x00\x00<\x00\x00\x00<\x00\x00\x00\xd0\x07\x00\x00&\x02\x00\x00\xf4\x01\x00\x00&\x02\x00\x00\xf4\x01\x00\x00\x14\x00\x00\x002\x00\x00\x00\xe8\x03\x00\x00 \x03\x00\x00\x04\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00')
2024-11-17 12:26:23.573 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] (12v420a) Rx BLE data (cnt.): bytearray(b'\x00\x00\xa0h\x06\x00\xdc\x05\x00\x00\xe4\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
2024-11-17 12:26:29.604 DEBUG (MainThread) [custom_components.bms_ble.plugins.jikong_bms] Disconnected from BMS (12v420a)
2024-11-17 12:26:32.185 DEBUG (MainThread) [custom_components.bms_ble] 12v420a: device communication timed out
2024-11-17 12:26:32.185 DEBUG (MainThread) [custom_components.bms_ble] Finished fetching 12v420a data in 31.500 seconds (success: False)
2024-11-17 12:26:32.186 DEBUG (MainThread) [custom_components.bms_ble] 12v420a: shuting down BMS device
@SkeLLLa SkeLLLa added the bug Something isn't working label Nov 17, 2024
@patman15
Copy link
Owner

Hi! Thanks for the report. I can see the BMS react in different way than expected, so most probably there is a mismatch in the protocol version, or similar. Need to check more details. Have you installed the latest firmware?
You can try to change the timeout (if you know how to edit the source on your installation), although I doubt it will help, here:

@SkeLLLa
Copy link
Author

SkeLLLa commented Nov 18, 2024

@patman15 I've already tried to change the timeouts, but likely forgot to send the message with updated and logs. It didn't help a lot. Same error.

I'll try to connect with mobile app and see what firmware is there and also will try updating it to see if it helps, thanks.

@patman15
Copy link
Owner

patman15 commented Nov 18, 2024

I need to check the protocol details that I can see from the log. I know there are different versions out there. Most probably it's a different one. I'll check other information on the Internet to find solutions.
What would help: a BT trace from the Android app communicating with the BMS, if you know how to debug Android BT ...

@patman15
Copy link
Owner

@SkeLLLa I checked again the code. What puzzles me is that the BMS does respond with wrong messages to a request for the cell information. So far I can only see that different BMS answer with different data but always the same type of reply, while yours just responds with a different type. I haven't found any issue that explains the situation, also, I implemented the JK02_32S protocol which is for new JK-BMS >= hardware version 11.0 (f.e. JK-B2A8S20P hw 11.XW, sw 11.26)
I can see that you have exactly that BMS JK_B2A8S20P with HW 11.XA and SW 11.48. So all good.
Not sure how to proceed, it should work.

  • Is there probably some setting in the app that hinders communication?
  • Did you disconnect the app?
  • Is there some way to do a reset?
  • Are you able to provide a Bluetooth hcidump from the Android app while communicating?

Really hard to remotely guess what happened since all things look actually ok, but the BMS does not answer the request.

@SkeLLLa
Copy link
Author

SkeLLLa commented Nov 19, 2024

Hi.

First answering your questions:

  1. Doesn't think so, since the app (mobile) actually was never connected before I tried it today. I could think only about crappy bluetooth module on my PI4.
  2. As I said it was never connected before. I suspect that battery manufacturer did connections to test it, but it's definitely not in range.
  3. Yes, I've did non full reset, but what usually helps with stuck bluetooth on bms - turned off the battery for ~5-10 minutes and turned on again. When I've tried BatMon addon it helped, since after some time I couldn't see battery bluetooth, but after that it helped.
  4. Unfortunately currently I'm not at that place where battery is, so just asked another person to take some app screenshots. But might be I'll figure it out somehow.

Meanwhile I've installed the app to verify firmware. Here are some readings (if it helps you).
Also the bluetooth password (that app's is asking) is standard as I assume: 1234. Also I will try to search some info about jk protocol in https://github.com/syssi/esphome-jk-bms/tree/main/components/jk_bms_ble or other repos.

image
image

@patman15
Copy link
Owner

Hi!
If it has worked with batmon-ha then my current best guess is an issue with the Bluetooth connection / adapter. My protocol implementation is practically the same as the one there and the one from syssi, JK02_32S. At least I wouldn't know why the BMS does not answer at this stage. Sorry, I have a lot of further questions in order to narrow down this strange behaviour:

  • Which HA installation method did you use
  • Did you fully deactivate/uninstall batmon-ha before trying?
  • Do you have a lot of other devices in BT range? Can you get them out of range?
  • Do you have another BT dongle that you could try, or use an ESPHome Bluetooth proxy?
  • Probably deactivating WiFi (in case you have a wired connection) on the RPi helps. Be sure to keep BT on!

In summary, I still do not see a reason why it wouldn't work as with other users. 😞 Hopefully, some of the possibilities above bring hints.

@SkeLLLa
Copy link
Author

SkeLLLa commented Nov 20, 2024

Actually batmon-ha didn't work at all, but your integration at least show something in logs.

  1. I have supervised install on RPi4
  2. Yes, it is removed completely
  3. 97% of time the battery is only bluetooth device in range.
  4. I've came up to the same conclusion and already ordered a BT proxy, so will try with it. Also I have dongle, but it's not considered as stable according to HA docs. However I remember that previously I have connected a Bluetti battery with bluetti_mqtt and it worked perfectly fine. But it might be difference in protocol.
  5. WiFi on RPi is diactivated.

Currently I also trying to debug and see what's happening with https://github.com/jblance/mpp-solar, it has command line utility for jkbms, but didn't have too much time for tests. If I find something, I'll update you here or submit PR.

@patman15
Copy link
Owner

Ok, given your answers, given that the app on the phone works, given that I see replies from the BMS, but just not to the request, I think our best guess is to see what the app does. Can you follow the steps from this guide? Between step 2 and 3, please run the JK app until you see the voltage level, etc., then stop Bluetooth and follow the further steps to get the zip. Out of the zip, I would only need FS/data/log/bt/btsnoop_hci.log to check why the app works and integration doesn't.

@SkeLLLa
Copy link
Author

SkeLLLa commented Nov 20, 2024

Gotcha, will do that when I'll be in location with battery or just ask other person to do that. When I'll have the logs I'll upload them here.

@romanshypovskyi
Copy link

Hi, I have the same BMS, jk_b2a8s20p, I found that it stopped working since version 1.6.3
Commit 6efa1e414b7f8b1c25e94719a969cc24f43a31a6, after reverting this commit everything works again
Process hangs during initialization but works after timeout

Debug logs with and without commit 6efa1e414b7f8b1c25e94719a969cc24f43a31a6:
home-assistant_bms_ble_1.9.1.log
home-assistant_bms_ble_1.9.1_revert_6efa1e414b7f8b1c25e94719a969cc24f43a31a6.log

@patman15
Copy link
Owner

@romanshypovskyi that is an amazing hint! Thanks! Looks like the BMS needs some time after connect till accepts commands.
Can one of you try the branch which just delays the command?

@romanshypovskyi
Copy link

I just tried this branch and now everything works immediately without errors:
home-assistant_bms_ble_1.9.1+sleep1.log

@patman15
Copy link
Owner

Ok, I will do a bit cleaner version. I hope I can ask you for a retest before I merge. Unfortunately, I cannot check such behaviour myself. Thanks again for that amazing hint!

@romanshypovskyi
Copy link

No problem, I will test the new version. Thanks for your work!

@patman15
Copy link
Owner

patman15 commented Nov 21, 2024

@romanshypovskyi could you please check/confirm, that the updated branch (commit 7a5d7fd) still works? I removed the sleep (which is really ugly) and modified the protocol handling to get it working. Thanks a lot!

@romanshypovskyi
Copy link

Hi, strange behaviour now, sometimes everything works after first attempt, sometimes after couple of attempts

For example after third attempt:
home-assistant_bms_ble_2024-11-21T17-07-12.096Z.log

With 1 second delay it always works after first attempt

@patman15
Copy link
Owner

Thanks a lot, I will take a look why. I'm not happy with keeping the delay, it just is a new source for potential floating issues. That's why I keep fixing it.

@patman15
Copy link
Owner

@romanshypovskyi learned something new about the protocol which is implemented wrong in all the other implementations ...
If you could test again, it would be great. Hope I this time hit the right spot. As always, log would be great! Thanks a lot!

@romanshypovskyi
Copy link

Hi, looks like everything works fine now, I tried multiple times disable/enable integration, restart HA, and all good:
home-assistant_bms_ble_2024-11-22T17-48-30.116Z.log

@patman15
Copy link
Owner

😅 Finally! Thanks for your patience and the feedback! I hope you can also see continuous updates when you just leave it running. I'll clean it up for a release now. A spec would make things so much easier. 😶

@romanshypovskyi
Copy link

Everything works fine for almost an hour now. Thanks for your work!

@patman15 patman15 self-assigned this Nov 23, 2024
@patman15 patman15 linked a pull request Nov 23, 2024 that will close this issue
@SkeLLLa
Copy link
Author

SkeLLLa commented Dec 16, 2024

Hey, @patman15 . I was able to gather some logs with esp32 bt proxy.

With bt proxy it finally start working and receiving data. It's working not ideally, but since it receives data, Sometimes with following ble proxy config battery sensors become unavailable and then available again (see screenshot and logs attached).

So I blame RPi bluetooth adapter. Probably it doesn't work well either because of drivers or just because of RPi enclosure that blocks signal.

[22:40:27][C][bluetooth_proxy:091]: Bluetooth Proxy:
[22:40:27][C][bluetooth_proxy:092]:   Active: YES
[22:40:27][C][bluetooth_proxy:093]:   Connections: 3
[22:40:27][C][bluetooth_proxy:094]:   Raw advertisements: YES
[22:40:27][C][esp32_ble:391]: ESP32 BLE:
[22:40:27][C][esp32_ble:393]:   MAC address: 12:34:56:78:90:12
[22:40:27][C][esp32_ble:394]:   IO Capability: none
[22:40:27][C][esp32_ble_tracker:658]: BLE Tracker:
[22:40:27][C][esp32_ble_tracker:659]:   Scan Duration: 300 s
[22:40:27][C][esp32_ble_tracker:660]:   Scan Interval: 320.0 ms
[22:40:27][C][esp32_ble_tracker:661]:   Scan Window: 30.0 ms
[22:40:27][C][esp32_ble_tracker:662]:   Scan Type: ACTIVE
[22:40:27][C][esp32_ble_tracker:663]:   Continuous Scanning: True

home-assistant_bms_ble_2024-12-16T20-44-41.587Z.log
home-assistant_bms_ble_2024-12-16T19-57-16.134Z.log
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants