-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
BT Pin code supported? #41
Comments
Looks like the device does not respond, which is highly likely due to the set pin. Unfortunately, there is currently no function to set a pin for a battery in the integration. Would need to take a look on how to implement that. Would you volunteer as beta-tester (since I have no battery with pin available)? |
You could also try to pair the battery from the terminal using bluetoothctl see https://commandmasters.com/commands/bluetoothctl-linux/ chapter 4.
|
Thanks for your quick reply! I will be very happy to do the beta test for sure! And I will try to pair from the terminal right away, will let you know asap. |
Hmm, tried to pair but maybe from the wrong terminal? I have a ssh and terminal add-on in HA which reports: |
And maybe a silly suggestion since my programming skills are very low but maybe this could be solved (by someone with te right skills) with a small setting added to the ESPHome proxy based upon this: on_passkey_request ble_client:
|
You see that as reply to which command? When you enter the terminal you should see:
|
Yes, I tried it there indeed but my BMS device is not listed there... It is in the log of the proxy though, see the attached logfile. |
I changed the log settings in the proxy to VERY_VERBOSE and copied the parts with the Battery which seem to indicate it gets connected if I understand it well. Still do not understand why it does not appear in HA though. I attached a screenshot of the bluetoothctl devices output as well. Also strange, I reloaded your integration without the proxy and it failed on the entities. When I connected the proxy again it reloaded well. |
Which install type did you choose for Homeassistant? Are you using HASS or other?
--
Touched, not typed.
|
I am running HA core 2024.8.3 with supervisor 2024.08.0 on OS 13.1 on generic-x86-64 |
Can you please check the output of |
Attached is the result of the list command. I guess however looking at the log that the MBS is paired with the proxy. I also sniffed the communication between the original app and the device and it looks like there is some special communications. I will include the log as well. What I did, I removed and reinstalled the app so it would ask for the password again. Im am looking at it and trying to make some sense out of it: ![]() |
Which app did you reinstall that works and asks for the pin again? Just for reference so I can have a look.
--
Touched, not typed.
|
The XiaoXiangElectric app on my iPhone, there is also an Android version, see https://xiaoxiangbms.com/download/. |
Hi! I digged a bit through the documentation on the Internet regarding the proxy and pairing, which is very weak regarding hints. Can you please try to bring the BMS into the range of your controller directly attached to homeassistant (and probably also disable the BT proxy) and then try to pair the device once see #41 (comment). If I interpret the documentation correct, it should afterwards also work with the BT proxy, but the pairing needs to happen directly without the proxy. |
Hi Patrick, that is going to be quite a challenge but I will see whether I can figure something out to make that possible. Will get back to you hopefully soon. |
Hi Hans, I have not too much hope, but you could try this code: https://github.com/patman15/BMS_BLE-HA/tree/feature/pairing I found some hints that pairing is not supported by the bleak library which is used by Home Assistant. |
This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 15 days. |
This issue was closed because it has been stalled for 15 days with no activity. |
@HansWegman Did you have any luck with on_passkey_request? I'm trying to set up this integration with ESPHome BT proxy and JK BMS that apparently does require PIN, but no luck so far |
Hello Dmitri, unfortunately not. I have found a possible solution though with https://github.com/syssi/esphome-jbd-bms. The author has figured out the encryption and is working on implementing that into the software so hopefully there is a solution soon. |
Checklist
Describe the issue
I just tried to install the integration to connect by XiaoXiangElectric Battery (JBD) which went like a charm, unfortunately although my battery was detected nicely through the ESPHome proxy and 11 entities were added, none have any data. I suspect this is because I have added a bluetooth pin to the battery which unfortunately cannot be removed. I have set it to "000000" now but still no data and the integration reports: "Failed to initialise BMS Hans Battery, continuing". Any idea if it is possible to enter the pin somewhere?
log
2024-09-01 17:21:35.661 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration bms_ble which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-09-01 17:21:41.997 INFO (MainThread) [homeassistant.setup] Setting up bms_ble
2024-09-01 17:21:41.997 INFO (MainThread) [homeassistant.setup] Setup of domain bms_ble took 0.00 seconds
2024-09-01 17:21:41.997 DEBUG (MainThread) [custom_components.bms_ble] Setup of
2024-09-01 17:22:23.632 DEBUG (MainThread) [custom_components.bms_ble] Bluetooth device detected: <BluetoothServiceInfoBleak name=Hans Battery address=A4:C1:37:04:2D:BE rssi=-65 manufacturer_data={11710: b'\x047\xc1\xa4'} service_data={} service_uuids=['0000ff00-0000-1000-8000-00805f9b34fb'] source=10:06:1C:16:7C:28 connectable=True time=240246.576593881 tx_power=None>
2024-09-01 17:22:23.634 DEBUG (MainThread) [custom_components.bms_ble] Setup of
2024-09-01 17:22:23.679 DEBUG (MainThread) [custom_components.bms_ble] Initializing coordinator for Hans Battery (A4:C1:37:04:2D:BE) as Jiabaida Smart BMS
2024-09-01 17:22:23.679 DEBUG (MainThread) [custom_components.bms_ble] device data: {'name': 'Hans Battery', 'address': 'A4:C1:37:04:2D:BE', 'rssi': -63, 'manufacturer_data': {11710: b'\x047\xc1\xa4'}, 'service_data': {}, 'service_uuids': ['0000ff00-0000-1000-8000-00805f9b34fb'], 'source': '10:06:1C:16:7C:28', 'advertisement': AdvertisementData(local_name='Hans Battery', manufacturer_data={11710: b'\x047\xc1\xa4'}, service_uuids=['0000ff00-0000-1000-8000-00805f9b34fb'], tx_power=-127, rssi=-63), 'device': BLEDevice(A4:C1:37:04:2D:BE, Hans Battery), 'connectable': True, 'time': 240285.365139811, 'tx_power': None}
2024-09-01 17:22:23.679 DEBUG (MainThread) [custom_components.bms_ble] BMS Hans Battery data update
2024-09-01 17:22:23.680 DEBUG (MainThread) [custom_components.bms_ble.plugins.jbd_bms] Connecting BMS (Hans Battery)
2024-09-01 17:22:35.168 DEBUG (MainThread) [custom_components.bms_ble] Device communication timeout
2024-09-01 17:22:35.169 DEBUG (MainThread) [custom_components.bms_ble] Finished fetching Hans Battery data in 11.489 seconds (success: False)
2024-09-01 17:22:35.169 WARNING (MainThread) [custom_components.bms_ble] Failed to initialize BMS Hans Battery, continuing
2024-09-01 17:22:35.176 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up bms_ble.binary_sensor
2024-09-01 17:22:35.178 INFO (MainThread) [homeassistant.components.sensor] Setting up bms_ble.sensor
2024-09-01 17:23:05.091 DEBUG (MainThread) [custom_components.bms_ble] BMS Hans Battery data update
2024-09-01 17:23:05.092 DEBUG (MainThread) [custom_components.bms_ble.plugins.jbd_bms] BMS Hans Battery already connected
2024-09-01 17:23:15.095 DEBUG (MainThread) [custom_components.bms_ble] Device communication timeout
2024-09-01 17:23:15.095 DEBUG (MainThread) [custom_components.bms_ble] Finished fetching Hans Battery data in 10.004 seconds (success: False)
2024-09-01 17:23:45.091 DEBUG (MainThread) [custom_components.bms_ble] BMS Hans Battery data update
2024-09-01 17:23:45.091 DEBUG (MainThread) [custom_components.bms_ble.plugins.jbd_bms] BMS Hans Battery already connected
2024-09-01 17:23:55.094 DEBUG (MainThread) [custom_components.bms_ble] Device communication timeout
2024-09-01 17:23:55.095 DEBUG (MainThread) [custom_components.bms_ble] Finished fetching Hans Battery data in 10.003 seconds (success: False)
The text was updated successfully, but these errors were encountered: