diy solar

diy solar

Monitoring Bluetti Systems

I tried to install that on an Intel NUC native Installation of HA and get the following error message when I try to test the script from the command line.

[core-ssh shell]$ chmod +x install start bluetti mqtt.sh
[core-ssh shell]$ .//install start bluetti matt.sh
.//install start bluetti mqtt.sh: line 2: pip: command not found
nohup: appending output to nohup.out

2 Questions.

1. Is that a limitation of HAOS that it cannot run/test the script with the "pip install bluetti_mqtt" via command line but that would work during a reboot ?
2. does the id in the first line of the automation.yaml have to match the device-id or ist it just an id which have to be unique within the automation.yaml ?
Thanks

UPDATE:
Just configured everything as described in the post and restarted HA and it works immediately !!!!!
Now I don't need the Raspberry PI and can use it for something else.
Everything of the Bluetti_MQTT Installation runs on the Intel NUC.
Great Job, THANKS !!!!

Unfortunately it only worked for a short time, after some time none of the values gets updated anymore.
Where can I find an info what could have caused the freeze ?
 
Big thanks for your short guide, it works for my AC200Max. But a question, how you get the Estimated Energy Production Today in your Dashboard ? i am new in home assistant and with the bluetti-mqtt integration i only get the total battery, dc in/out, ac in/out and the two switches .. thanks for your help :)
Hi Cernu,

you have to edit mqtt_client.py and add following lines within async def _handle_message(self, client: Client, msg: ParserMessage):

if 'power_generation' in msg.parsed:
await client.publish(
topic_prefix + 'power_generation',
payload=str(msg.parsed['power_generation']).encode()
)

@chromedshark - maybe/please can you add this in your git repository
 
Hi Cernu,

you have to edit mqtt_client.py and add following lines within async def _handle_message(self, client: Client, msg: ParserMessage):

if 'power_generation' in msg.parsed:
await client.publish(
topic_prefix + 'power_generation',
payload=str(msg.parsed['power_generation']).encode()
)

@chromedshark - maybe/please can you add this in your git repository
Thanks for that, if i add the lines in the py the service doesnt starts anymore. maybe it is not possible for the ac200max and generate an error ?
Update : My failure, i missed one character, now the service starts :) But i dont find the new entity in home assistant.. i reconfigure the mqqt integration but all the same ... any idea ?
 
Last edited:
Really appreciate getting all this started @chromedshark and others!

For anyone looking for a super simple way to integrate into HA OS (Home Assistant Operating System), here's the cleanest, lowest code route I've found:

Find your device ID: I did this by getting into the HA OS host, then Docker instance, then manually installing bluetti_mqtt (pip install bluetti_mqtt) and running the --scan command (there's likely an easier way to do this).

Setup MQTT (if you haven't yet): Follow directions here - https://www.home-assistant.io/docs/mqtt/broker/ (including user/password combo)

Create script/shell_command integration: I created a new directory in /config/ called "shell" and placed a new script called install_start_bluetti_mqtt.sh in it. Inside that script (replace USERNAME, PASSWORD, DEVICE_ID with yours):

#!/bin/bash pip install bluetti_mqtt nohup bash -c "bluetti-mqtt --broker 127.0.0.1 --username USERNAME --password PASSWORD DEVICE_ID &"
Once that's in there, add this to the root of your configuration.yaml:

shell_command: install_start_bluetti: bash /config/shell/install_start_bluetti_mqtt.sh
Setup automation: Super simple automation that trigger's on HA start (can create with the GUI in Settings>Automations>Create Automation):
Note: the "id" value here has no connection to the DEVICE_ID, it's auto-generated by HA when creating a new automation

- id: '1665937079543' alias: Install and start bluetti-mqtt on HA start description: '' trigger: - platform: homeassistant event: start condition: [] action: - service: shell_command.install_start_bluetti data: {} mode: single
-

Have this up and running for my WIP AC300+2xB300+2xPV350 build - running HA OS 9 on a Raspberry Pi 3. Obviously a temp solution, but working well for now! Going to dig into HA OS 9+ BT support and see if I can help further a native HA integration.
Let me get this correct... You're runing HA OS and you were able to install the bluetti-mqtt service inside of HA? Can you create multiple instances? As I have four units to track?

This would be great, as I'm currently running it on a Raspberry PI instance.
 
Hey guys,

So today I fired up the AC500's and I've begun taking logs for @chromedshark... I assume this is the type of data needed:
{"type": "client", "time": "2022-10-25 17:56:12 -0600", "data": "AQOMAAAAAAAAAAAAAAAAAAAAAAAAAABBQzUwMAAAAAAAAAAD/HCzJMcCCAAAAAAAACu0AAYsGAAGAAAAAMumAA0AAAAAAAAAAAAAAAACRAAAAAAAAAALAAAANQAAAAEAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC1/Q==", "command": "AQMAAABGxDg="}

Can someone explain the data field? What encoding is this? I assume it's the topic?
 
Unfortunately it only worked for a short time, after some time none of the values gets updated anymore.
Where can I find an info what could have caused the freeze ?
I believe my hacky shell_command solution with nohup sends logs into the ether with HA OS unfortunately :(. Looking into how to send those somewhere easily reachable.

In the meantime, you could setup another automation that triggers on a schedule? Similar to how lgb-this did with systemd: https://diysolarforum.com/threads/monitoring-bluetti-systems.37870/post-611819 — guessing there's a few different ways it can break (broken BT connection, AC200/300 auto shut-off/power cycle, bluetti-mqtt crash, etc.)

Let me get this correct... You're runing HA OS and you were able to install the bluetti-mqtt service inside of HA? Can you create multiple instances? As I have four units to track?

This would be great, as I'm currently running it on a Raspberry PI instance.
Yup! As I mentioned, it's a very hacky/temp solution and doesn't "natively" integrate with HA OS, but it has held up for my setup over the past week or so. Hoping to get some time soon to help out @chromedshark with the HA integration (https://github.com/warhammerkid/bluetti_ha).

I don't have multiple AC/EP* instances to test, but based on the Entity ID and a quick look at the bluetti-mqtt source code, it should be possible? Should be straightforward to test by adding additional commands with each Device ID to the bash (.sh) script.
 
Last edited:
I believe my hacky shell_command solution with nohup sends logs into the ether with HA OS unfortunately :(. Looking into how to send those somewhere easily reachable.
Huh, looking at the Home Assistant add-on system, it probably wouldn't be that difficult to build a configurable add-on that runs bluetti-mqtt as a service, so you'd get logs, configurability, and automatic restarting. It's not anywhere close to what a native "integration" can provide, but that's significantly more effort. If I have time this weekend I might put up a simple add-on repo.

Can you create multiple instances? As I have four units to track?
I still strongly recommend tracking multiple units with one "instance". It's easier, and should provide better bluetooth polling performance as well. You can list as many devices as you want to track:
Code:
bluetti-mqtt --broker 192.168.0.0 00:11:22:33:44:55 00:11:22:33:44:66 00:11:22:33:44:77 00:11:22:33:44:88

I recently purchased an EB3A just so I could verify that this was working correctly (and also to properly reverse all the new functionality it has), and I've run it this way in testing for 12+ hours with no issues, although feel free to reach out if you run into trouble.
 
I still strongly recommend tracking multiple units with one "instance". It's easier, and should provide better bluetooth polling performance as well. You can list as many devices as you want to track:
Code:
bluetti-mqtt --broker 192.168.0.0 00:11:22:33:44:55 00:11:22:33:44:66 00:11:22:33:44:77 00:11:22:33:44:88

I'll have to try this.. the only reason I setup two separate service files for each Bluetti units is sometimes the bluetti-mqtt service doesn't connect to one and I have to restart the connection to that one unit.

But let me see if I have any issues with this being one service for both of my units.
 
I signed up to say thank you for the code and discussion. It works great and it adds so much to the functionality of the AC300. The phone app leaves a lot to be desired.

I set it up on a NUC and it ran flawlessly for a few days and now I've moved it over to a low power pi. So far I haven't had a dropped connection or any hiccups at all.

I had issues installing it but was able to use the post history here to install the bleak dependency.

I'm hoping it will run unattended for a few years.

Screenshot 2022-10-31 at 18.21.49.png

sag
 
I signed up to say thank you for the code and discussion. It works great and it adds so much to the functionality of the AC300. The phone app leaves a lot to be desired.

I set it up on a NUC and it ran flawlessly for a few days and now I've moved it over to a low power pi. So far I haven't had a dropped connection or any hiccups at all.

I had issues installing it but was able to use the post history here to install the bleak dependency.

I'm hoping it will run unattended for a few years.

View attachment 118617

sag
How do i get this beautiful reports in HA ?
 
Hi rather I am interested in how I get the data as an entity to the energy panel because in my konfig is a 800W balcony power plant and I would like to have the 1600 watt solar panels that are attached to the Blutet including the battery in the energy display, who has already done something in this direction?

At the moment only the displays run in the panel looks nice I also like better than forever to look at the phone 1667292671124.png

1667292380988.png
 
Hi rather I am interested in how I get the data as an entity to the energy panel because in my konfig is a 800W balcony power plant and I would like to have the 1600 watt solar panels that are attached to the Blutet including the battery in the energy display, who has already done something in this direction?

At the moment only the displays run in the panel looks nice I also like better than forever to look at the phone
You have to convert the Power to Energy, then you can select it in the Energy Panel Config.
I added the following to the configuration.yaml of my HA, if you don't have a EP500Pro, then you have to change the source names to match what the Bluetti_MQTT creates for your Type.

#My Sensors:
sensor:
# EP500Pro Convert Power to Energy
- platform: integration
source: sensor.ep500p_dc_input_power
name: EP500Pro_PV_IN_Energy
unit_prefix: k
round: 2
- platform: integration
source: sensor.ep500p_ac_output_power
name: EP500Pro_AC_OUT_Energy
unit_prefix: k
round: 2
 
How do i get this beautiful reports in HA ?
It's a custom SVG grapher. I need to use bluetti-mqtt to post to an MQTT broker then another service/program to subscribe to the broker and post the data I want to a SQL database, and then a website that uses a hierarchical config file to browse select data in the database. The code is ugly though so it's not something I've ever shared.

I've never used HA so I'm not sure if you can export the data from there or if you can attach a custom grapher. The grapher just takes the data and generates SVG elements which browsers and other programs display. The SVG isn't great for interaction though. For example I'd like to be able to use the mouse to tell the site to calculate the area under the curve in a user specified box or get the slope of the line between two points but it's not able to do that on the website.
 
You have to convert the Power to Energy, then you can select it in the Energy Panel Config.
I added the following to the configuration.yaml of my HA, if you don't have a EP500Pro, then you have to change the source names to match what the Bluetti_MQTT creates for your Type.

#My Sensors:
sensor:
# EP500Pro Convert Power to Energy
- platform: integration
source: sensor.ep500p_dc_input_power
name: EP500Pro_PV_IN_Energy
unit_prefix: k
round: 2
- platform: integration
source: sensor.ep500p_ac_output_power
name: EP500Pro_AC_OUT_Energy
unit_prefix: k
round: 2
Hi MrGPS, thx for the Tipp I take your entries and changed the Sensors . My sensor names are for the PV Input sensor.ac300_dc_input_power and for the AC Output sensor.ac300_ac_output_power 1667310293997.png
In the Energy Board after restart I have the 2 entities in but no data comes from there

1667310566222.png
and in the Device> Enities are now 1667311417526.png

is this on your side the same orhave you assign a uniqueID ? Sry for the Questions im a beginner with HA
 
I also startet new with HA.
Hi MrGPS, thx for the Tipp I take your entries and changed the Sensors . My sensor names are for the PV Input sensor.ac300_dc_input_power and for the AC Output sensor.ac300_ac_output_power View attachment 118667
In the Energy Board after restart I have the 2 entities in but no data comes from there


and in the Device> Enities are now

is this on your side the same orhave you assign a uniqueID ? Sry for the Questions im a beginner with HA
I am also new to HA, it worked for me. The new sensors showed up in the main window and i added them manually to the Energy Tab.
I haven*t assigned any id.
But it could take some time to calculate the energy for the first time.
Do you see any updates at the origin sensor.ac300….. ?

BTW: you can change the name: … to anything you want, it does not have to be EP500Pro.
 
Since we're sharing, I too have been spending allot of time setting up dashboarding and automation to control my grid charging of my unit (if batteries drop lower then the defined SOC).

For my system I created the follow:
  1. HA Sensor to monitor the status of the Bluetti-MQTT service. If it fails to reconnect after 5 minutes I get an SMS alert.
  2. Battery monitoring of each battery:
    • Automatically enable a specific T500 to directly charge that battery if it falls below the SOC low defined on the Bluetti unit.
    • Automatically disable the T500 when the battery reaches the defined SOC high defined on the Bluetti unit.
  3. Monitoring of 16 battery cells for bad cells, represented by the 16 green squares under each battery.
  4. Automation to automatically fall back to the grid if the AC Output fails for x period of time.
  5. Maintenance Mode toggle to allow batteries to automatically drop and charge to 100% for all batteries before returning to normal charging mode.
  6. Toggle that allows charging from the grid during peak hours or not.

1667344734086.png

Love sharing the ideas!... I too plan to add my solar, which is still being installed, to my "Engery Dashboard" in HA.
 
Last edited:
You have to convert the Power to Energy, then you can select it in the Energy Panel Config.
I added the following to the configuration.yaml of my HA, if you don't have a EP500Pro, then you have to change the source names to match what the Bluetti_MQTT creates for your Type.

#My Sensors:
sensor:
# EP500Pro Convert Power to Energy
- platform: integration
source: sensor.ep500p_dc_input_power
name: EP500Pro_PV_IN_Energy
unit_prefix: k
round: 2
- platform: integration
source: sensor.ep500p_ac_output_power
name: EP500Pro_AC_OUT_Energy
unit_prefix: k
round: 2

How does this work? Does it convert the original sensor to KWH?

UPDATE:
I answered my own question after looking it up:
sensor:
- platform: integration
unique_id: ac300_a_total_dc_input_power
source: sensor.ac300_dc_input_power_2
name: "AC300-A TOTAL DC INPUT POWER"
unit_prefix: k
unit_time: h


@chekey you need to add "unique_id" to anything you add for the front UI to be able to interact with it.
 
Last edited:
Fantastic job ! I operate a Bluetti AC200MAX and i monitor the device with a Raspberry Pi 3 and this software. I run bluetti-mqtt as a service in systemd with the
I also have the AC200Max and a setup with bluetti-mqtt, Mosquitto, Telegraf and Grafana which just works fine. Only current downside is: As long as the Raspberry is connected via Bluetooth, I can' connect with the Bluetti app to turn AC on/off as the Bluetti can only be connected to one device at a time.

Any hints how to approach that?
 
How does this work? Does it convert the original sensor to KWH?

UPDATE:
I answered my own question after looking it up:
sensor:
- platform: integration
unique_id: ac300_a_total_dc_input_power
source: sensor.ac300_dc_input_power_2
name: "AC300-A TOTAL DC INPUT POWER"
unit_prefix: k
unit_time: h


@chekey you need to add "unique_id" to anything you add for the front UI to be able to interact with it.
Thanks for the info, it was working for me without unique_id and it is optional according to the user manual, but to be on the safe side I also added a unique_id.
 
I also have the AC200Max and a setup with bluetti-mqtt, Mosquitto, Telegraf and Grafana which just works fine. Only current downside is: As long as the Raspberry is connected via Bluetooth, I can' connect with the Bluetti app to turn AC on/off as the Bluetti can only be connected to one device at a time.

Any hints how to approach that?
I think that this is a limit how Bluetti implemented the Bluetooth conversation.
I am running the MQTT Server in home assistant and that makes it possible to turn the Powerstation outputs on/off via the Home Assistant App or WebGui or e.g. it is possible to automatically turn AC-Output off if battery is below 10% and turn it on again if it is above 50%.
Tip: According to the Home Assistant Website it is also possible to run Grafana inside HA and use the same database as HA.
 
I am running the MQTT Server in home assistant and that makes it possible to turn the Powerstation outputs on/off via the Home Assistant App or WebGui or e.g. it is possible to automatically turn AC-Output off if battery is below 10% and turn it on again if it is above 50%.
Tip: According to the Home Assistant Website it is also possible to run Grafana inside HA and use the same database as HA.
Thanks, but doesn't it mean that the Bluetti AC can be turned on via an MQTT command? If yes it should be possible to do that also without Homeassistant!?
 
Thanks, but doesn't it mean that the Bluetti AC can be turned on via an MQTT command? If yes it should be possible to do that also without Homeassistant!?
It is not bound to HA, i am using HA since i already had it running. The bluetti_mqtt software described here collects the data and sends it to an mqtt server. you can decide on which platform you run this server.
 
Hi,
I don't have a running HA system, so I connected the BLUETTI-MQTT to my IOBROKER MQTT Instance. I can see all the status in my IOBROKER objects but I can't change values from my IOBROKER. I like to switch on / off DC power and also AC power, but I don't know how.

I don't see e.g.

bluetti/command/DEVICE_ID/ac_output_on - supports setting to ON or OFF

in my MQTT server. No "command" folder.

Okay got it. Defined those topics with Node-Red and now it works

Greetings

Bernd

PS: I own a AC500+2xB300S system
 
Last edited:
As far as I can tell only DC1 details are available over bluetooth. In theory there might be some way to switch it from reporting DC1 to DC2 to get both, but I haven't been able to figure out how to do that.
Hello together,
as we get "DC_INPUT_POWER" (both inputs together) and DC1 input ("INTERNAL_DC_INPUT_POWER") separately it should be correct to calculate the value for DC2 :)

I'm using https://github.com/mariolukas/Bluetti_ESP32_Bridge and have implemented it like that in PayloadParser.cpp:

Code:
...
int16_t last_solar_sum=(-1);
int16_t last_solar_dc1=(-1);
...

        if(bluetti_device_state[i].f_name == DC_INPUT_POWER) last_solar_sum=parse_uint_field(data_payload_field);
        if(bluetti_device_state[i].f_name == INTERNAL_DC_INPUT_POWER) last_solar_dc1=parse_uint_field(data_payload_field);     
        if( (bluetti_device_state[i].f_name == DC_INPUT_POWER) || (bluetti_device_state[i].f_name == INTERNAL_DC_INPUT_POWER) )
        {
          if( (last_solar_sum >= last_solar_dc1) && (last_solar_sum >= 0) && (last_solar_dc1 >= 0) ) publishTopic(CALC_DC2_INPUT_POWER, String(last_solar_sum - last_solar_dc1));
        }
...

Seems to work very well.

Greetings,
Martin
 
Hello together,
as we get "DC_INPUT_POWER" (both inputs together) and DC1 input ("INTERNAL_DC_INPUT_POWER") separately it should be correct to calculate the value for DC2 :)

I'm using https://github.com/mariolukas/Bluetti_ESP32_Bridge and have implemented it like that in PayloadParser.cpp:

Code:
...
int16_t last_solar_sum=(-1);
int16_t last_solar_dc1=(-1);
...

        if(bluetti_device_state[i].f_name == DC_INPUT_POWER) last_solar_sum=parse_uint_field(data_payload_field);
        if(bluetti_device_state[i].f_name == INTERNAL_DC_INPUT_POWER) last_solar_dc1=parse_uint_field(data_payload_field);    
        if( (bluetti_device_state[i].f_name == DC_INPUT_POWER) || (bluetti_device_state[i].f_name == INTERNAL_DC_INPUT_POWER) )
        {
          if( (last_solar_sum >= last_solar_dc1) && (last_solar_sum >= 0) && (last_solar_dc1 >= 0) ) publishTopic(CALC_DC2_INPUT_POWER, String(last_solar_sum - last_solar_dc1));
        }
...

Seems to work very well.

Greetings,
Martin
This "works" only to some extent. The DC total and DC Input 1 might not update at the same time and will give a slight inaccurate reading on wattage during that time. Also this doesn't allow for the amp/volts to be identified for DC2, which is very important for PV.
 
Hi,
found this site digging the internet in search for "bluetti monitoring". Hi anyone :cool:
I'm totally new to this MQTT and Home Automation stuff, so please forgive me my maybe dumb questions...

What I did so far:
- Bought an AC200M (Location: basement)
- Bought a Bananapi, installed Armbian (Location: basement). Is talking bluetooth to the Bluetti and is reachable via Wifi from my PC (Linux) in the livingroom
- Installed bluetti-mqtt on the Bananapi. Finds the Bluetti:
Code:
root@bananapi:~# bluetti-mqtt --scan

Scanning....

Found AC200Mwhatsoever: address 00:11:22:33:44:55

But if I try to connect, I end up with
 
Last edited:
Code:
root@bananapi:~# bluetti-mqtt --broker 127.0.0.1 --username banana --password banana 00:11:22:22:44:55
2023-01-09 07:44:56 INFO     Connecting to MQTT broker...
2023-01-09 07:44:56 INFO     Starting to poll clients...
2023-01-09 07:44:56 INFO     Connecting to clients: ['00:11:22:33:44:55']
2023-01-09 07:44:56 ERROR    MQTT error:
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/bluetti_mqtt/mqtt_client.py", line 447, in run
    async with Client(
  File "/usr/local/lib/python3.11/dist-packages/asyncio_mqtt/client.py", line 822, in __aenter__
    await self.connect()
  File "/usr/local/lib/python3.11/dist-packages/asyncio_mqtt/client.py", line 390, in connect
    raise MqttError(str(error)) from None
asyncio_mqtt.error.MqttError: [Errno 111] Connection refused
2023-01-09 07:44:58 ERROR    Error connecting to device 00:11:22:22:44:55:
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/bluetti_mqtt/bluetooth/client.py", line 40, in run
    await self.client.connect()
  File "/usr/local/lib/python3.11/dist-packages/bleak/__init__.py", line 471, in connect
    return await self._backend.connect(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/bleak/backends/bluezdbus/client.py", line 190, in connect
    assert_reply(reply)
  File "/usr/local/lib/python3.11/dist-packages/bleak/backends/bluezdbus/utils.py", line 20, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] le-connection-abort-by-local
2023-01-09 07:44:59 INFO     Retrying connection to 00:11:22:22:44:55
2023-01-09 07:45:00 ERROR    Error connecting to device 00:11:22:22:44:55:
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/bluetti_mqtt/bluetooth/client.py", line 40, in run
    await self.client.connect()
  File "/usr/local/lib/python3.11/dist-packages/bleak/__init__.py", line 471, in connect
    return await self._backend.connect(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/bleak/backends/bluezdbus/client.py", line 190, in connect
    assert_reply(reply)
  File "/usr/local/lib/python3.11/dist-packages/bleak/backends/bluezdbus/utils.py", line 20, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] le-connection-abort-by-local

What am I doing wrong?
Thanks in advance

Edit: Doing this without user/pass doesn´t change anything...
 
Code:
root@bananapi:~# bluetti-mqtt --broker 127.0.0.1 --username banana --password banana 00:11:22:22:44:55
2023-01-09 07:44:56 INFO     Connecting to MQTT broker...
2023-01-09 07:44:56 INFO     Starting to poll clients...
2023-01-09 07:44:56 INFO     Connecting to clients: ['00:11:22:33:44:55']
2023-01-09 07:44:56 ERROR    MQTT error:
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/bluetti_mqtt/mqtt_client.py", line 447, in run
    async with Client(
  File "/usr/local/lib/python3.11/dist-packages/asyncio_mqtt/client.py", line 822, in __aenter__
    await self.connect()
  File "/usr/local/lib/python3.11/dist-packages/asyncio_mqtt/client.py", line 390, in connect
    raise MqttError(str(error)) from None
asyncio_mqtt.error.MqttError: [Errno 111] Connection refused
2023-01-09 07:44:58 ERROR    Error connecting to device 00:11:22:22:44:55:
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/bluetti_mqtt/bluetooth/client.py", line 40, in run
    await self.client.connect()
  File "/usr/local/lib/python3.11/dist-packages/bleak/__init__.py", line 471, in connect
    return await self._backend.connect(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/bleak/backends/bluezdbus/client.py", line 190, in connect
    assert_reply(reply)
  File "/usr/local/lib/python3.11/dist-packages/bleak/backends/bluezdbus/utils.py", line 20, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] le-connection-abort-by-local
2023-01-09 07:44:59 INFO     Retrying connection to 00:11:22:22:44:55
2023-01-09 07:45:00 ERROR    Error connecting to device 00:11:22:22:44:55:
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/bluetti_mqtt/bluetooth/client.py", line 40, in run
    await self.client.connect()
  File "/usr/local/lib/python3.11/dist-packages/bleak/__init__.py", line 471, in connect
    return await self._backend.connect(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/bleak/backends/bluezdbus/client.py", line 190, in connect
    assert_reply(reply)
  File "/usr/local/lib/python3.11/dist-packages/bleak/backends/bluezdbus/utils.py", line 20, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] le-connection-abort-by-local

What am I doing wrong?
Thanks in advance

Edit: Doing this without user/pass doesn´t change anything...
*bump*

really no one?
 
Hi,
found this site digging the internet in search for "bluetti monitoring". Hi anyone :cool:
I'm totally new to this MQTT and Home Automation stuff, so please forgive me my maybe dumb questions...

What I did so far:
- Bought an AC200M (Location: basement)
- Bought a Bananapi, installed Armbian (Location: basement). Is talking bluetooth to the Bluetti and is reachable via Wifi from my PC (Linux) in the livingroom
- Installed bluetti-mqtt on the Bananapi. Finds the Bluetti:
Code:
root@bananapi:~# bluetti-mqtt --scan

Scanning....

Found AC200Mwhatsoever: address 00:11:22:33:44:55

But if I try to connect, I end up with

So it looks like there are two errors here:
1. The first error is that it cannot connect to an MQTT broker. You must install an MQTT broker like Mosquitto separately (or use the MQTT broker integration for Home Assistant if you want to go that route). By default they won't have a username or password.
2. The second error appears to be a connection error. The good old "turn it off and back on" advice some times fixes these kinds of things - turn off bluetooth on your AC200M and then turn it back on again.
 
Hi @chromedshark,

thanks for help, you brought me in the right direction. My wrong assumption was, that bluetti-mqtt itself is a MQTT broker, silly me...
So I just installed mosquitto on the bananapi, found a better position for it to join bluetooth and, tada:

Code:
root@bananapi:~# bluetti-mqtt --broker 127.0.0.1 00:11:22:33:44:55
2023-01-17 16:58:46 INFO     Connecting to MQTT broker...
2023-01-17 16:58:46 INFO     Starting to poll clients...
2023-01-17 16:58:46 INFO     Connecting to clients: ['00:11:22:33:44:55']
2023-01-17 16:58:46 INFO     Connected to MQTT broker
2023-01-17 16:58:46 INFO     Sent discovery message of AC200M-xxxxxxxxxxx to Home Assistant
2023-01-17 16:58:46 WARNING  filtered_messages() is deprecated and will be removed in a future version. Use messages() together with Topic.matches() instead.
2023-01-17 16:58:46 INFO     Connected to device: 00:11:22:33:44:55

My home assistant on my working PC is not finding the MQTT broker on the bananapi, maybe a (hidden) setting on mosquitto...

Again, thanks so far

Ha, got it:
Code:
listener 1883 0.0.0.0
allow_anonymous true
in the mosquitto.conf (y)
 
Last edited:
Hi to all,
I finally made it to install the bluetti to mqtt on my HA (running as a VM on a Synology NAS). All good, Bluetooth integrated, Bluetti AC500 connected, data is coming in (at least I can see the information in the protocol), bute there is no entity created which I can use. Any Ideas where to look? Regards Tapo
 
Hi to all,
I finally made it to install the bluetti to mqtt on my HA (running as a VM on a Synology NAS). All good, Bluetooth integrated, Bluetti AC500 connected, data is coming in (at least I can see the information in the protocol), bute there is no entity created which I can use. Any Ideas where to look? Regards Tapo
You have to install the MQTT addon at the HA. Did you do that ?
And create a user/pw for the service and use that when starting the bluetti_mqtt.
The Bluetti_Mqtt Service does not directly talk to HA, It sends its data to an mqtt server and HA automatically detects that and then integrates the entities.
 
Last edited:
You have to install the MQTT addon at the HA. Did you do that ?
And create a user/pw for the service and use that when starting the bluetti_mqtt.
The Bluetti_Mqtt Service does not directly talk to HA, It sends its data to an mqtt server and HA automatically detects that and then integrates the entities.
Hi, Thanks a lot. I did and linked it to the Mosquito MQTT Broker. Now the entity has been created and data is coming in. !Perfect! :) - Would be super helpful for each noob like me - to have these steps or prerequisites listed somewhere. Final question now - how to modify/add the DC charging Watt to KwH - to make it available for the batterie gauge within the energy dashboard - Where do I have to make this change? Regards Tapo
 
Hi, Thanks a lot. I did and linked it to the Mosquito MQTT Broker. Now the entity has been created and data is coming in. !Perfect! :) - Would be super helpful for each noob like me - to have these steps or prerequisites listed somewhere. Final question now - how to modify/add the DC charging Watt to KwH - to make it available for the batterie gauge within the energy dashboard - Where do I have to make this change? Regards Tapo
Discussion and solution is on the previous page ;)
 
here you can find a description for HA and HACS in German
I tested it with the AC300 and it works perfectly


here the GitHub- link

from Readme:
"This add-on was created as an easy method to get Bluetti data into Home Assistant, without having to setup [bluetti_mqtt](https://github.com/warhammerkid/bluetti_mqtt) on a separate device."
 
Last edited:
I had the bluetetti_mqtt running on my Raspi for e few months without any problems.
But since my HomeAssistant runs on an Intel Mini PC (Beelink S) i testet now the HACS integration.
But unfortunately it stops somewhere between a few minutes and a few hours.
I testet the none HACS integration before on another hardware (Beeline Pro 4) and had the same problem, so at least the cause could not be a defective hardware.
The Mini PC and the Raspi are located on the Top of my EP500Pro, so the Bluetooth connection should be very good.
I tried also to move the Mini PC 2m away from my Bluetti because I thought it might be too close. But still same problem.
Any idea how to pinpoint the problem ? I turned debug on and attached is the bluetti_mktt HA integration log:
 

Attachments

  • Debug-Log 20230228.txt
    6.1 KB · Views: 4
@MrGPS
Since I'm currently reassembling my Home Assistant, I've only tested it briefly and unfortunately can't say anything about a longer runtime.
I will test this over a longer period of time and then report back here.
 
Back
Top