Official Bluetti Device API Survey

Ohhh That is good news . I am stuck with the matter . I am now trying to get something out of Esphome BLE tracker/client . This machine is stubborn , to the max…My question is ; Protecing from what/who ??? BLE devices will not mantain an stable connection from more than 6-8 mts away …and that is not even the distance to your backyard. I find this really , … crazy ? . Greetings and hope your tip becomes reallity. I my case , from 4 Phones/ablets I got at home , onlt 1 “sometimes” connects with the app… I have no easy control of basic settings I would like to change on a daily basis … like AC charging regime … Oh My … Annoying

1 Like

After some digging and trying I found a way to fully integrate a elite 200 v2 into home assistant. Nearly all controls are integrated (thx to desalvo for creating the fork and integrating the necessary code). It’s basically putting together the things from different users.
The approach is a bit hacky but doable (thx to toeachbyeach for the approach,

  1. Download this github repo to your desktop: GitHub - jesherman/bluetti2mqtt: Home Assistant Add-on for bluetti_mqtt
    You only need the content of the folder bluetti2mqtt
  2. Now modify three files in the folder (build.yaml, config.yaml and dockerfile) as follows:
    A. dockerfile:
ARG BUILD_FROM
FROM $BUILD_FROM

# Copy data for add-on new 1
COPY rootfs /

# Install system dependencies using apk (Alpine package manager)
# Note: build-base is the Alpine equivalent of build-essential
# Note: openssl-dev is the Alpine equivalent of libssl-dev
# Note: Removing bluez version pin initially - add back if needed and available
RUN apk add --no-cache --force-overwrite \
    openssl=3.5.2-r0 \
    openssl-dev=3.5.2-r0 \
    libcrypto3=3.5.2-r0 \
    libssl3=3.5.2-r0

RUN apk add --no-cache \
    git \
    build-base \
    python3-dev \
    libffi-dev \
    cargo \
    bluez

# Install pip dependencies FIRST with explicit versions
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir \
	aiomqtt==2.1.0 \
        bleak==0.22.3 \
        crcmod==1.7 \
        cryptography==44.0.0 \
        dbus-next==0.2.3 \
        pyasn1==0.6.1 \
        pyserial==3.5 \
        prometheus_client==0.20.0

RUN pip install --no-cache-dir --no-deps git+https://github.com/desalvo/bluetti_mqtt.git@v2devices

# Set permissions for run script
RUN chmod a+x /run.sh

RUN sed -i 's/sys.exit(main())/sys.exit(main(sys.argv))/' /usr/local/bin/bluetti-mqtt

# Optional: Clean apk cache if needed, though --no-cache minimizes it
# RUN rm -rf /var/cache/apk/*

CMD [ "/run.sh" ]

B. config.yaml:

Commented out the “image:” line; changed version and deleted irrelevant archs for good measure.

arch:
  - amd64
#image: ghcr.io/jesherman/{arch}-addon-bluetti2mqtt
host_dbus: true

C. build.yaml

bumped version of base python, deleted irrelevant archs.

---
build_from:
  amd64: ghcr.io/hassio-addons/base-python/amd64:17.0.0

Afterwards install the SMB Addon in Home Assistant and access the share via your computer.
Now copy the prepared bluetti2mqtt folder from earlier into the addons folder on the Home Assistant SMB share.
Restart Home Assistant. Next go to addons and click on add-on store. If everything worked as planned you should see “Local add-ons” directly at the top and there the bluetti2mqtt add-on. Install it. Now you should be able to discover your elite 200 v2 with the scan feature of the add-on (see protocol to get the details). Afterwards enter the Mac address which is listed in protocol in configuration of the add-on.
If everything worked as planned there should be a new MQTT device:

3 Likes

Hi everyone,

I’m about to be a proudly and happy (hope so!) owner of a Elite 200 V2. Good for me! :joy:

I just answered the survey for the API development - hope we get it soon.

I have a Hubitat Elevation hub and I’d like to integrate my future device to it.

BTW, has somebody any information about a possible Matter support? It would be a breeze to integrate to my hub and, being so, it would be not necessary to develop an integration/driver myself … :smiling_face_with_tear:

Any Hubitat user around?

1 Like

Thank you very much .Will give it a try . My HA runs on an x86 mini Pc without self Bluetooth support. I am thinking of using the ESp32 bluetooth proxy for that … Will se how it goes. Greetings , Alles Gute.

Filled in the Survey. I had a few esp32 with screens and planned to run the Bluetooth MQTT for the esp32. To then strip away the MQTT to instead display the information on the esp32 screen as a control panel in my Mhome. Only to discover that after trying the code on my new purchase of the Elite100. The data looks encrypted. I hope there will be a stand alone away from the internet esp32 once off API that can be imbedded into the esp32. I understand the security issue of the open BLE. But it would have been nice to have read only basic plain data.

1 Like

I use Hubitat for my whole smart home system, I’d love to see Bluetti integration for my Apex 300.

1 Like

Would be awesome if Bluetti had an API that could be used for integration with Hubitat. I could get so much additional functionality out of my Apex 300.

1 Like

Since the last home assistant update I got a disconnect after 4 minutes and only hardware reset seemed to solve this. Turns out I had to update the dependencies in run.sh and rebuild the addon in HA. If you change run.sh like this it works again like a charm:

ARG BUILD_FROM
FROM $BUILD_FROM

Copy data for add-on

COPY rootfs /

Remove hard-pinned openssl packages from world file

RUN sed -i ‘/libcrypto3=/d’ /etc/apk/world &&
sed -i ‘/libssl3=/d’ /etc/apk/world &&
sed -i ‘/openssl=/d’ /etc/apk/world

Full system upgrade

RUN apk upgrade --no-cache --available

Install system dependencies

RUN apk add --no-cache
openssl-dev
git
build-base
python3-dev
libffi-dev
cargo
bluez

Install pip dependencies FIRST with explicit versions

RUN pip install --no-cache-dir --upgrade pip &&
pip install --no-cache-dir
aiomqtt==2.1.0
bleak==0.22.3
crcmod==1.7
cryptography==44.0.0
dbus-next==0.2.3
pyasn1==0.6.1
pyserial==3.5
prometheus_client==0.20.0

RUN pip install --no-cache-dir --no-deps git+https://github.com/desalvo/bluetti_mqtt.git@v2devices

Set permissions for run script

RUN chmod a+x /run.sh
RUN sed -i ‘s/sys.exit(main())/sys.exit(main(sys.argv))/’ /usr/local/bin/bluetti-mqtt

CMD [ “/run.sh” ]

Please open a Github Issue on the Repo mainsite for this. We arent able to help with unofficial Software

Hubitat just released support for Bluetooth (BLE) - but only for the C-8 Pro hub.

Install the Bluetooth integration (beta) app and it will (hopefully) install Bluetooth devices.

I haven’t tried it yet but let’s hope that it works with Bluetti devices.

UPDATE

Bad news … just tried to connect my Elite 30 to Hubitat … no success.
Hubitat documentation says something about BTHomeV2 but it seems that it’s only for sensors (https://bthome.io).

:cry:

In the meantime, I have completely decoded the CAN protocol of the EP760.
This is quite different from the CAN protocol of the AC300 and introduces new very interesting features.
.
This model, in particular, not only exposes 31 cell indexes per pack which is singular, but also includes some interesting status bits in the CAN packets that are set and unset during charge and discharge for single cells like the BMS is actively balancing (in the screenshot of my engine I represented them as red and blue bars on the cell voltage levels).
.
Also worth of note is the SoH calculation (100%), average internal resistance calculation (35 mOhmAh) and 8 temperature sensors for each B500 battery.
VpC is not exposed in the protocol but I calculate it RT from cell V levels, this is always kept very low by the balancing system on voltage excursions from about 5 to 100% which is also great to improve pack lifetime.
.
As always, there is a lot to learn from these systems. :slight_smile:
.

1 Like

WTF, this is like Christmas, New Year’s, and Easter all at once ;-)
.
This has me really curious now. I don’t have an EP760, but I do have two EP600s, and they use the exact same B500 batteries. So I’m guessing that, aside from the EP600’s inverter (3-phase instead of 1-phase), the CAN protocol should be the same.
.
Reading the relevant values directly from the CAN bus sounds much more stable and interesting than fiddling around with that unstable Bluetooth.
What hardware are you using to read the CAN bus, and what software is converting the protocol for you? Your picture suggests you’re using “homemade” software, possibly written in C++?
.
The labeling in your picture seems to indicate a “home-field advantage” and is quite difficult for me to read…

My setup is overly-complicated because I always personally like to receive data to user-level before parsing to make reverse engineering easier.
.
CAN H/L → opto-isolation → MCP 2551 → MCP 2515 → SPI to an ATMega328 → UART → STM32 hardware to ethernet → C collector and parser → C opengl engine
.
The middle-man ATMega328 is RT single threaded receiving by SPI and relaying to UART without talking back so to avoid any unnecessary interference to the bus. For the moment I read-only.
.
C software is part of my company prop. resources but I’ll plan to simplify it by using a single transceiver+microcontroller; in fact everything can be done with a single MCU like the PBOX is actually doing by using an ESP32 wroom.
.
In my case CAN bus is very busy, with x4 B500 I detect 9 IDs talking almost simultaneously and payloads are split between packets so received data must be re-ordered and filled in a timeframe before parsing. Bluetti hardware exclusively talks CAN by MCUs so that is very fast and efficient, the PBOX is almost only buffering CAN data so it doesn’t actively participate as a software bottleneck which is good.
.
From a technical standpoint this is basically automotive high-reliability hardware.