patman15 / BMS_BLE-HA

This integration allows to monitor Bluetooth Low Energy (BLE) battery management systems (BMS) from within Home Assistant.
GNU Lesser General Public License v2.1
50 stars 9 forks source link

Add support Redodo battery BMS #78

Closed azisto closed 2 weeks ago

azisto commented 2 weeks ago

Checklist

Is your feature request related to a problem? Please describe.

Hi, is it possible to add Redodo Smart BMS support to your integration ?

Describe the solution you'd like

What information should I provide to do this?

Additional context

I try add to manifest.json { "local_name": "R-24*" },

and image

In Debug:

DEBUG (MainThread) [custom_components.bms_ble] Bluetooth device detected: <BluetoothServiceInfoBleak name=R-24100BNN160-A00643 address=C8:47:80:15:D8:34 rssi=-88 manufacturer_data={22618: b'\xc8G\x80\x15\xd84'} 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=BC:2B:02:10:E2:B4 connectable=True time=19205.862500036 tx_power=None>

patman15 commented 2 weeks ago

Hi! The information you already provided is helpful! Next, details about the used protocol, e.g. specification, would be needed. If you do not have that and can't find it, a BT debug trace from an Android/iOS app communicating with the BMS and the link to the app itself are necessary. If you know Python, you can also have a look at the contribution guidelines and give it a try yourself.

azisto commented 2 weeks ago

Hello, here is the link to the program: https://play.google.com/store/apps/details?id=com.redodopower.ble My python knowledge is very weak, but I was able to get a bluetooth dump from my smartphone while using the app. btsnoop_hci.log What else can I do?

patman15 commented 2 weeks ago

What else can I do?

Hmm, hope for bad weather in my area, so I'm bored. :laughing: Basically I think, I have everything I need, so just need to find some time to implement, the read-out, the emulation, and the tests. So it takes a bit. When (almost) done, I would ask you to test. Thanks for providing comprehensive information about the battery!

patman15 commented 2 weeks ago

@azisto is it really the case that I need to register with Redodo in order to use the app?! :disappointed: I guess you do not have any further documentation about the Bluetooth protocol, right?

azisto commented 2 weeks ago

@patman15 Yes, you need to create an account to use the app. I couldn't find any information about the Bluetooth protocol.

azisto commented 2 weeks ago

Maybe I could write to the manufacturer, but I don't know how to write a proper request (what exactly do I need from them and why)

patman15 commented 2 weeks ago

Well the ask would be a specification of the protocol between the battery and the app via Bluetooth, especially the frame format being used. I'll have another look tomorrow to see if I can proceed otherwise.

patman15 commented 2 weeks ago

@azisto ok, I had a look into the data that you provided and could come up with a first version that should work partially. Can you check the version from the linked branch in this ticket? Please follow the steps for manual installation in the README.

What I could not identify (but I think must be there) is SoC, remaining capacity, cycles, temperature. In you message you linked a btsnoop_hci.log that was extremely helpful to progress. Could you do this again, but also note down the time and the values from the app? Basically I would need the log and something like 14:32:16 -> SoC 56%, remaining capacity 34.8 Ah, 22 cycles, temp 38.1°C, current: 2.8A or a screenshot for simplicity. Ideal would be to change a bit the battery conditions, e.g. charge/discharge etc.

If you could provide that as a .zip attached (especially if you have a number of screenshots) that would be great, I think we can solve that together! Also any feedback to the first version is appreciated!

azisto commented 2 weeks ago

@patman15 Here you go. Now I will try the first version and give you my feedback soon. hci_logs.zip

patman15 commented 2 weeks ago

@azisto wow, that was a super set of information! I think I found the missing values, pushed a new commit, you can run a test. Let me know if the values are plausible. Be aware that you most likely cannot connect HA and the app in parallel, but you can simply disable it in HA and then have a look at the app.

azisto commented 2 weeks ago

@patman15, I just tried to add the previous version from this test branch to HA manually (according to your readme instructions). This is the problem I'm having. I must be doing something wrong. 2024-11-08 16:28:23.908 DEBUG (MainThread) [custom_components.bms_ble] Bluetooth device detected: <BluetoothServiceInfoBleak name=R-24100BNN160-A00643 address=C8:47:80:15:D8:34 rssi=-78 manufacturer_data={22618: b'\xc8G\x80\x15\xd84'} service_data={} service_uuids=['0000ffe0-0000-1000-8000-00805f9b34fb'] source=BC:2B:02:10:E2:B4 connectable=True time=54.93475358 tx_power=None> 2024-11-08 16:30:24.770 DEBUG (MainThread) [custom_components.bms_ble] user step bms

azisto commented 2 weeks ago

Update: I've uploaded the latest version. Everything is working now (commit 2e47676).

image

image

2024-11-08 16:54:29.890 DEBUG (MainThread) [custom_components.bms_ble] BMS data sample {'voltage': 26.731, 'current': 0.0, 'temperature': 23, 'battery_level': 69, 'cycle_capacity': 72.93, 'cycles': 3, 'cell#0': 3.342, 'cell#1': 3.341, 'cell#2': 3.341, 'cell#3': 3.341, 'cell#4': 3.342, 'cell#5': 3.342, 'cell#6': 3.341, 'cell#7': 3.341, 'power': 0.0, 'battery_charging': False, 'delta_voltage': 0.001}
2024-11-08 16:54:29.891 DEBUG (MainThread) [custom_components.bms_ble] Finished fetching R-24100BNN160-A00643 data in 0.139 seconds (success: True)
2024-11-08 16:54:59.752 DEBUG (MainThread) [custom_components.bms_ble] R-24100BNN160-A00643: BMS data update
2024-11-08 16:54:59.752 DEBUG (MainThread) [custom_components.bms_ble.plugins.redodo_bms] BMS R-24100BNN160-A00643 already connected
2024-11-08 16:54:59.752 DEBUG (MainThread) [custom_components.bms_ble.plugins.redodo_bms] (R-24100BNN160-A00643) replace with command to UUID ffe2
2024-11-08 16:54:59.889 DEBUG (MainThread) [custom_components.bms_ble.plugins.redodo_bms] R-24100BNN160-A00643: Received BLE data: 00 00 65 01 93 55 aa 00 f8 66 00 00 6a 68 00 00 0d 0d 0d 0d 0d 0d 0d 0d 0e 0d 0e 0d 0d 0d 0d 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17 00 17 00 17 00 00 00 00 00 7d 1c 04 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 45 00 64 00 00 00 03 00 00 00 5f 01 00 00 11
2024-11-08 16:54:59.889 DEBUG (MainThread) [custom_components.bms_ble] BMS data sample {'voltage': 26.73, 'current': 0.0, 'temperature': 23, 'battery_level': 69, 'cycle_capacity': 72.93, 'cycles': 3, 'cell#0': 3.341, 'cell#1': 3.341, 'cell#2': 3.341, 'cell#3': 3.341, 'cell#4': 3.342, 'cell#5': 3.342, 'cell#6': 3.341, 'cell#7': 3.341, 'power': 0.0, 'battery_charging': False, 'delta_voltage': 0.001}
2024-11-08 16:54:59.889 DEBUG (MainThread) [custom_components.bms_ble] Finished fetching R-24100BNN160-A00643 data in 0.137 seconds (success: True)
2024-11-08 16:55:29.752 DEBUG (MainThread) [custom_components.bms_ble] R-24100BNN160-A00643: BMS data update
2024-11-08 16:55:29.752 DEBUG (MainThread) [custom_components.bms_ble.plugins.redodo_bms] BMS R-24100BNN160-A00643 already connected
2024-11-08 16:55:29.752 DEBUG (MainThread) [custom_components.bms_ble.plugins.redodo_bms] (R-24100BNN160-A00643) replace with command to UUID ffe2
2024-11-08 16:55:29.904 DEBUG (MainThread) [custom_components.bms_ble.plugins.redodo_bms] R-24100BNN160-A00643: Received BLE data: 00 00 65 01 93 55 aa 00 d1 66 00 00 42 68 00 00 08 0d 08 0d 08 0d 08 0d 09 0d 09 0d 08 0d 08 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 f2 ff ff 17 00 17 00 17 00 00 00 00 00 7c 1c 04 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 45 00 64 00 00 00 03 00 00 00 5f 01 00 00 8f
2024-11-08 16:55:29.905 DEBUG (MainThread) [custom_components.bms_ble] BMS data sample {'voltage': 26.69, 'current': -3.58, 'temperature': 23, 'battery_level': 69, 'cycle_capacity': 72.92, 'cycles': 3, 'cell#0': 3.336, 'cell#1': 3.336, 'cell#2': 3.336, 'cell#3': 3.336, 'cell#4': 3.337, 'cell#5': 3.337, 'cell#6': 3.336, 'cell#7': 3.336, 'power': -95.55, 'battery_charging': False, 'delta_voltage': 0.001}
2024-11-08 16:55:29.905 DEBUG (MainThread) [custom_components.bms_ble] Finished fetching R-24100BNN160-A00643 data in 0.153 seconds (success: True)
2024-11-08 16:55:59.752 DEBUG (MainThread) [custom_components.bms_ble] R-24100BNN160-A00643: BMS data update
2024-11-08 16:55:59.752 DEBUG (MainThread) [custom_components.bms_ble.plugins.redodo_bms] BMS R-24100BNN160-A00643 already connected
2024-11-08 16:55:59.752 DEBUG (MainThread) [custom_components.bms_ble.plugins.redodo_bms] (R-24100BNN160-A00643) replace with command to UUID ffe2
2024-11-08 16:55:59.888 DEBUG (MainThread) [custom_components.bms_ble.plugins.redodo_bms] R-24100BNN160-A00643: Received BLE data: 00 00 65 01 93 55 aa 00 95 66 00 00 1b 68 00 00 02 0d 03 0d 04 0d 03 0d 04 0d 04 0d 04 0d 03 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 ee ff ff 17 00 17 00 17 00 00 00 00 00 78 1c 04 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 45 00 64 00 00 00 03 00 00 00 5f 01 00 00 fe
2024-11-08 16:55:59.888 DEBUG (MainThread) [custom_components.bms_ble] BMS data sample {'voltage': 26.651, 'current': -4.603, 'temperature': 23, 'battery_level': 69, 'cycle_capacity': 72.88, 'cycles': 3, 'cell#0': 3.33, 'cell#1': 3.331, 'cell#2': 3.332, 'cell#3': 3.331, 'cell#4': 3.332, 'cell#5': 3.332, 'cell#6': 3.332, 'cell#7': 3.331, 'power': -122.675, 'battery_charging': False, 'delta_voltage': 0.002}
2024-11-08 16:55:59.888 DEBUG (MainThread) [custom_components.bms_ble] Finished fetching R-24100BNN160-A00643 data in 0.136 seconds (success: True)`
patman15 commented 2 weeks ago

Except for one useless debug message, it looks good to me. Let me know if you are happy or spot some strange or implausible values. I'll release it with 1.9.0 with you confirm it's good.

azisto commented 2 weeks ago

I am very happy, thank you very much! According to my observations, all indicators are correct. The only thing that doesn't work is the runtime, maybe it should be the remaining time?

patman15 commented 2 weeks ago

The only thing that doesn't work is the runtime, maybe it should be the remaining time?

Good catch! I actually mixed up cycle charge (Ah) and cycle capacity (Wh). It showed the number of the first as the second which also lead to missing runtime value. Fixed in newest commit. Thanks!