BMS_BLE-HA icon indicating copy to clipboard operation
BMS_BLE-HA copied to clipboard

Adding Fliteboard Efoil battery

Open alros100 opened this issue 1 year ago • 39 comments

Checklist

  • [X] I have filled out the template to the best of my ability.
  • [X] I have understood that this integration is only about battery management systems with Bluetooth Low Energy support.
  • [X] This only contains 1 feature request (if you have multiple feature requests, open one feature request for each feature request).
  • [X] This issue is not a duplicate of any previous feature requests.

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

Hello I tried the integration with my flight board efoil battery bms. But the integration reports no compatible device found.

would you please consider adding this battery ? I realize you have left instructions to add different bms. But I am not up to the task.

this is what I know about this battery from a Reddit post

thanks so much for considering Al

The Flitecells are designed by Battery Pack Brand Official Store | Em3ev. The BMS is a DXB46A that is custom-made for these packs by Tianjin D-powercore Co., Ltd their software is kinda junk and they do not publically release firmware. It has two temperature probes that are glued to cells 25% and 75% up one side of the pack.

Describe the solution you'd like

Adding support for the bms DXB46A please

Additional context

No response

alros100 avatar Sep 22 '24 18:09 alros100

Hi! In order to help I need more technical information about Bluetooth and the used protocol. Please have a look at this https://github.com/patman15/BMS_BLE-HA/issues/47#issuecomment-2353274285 about what I would need. The reason is, I do not own any (except one) of the supported batteries so I cannot figure it out on my own.

patman15 avatar Sep 23 '24 06:09 patman15

Hi

I was chatting with an iOS app developer who added the batter for me. I will reach out to him and see if he can help with the protocol and get back to you

Thanks so much for your help Al

alros100 avatar Sep 23 '24 10:09 alros100

I do have a log of the connection failed and then connecting to the iOS app Strom. Is there a way I can send you the log, rather than post a long log here ?

Al

alros100 avatar Sep 23 '24 12:09 alros100

You can add it as file attachment here (probably zip before), otherwise I have a discord profile in my profile.

patman15 avatar Sep 23 '24 13:09 patman15

Here is the log that connects. I am waiting to here back from the IOS developer as well log.zip

Thanks so much Al

alros100 avatar Sep 23 '24 15:09 alros100

Hmm, I have an idea how to do this, need to check, cannot promise much, especially not too soon. Will keep you posted.

patman15 avatar Sep 23 '24 16:09 patman15

The developer of IOS app is willing to help. I gave him link to this issue. Thanks so much !

alros100 avatar Sep 23 '24 17:09 alros100

Ok, I tried to emulate the BMS, but I got stuck. The app from Tianjin D-powercore does use different commands than your Fliteboard (I guess its a custom made version) and the app from Fliteboard does not work without account. I think I know the BT characteristics that are relevant, but ideally I'm now looking for an emulation or documentation of the commands and responses.

patman15 avatar Sep 23 '24 20:09 patman15

Hi Patrick

Thanks so much for trying. The iOS developer said you could reach out to him and I have his email but don't want to post publicly. Is there a way I could send that to you privately in a private message?

He was able to communicate with the battery and get the data - so maybe all the work is already done?

Let me know

alros100 avatar Sep 23 '24 20:09 alros100

Is there a way I could send that to you privately in a private message?

You could DM me in the HA community or on Discord, would that work?

patman15 avatar Sep 24 '24 06:09 patman15

Thanks, I PM'd you on home assistant committee with the contact

Thanks again Al

alros100 avatar Sep 24 '24 11:09 alros100

@alros100 can you try the code on the branch? Note it is very alpha, only roughly tested and might contain some major flaws. I need to take a break from coding the next weeks, so not sure how far I can get still. EDIT: please do not forget to attach a debug log so I can verify that it works / has some flaws / ... Thanks!

patman15 avatar Sep 25 '24 12:09 patman15

Thank you so much. I will try it and post back. Please take all the time off you need - no pressure at all . I am very grateful that you are assisting!!

Al

alros100 avatar Sep 25 '24 13:09 alros100

Hi

Thanks so much for your assistance on this.

I uninstalled the original integration from hacs and I installed the branch manually as per the instruction and I confirmed that the updated files are present.

I have both the raspberry pi Bluetooth enabled as well as running the Bluetooth proxy on esp32. And I also tried with each separately

I can find and add the integration from the add integration list, but it instantly indicated that no compatible batteries are found and is not added to my configured integration list.I tried searching for logs but I could not find anything. I also ran the integration with the Bluetooth proxy log running and did not see any attempts at a search or any changes.

Because the integration is not added, I can enable debug protocol. Does the integration log to a other specific area? I just want to confirm that it's trying to connect as the message of no compatible batteries comes up so instantly that I wonder if there is something wrong with with the installation rather than the new code ?

addendum:

the raspberry pi built in Bluetooth debug dump appears to see the battery "name": "TBA-13500448", "address": "B0:D2:78:19:59:36", "rssi": -81, "advertisement_data": [ "TBA-13500448",

Al

alros100 avatar Sep 26 '24 14:09 alros100

Can you check in the terminal: bluetoothctl info B0:D2:78:19:59:36 ?

You can enable debugging permanently (don't forget to turn it off when everything works ...) right at startup by adding the following to your configuration.yaml:

logger:
  default: info
  logs:
    custom_components.bms_ble: debug

Can you provide a Home Assistant log file?

patman15 avatar Sep 26 '24 15:09 patman15

Will Do ! Thank you Al

alros100 avatar Sep 26 '24 16:09 alros100

Hi Please see attached zip of what you requested. I am really confused. in terminal HA built in bluetooth seems to see the battery only randomly and bluetooth proxy ESP32 doesn't seem to see it HA Log.zip

not sure if its my home assistant Bluetooth that is the issue ?

Al

alros100 avatar Sep 28 '24 15:09 alros100

The log shows that the device characteristics are not resolved via Bluetooth, so the integration does not detect it as a valid device. My guess would be that you run into the 3 device limit of the BT Proxy, as I can see 2 Hue Lamps and a Bose speaker being resolved. It's definitely a BT issue, either add more BT proxies or due a static assignment of the BMS to one proxy so it is guaranteed to be connected. That would be by hint, hoping it is correct. Just checking, did you set active connections, see https://esphome.io/components/bluetooth_proxy.html#configuration to True on your proxy?

patman15 avatar Sep 29 '24 11:09 patman15

Hi

Thanks for you assistance and patience. Although I have bluetooth proxy running, I am only using the raspberry pi 4 built in bluetooth module. Also yes in the proxy I did have active enabled.

so I installed a new clean homeassistant on a spare raspberry pi 3 I had have. The only thing I put on it is bluetooth and the custom_component / bms_ble. The battery is sitting right next to the raspberry pi 3.

Now the bluetooth integration debug log and the terminal command bluetoothctl info B0:D2:78:19:59:36 consistently shows the battery. Not randomly like on my main homeassisstant.

the first time I tried to add the BMS ble integration there was a quick error message that I wish I had my phone to photo. it was something like a component caused an error (I looked in your strings file and it was not one of those messages). The second time I tried the integration there was no error message but it once again reported "no supported devices found via bluetooth"

logs attached, Logs.zip

thanks for your patience - no rush on this Al

alros100 avatar Sep 29 '24 20:09 alros100

The log does not mention the battery. There is still an issue with the BT setup.

  • did you try to pair the device? Use bluetoothctl pair <mac_address> from the terminal.
  • are you sure nothing else is connected to the BMS?

I'm still wondering via the device does not advertise any services, which is required for detection and operation.

patman15 avatar Sep 30 '24 17:09 patman15

Hi yes the main log doesn't show the battery, but the bluetooth integration download diagnostics - shows it . Yes I have the fliteboard app and the ios app from adreas that are able to connect to the battery and I am absolutely sure that both are not running on my phone and nothing is connected to the battery during these tests.

so I rebuild a brand new Home assistant on the pi 3. once again the info command shows the device, but the pair command attempts but doesnt appear to work see picture.

WI keep seeing that message n terminal "unable to open mgmt_socket" both on the old and new home assistant. Is this what is telling you that my bluetooth is not configured properly ? I wouold think the a brand new fresh install of HA should solve the issue unless the problem is the bluetooth chip on the Pi 3 and 4 .

since I have no other compatible connectable bluetooth devices compatible with home assistant. I ordered a new Pi 5 and a bluetooth thermometer on the HA compatible list to see if I can show that this connects and works. not sure how else to trouble shoot the bluetooth integration.

thanks so much for your patience - I'll report back in the next few days when I receive the new stuff.

terminal capture

Al

alros100 avatar Oct 01 '24 12:10 alros100

Hi Patman so I recieved the pi5 and set up a clean install of just bluetooth alone then added bluetooth proxy. in both cases bluetooth picks up and adds a known HA supported Govee bluetooth thermometer. also this thermometer is picked up by my full home assistant on a Pi4 as well as the Pi 3 clean install. So I am assuming bluetooth is working on these three devices. but I have had no luck with these batteries. bluetoothctl info with mac works as above but pair does not.

I continue to be able to connect and retrieve all the cell data using Djorn-Andreas' strom app and the fliteboard app . so is it that home assistant bluetooth does something upfront before the Patmon integration has a chance to find/connect to the battery ?

thanks for your patience Al

alros100 avatar Oct 02 '24 19:10 alros100

The message with the management socket doesn't tell me anything. I tried already previously to figure out under which conditions it occurs but did not succeed. Honestly, I'm running out of ideas why your device does not show up. Maybe you need to set the flite board into some pairing mode? Can you unpair it from your phone and try again? Just a random idea ... Did app just work out of the box? (No pairing needed) If yes to the latter my best guess is still an issue with the Bluetooth setup. The device must have services advertised in order to be able to detect and control it. For some strange reason it does not do so. 😞

patman15 avatar Oct 02 '24 19:10 patman15

I understand - this is super frustrating. No there is no pairing with either of the phone apps. But both apps immediately report the TBA battery. Before Andreas updated his app, the app immediately reported the battery but would not connect. After his update it connected and reported all the parameters.

I ran a verbose log of the ESPHome Bluetooth proxy and searched the log for the battery MAC address, but could not find it. The built in Pi Bluetooth at least seems to detect the battery name.

By the way, I had originally tried the Batmon bms integration. That one "sees" the battery but fails to connect using the included protocols as they don't have a em3ev BMS protocol. I reached out to you as that project seems to be inactive.

Hey I appreciate all the time you have spent and I understand if you can't devote anymore time to this.

My motivation for this was to simply create a home assistant charge to 60% automation for battery storage. The flite app and their incredibly overpriced charger has a fixed nearly full charge algorithm only. It was getting to be a pain timing the charge or watching it reach 60% !

Greatly appreciate your efforts

Al

alros100 avatar Oct 02 '24 20:10 alros100

I won't give up until I totally run out of ideas, or have figured out the problem. So no worries, the initial implementation took most of the time, so I want to make use of it. 😄 Batmon uses the same Bluetooth methods as my integration, but it assumes after the configuration that a compatible device is reachable via the MAC address you specify. I assume it fails connecting because the characteristics are not resolved. That would be the same reason why my integration doesn't even show it in the first place ... Do you have logs from Batmon you could share to validate that hypothesis? Do you have an Android phone where you could run nRF connect to check the Bluetooth properties and send a log /screenshot? Also just to check: which way did you choose to install Homeassistant? Are using the ready-made images for RPi? Or something different? Could you try the first, of not already done? I would need to play around a bit with the bluetoothctl and similar commands to get more information about the device, but currently I have no infrastructure at hand. Will take a few weeks till I can go deeper. Best regards, Patrick

patman15 avatar Oct 02 '24 22:10 patman15

Thanks so much Patrick ! i am responding now but please take the time you need !

nrf connect has ios version. It connects to the battery and I have the logs, I also included the logs before and after Bjorn-Andreas fixed the strom app. He also seemed very open to reconnecting if needed.

I will re-install Batmon and get some logs.

Also do you suggest any relatively cheap supported BMS that is known to work with the integration I could purchase to test ? or is the raspberry pi platform a potential problem for bluetooth ? should i try another home assistant platform

thanks ! Al

Logs.zip

alros100 avatar Oct 02 '24 22:10 alros100

here are the Batmon Logs when trying battery as JK or JBD JK Batmon Log.txt JBD Batmon log.txt

alros100 avatar Oct 02 '24 23:10 alros100

OMG ! so after uninstalling batmon, I just wanted to make sure everything was back to normal so I tested the terminal bluetooth commands and it all of sudden showed the TBA battery and attributes. So manually re-copied patman to the custom component and restarted it found the battery and connected and let me add the details into an entity card.

I have no idea way it worked now but you must be right it is some bluetooth issue that seems to have self corrected ??

amazing!

Terminal shows attributes HA success

Al

alros100 avatar Oct 02 '24 23:10 alros100

update. The connection to battery 1 is robust. I can reboot home assistant and it reconnects. I updated the core and it reconnected. The battery bms is activated with a magnet. I deactivated and activated the battery multiple times and it immediately connects. it is working perfectly.

now the weird part. Battery two is behaving like before. I can't add it and it won't connect. in terminal it shows as before without showing the TBA name or the extra attributes as from the screen grab above. so strange that one battery has a completely robust connection while the other one is behaving like the currently connected battery before it connected.

maybe this behaviour can point to the challenges with initial connection. Is it something with my bluetooth ? Al

alros100 avatar Oct 03 '24 01:10 alros100

I have no idea way it worked now but you must be right it is some bluetooth issue that seems to have self corrected ??

  • did you still have Batmon running? If yes -> that was the issue
  • Which method did you use to install Home Assistant? If you used core and copied Batmon in parallel then there is definitely a conflict. Especially if you chose to update the Bleak library (Batmon does use sometimes a special version) which is the core Bluetooth library. That could cause incompatibilities to Home Assistant.
  • For the 2nd battery not working I would guess you run into the 3 device limit of the ESPproxy, if you are using it. Check die logs of the proxy!

patman15 avatar Oct 03 '24 10:10 patman15