diy solar

diy solar

Monitoring Bluetti Systems

Hello everyone, I need your help. I can't get the connection to Bluetti-MQTT in. Broker is installed and running. Another client is also installed, the data points are also created there, but the values are empty because the connection to Bluetti-MQTT does not work.

I installed it according to these instructions on a Raspi 3b: https://github.com/warhammerkid/bluetti_mqtt

In addition, I had to install Phyton, which I did with the command sudo apt-get install python python3 python-pip python3-pip.

This is what is in my conf file:
Description=Bluetti MQTT
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=30
TimeoutStopSec=15
User=pi
ExecStart=/usr/local/bin/bluetti-mqtt --broker **** --username **** --password *****+ --interval 60 ******

[Install]
WantedBy=multi-user.target

This is my error message
Connecting to ****
Waiting for connection...
ERROR:root:Reconnecting to ***** after error:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/bluetti_mqtt/bluetooth/client.py", line 50, in run
await self.client.start_notify(
File "/usr/local/lib/python3.9/dist-packages/bleak/__init__.py", line 639, in start_notify
raise BleakError(f"Characteristic {char_specifier} not found!")
bleak.exc.BleakError: Characteristic 0000ff01-0000-1000-8000-00805f9b34fb not found!
ERROR:root:Error connecting to device 04:7F:0E:AD:84:D6:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/bluetti_mqtt/bluetooth/client.py", line 40, in run
await self.client.connect()
File "/usr/local/lib/python3.9/dist-packages/bleak/__init__.py", line 471, in connect
return await self._backend.connect(**kwargs)
File "/usr/local/lib/python3.9/dist-packages/bleak/backends/bluezdbus/client.py", line 190, in connect
assert_reply(reply)
File "/usr/local/lib/python3.9/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] Operation already in progress
ERROR:root:Error connecting to device ******

Screenshot Iobroker:
BluettiMQTT-Iobroker.png

Anyone an idea?
 
Hello everyone, I need your help. I can't get the connection to Bluetti-MQTT in. Broker is installed and running. Another client is also installed, the data points are also created there, but the values are empty because the connection to Bluetti-MQTT does not work.

I installed it according to these instructions on a Raspi 3b: https://github.com/warhammerkid/bluetti_mqtt

In addition, I had to install Phyton, which I did with the command sudo apt-get install python python3 python-pip python3-pip.

This is what is in my conf file:


This is my error message


Screenshot Iobroker:
View attachment 138992

Anyone an idea?
I had to install "bleak" as well on the raspberry PI. Additional to Python and Bluetti_mqtt.
See Post #49
 
Thanks for the hint. I just put it on a fresh buster, installed python, python-pip, bleak. Connection to MQTT-Broker is fine?, after reboot I got correct messages, the datapoints still are empty and this message occure a few minutes later:

Connecting to ******
Waiting for connection...
{'device_type': 'AC200M', 'serial_number': *****, 'arm_version': Decimal('4008.03'), 'dsp_version': Decimal('4005.07'), 'dc_input_power': 0, 'ac_input_power': 0, 'ac_output_power': 0, 'dc_output_power': 0, 'power_generation': Decimal('0'), 'total_battery_percent': 91, 'ac_output_on': True, 'dc_output_on': False}
{'ac_output_mode': <OutputMode.INVERTER_OUTPUT: 1>, 'internal_ac_voltage': 230, 'internal_current_one': Decimal('0'), 'internal_power_one': 0, 'internal_ac_frequency': Decimal('50'), 'internal_dc_input_voltage': 0, 'internal_dc_input_power': Decimal('0'), 'internal_dc_input_current': Decimal('0')}
{'pack_num': 2, 'ac_output_on': True, 'dc_output_on': False, 'power_off': False, 'auto_sleep_mode': <AutoSleepMode.FIVE_MINUTES: 4>}
{'pack_num_max': 3, 'pack_num': 1, 'pack_voltage': Decimal('53.1'), 'pack_battery_percent': 91, 'cell_voltages': [Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31')]}
{'pack_num_max': 3, 'pack_num': 2, 'pack_voltage': Decimal('0'), 'pack_battery_percent': 0, 'cell_voltages': [Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0')]}
{'pack_num_max': 3, 'pack_num': 3, 'pack_voltage': Decimal('0'), 'pack_battery_percent': 0, 'cell_voltages': [Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0'), Decimal('0')]}
{'device_type': 'AC200M', 'serial_number': ********, 'arm_version': Decimal('4008.03'), 'dsp_version': Decimal('4005.07'), 'dc_input_power': 0, 'ac_input_power': 0, 'ac_output_power': 0, 'dc_output_power': 0, 'power_generation': Decimal('0'), 'total_battery_percent': 91, 'ac_output_on': True, 'dc_output_on': False}
{'ac_output_mode': <OutputMode.INVERTER_OUTPUT: 1>, 'internal_ac_voltage': 230, 'internal_current_one': Decimal('0'), 'internal_power_one': 0, 'internal_ac_frequency': Decimal('50'), 'internal_dc_input_voltage': 0, 'internal_dc_input_power': Decimal('0'), 'internal_dc_input_current': Decimal('0')}
{'pack_num': 3, 'ac_output_on': True, 'dc_output_on': False, 'power_off': False, 'auto_sleep_mode': <AutoSleepMode.FIVE_MINUTES: 4>}
{'pack_num_max': 3, 'pack_num': 1, 'pack_voltage': Decimal('53.1'), 'pack_battery_percent': 91, 'cell_voltages': [Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31'), Decimal('3.31')]}
ERROR:root:Delayed reconnect to ********* after error:
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.9/site-packages/bluetti_mqtt/bluetooth/client.py", line 53, in run
await self._perform_commands(self.client)
File "/home/pi/.local/lib/python3.9/site-packages/bluetti_mqtt/bluetooth/client.py", line 112, in _perform_commands
raise err
bluetti_mqtt.bluetooth.exc.BadConnectionError: too many retries
Got an error running command QueryRangeCommand(page=0x00, offset=0x5b, length=0x77): too many retries
Got an error running command UpdateFieldCommand(page=0x0b, offset=0xbe, value=0x03): [org.bluez.Error.Failed] Not connected
 
@janne16
By default, mqtt-broker is just listening for local connected clients. Which broker did you install, mosquitto?
If your client is on a remote machine, don´t forget this in mosquitto.conf

Code:
listener 1883 0.0.0.0
allow_anonymous true

HTH
 
yes, I installed Mosquitto and installed it on the same client as bluetti-mqtt and made these entries in the conf file
listener 1883
allow_anonymous false
password_file /etc/mosquitto/mosquitto_passwords


The broker, is connected to iobroker and data points are created as shown in the screenshot above. However, there are no values in the data points.

I assume that the problem must be with this script (I posted above): bluetti-mqtt.service
 
As far as I can see, the bluetooth connection to the AC200M is not working. Do you have the Bluetti app running on another device in range?
AC200M (and the others too, afaik) only allow *one* bluetooth connection session.

The script itself is running fine here (same Bluetti)

Does
Code:
$ bluetti-mqtt --scan
show your device?

HTH
 
No, there isn't. But now I switched IP from 192.xxx to 127.0.0.1 and my bluetti is connected but there is another error

2023-03-14 17:59:32 INFO Connecting to MQTT broker...
2023-03-14 17:59:32 INFO Starting to poll clients...
2023-03-14 17:59:32 INFO Connecting to clients: ['******']
2023-03-14 17:59:33 INFO Connected to MQTT broker
2023-03-14 17:59:33 INFO Sent discovery message of AC200M-******** to Home Assistant
2023-03-14 17:59:33 WARNING filtered_messages() is deprecated and will be removed in a future version. Use messages() together with Topic.matches() instead.
2023-03-14 17:59:33 INFO Connected to device: *********
2023-03-14 17:59:33 ERROR Reconnecting to ******* after error:
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.9/site-packages/bluetti_mqtt/bluetooth/client.py", line 50, in run
await self.client.start_notify(
File "/usr/local/lib/python3.9/dist-packages/bleak/__init__.py", line 639, in start_notify
raise BleakError(f"Characteristic {char_specifier} not found!")
bleak.exc.BleakError: Characteristic 0000ff01-0000-1000-8000-00805f9b34fb not found!
 
***solved***

Fresh raspberry image
sudo apt update && sudo apt full-upgrade && sudo apt install python3 idle3 && sudo apt install pip
sudo apt install mosquitto && sudo nano /etc/mosquitto/conf.d/custom.conf
Paste into file and save
listener 1883
allow_anonymous false
password_file /etc/mosquitto/mosquitto_passwords
Secure MQTT broker with password
sudo mosquitto_passwd /etc/mosquitto/mosquitto_passwords yourusername
Follow the installation instructions for bluetti-mqtt and adapt the file.

Check result with MQTT Explorer: http://mqtt-explorer.com/
 
Thanks for bluetti-mqtt. I recently got myself a bluetti and was wondering how I was gonna monitor it and/or even run scripts etc on low battery.
I do not really require realtime consistent stats. So for what its worth ill share my use case.
I changed the interval to every 15 seconds.
I also don't really care much for having it integrated into homeassistant but I do want to graph for longer periods for stats.
So initially I wanted to hack it to try and send to influxdb then thought not to bother I already run Telegraf/InfluxDB/Grafana stack so I used a Telegraf input mqtt_consumer to poll mqtt every 15 seconds then push the results into InfluxDB and then slapped a quick dashboard around this that I can now use to send alerts and execute stuff using webhooks. This is my result.

bluetti-grafana-dash.PNG
 
Thanks to chromedshark for his amazing script - its running smooth since few months on my raspberry pie together with a remote MQTT broker!!
 
Last edited:
Hey Guys,

maybe someone can help me. I install the bluetti-mqtt and I got an error-message. Thanks a lot
 

Attachments

  • Terminal.png
    Terminal.png
    71.9 KB · Views: 19
Hey Guys,

maybe someone can help me. I install the bluetti-mqtt and I got an error-message. Thanks a lot
Hi, it seems you have no MQTT Broker installed, did you watch the video from the previous page ????
 
Linux instructions can be... complicated, but assuming that you're using a modern Raspberry Pi distro, you should be able to use systemd.

You'll want to take the following and write it to a file called /etc/systemd/system/bluetti-mqtt.service, after first modifying the User=your_username_here and adjusting the ExecStart line with the correct config.

Code:
[Unit]
Description=Bluetti MQTT
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=30
TimeoutStopSec=15
User=your_username_here
ExecStart=/home/your_username_here/.local/bin/bluetti-mqtt [MQTT_BROKER_HOST] 00:11:22:33:44:55

[Install]
WantedBy=multi-user.target

Once you've done that, you can run sudo systemctl start bluetti-mqtt to start the service (as well as stop or restart). To configure the service to start automatically at boot, you'll need to run sudo systemctl enable bluetti-mqtt.
Just after some help with this one please, Im trying to run the following automatically at startup, but Im doing something wrong with the code, obviously Im using my real details: - Also, if I run the details in the exec start line in terminal it works, but looking for a way to automate it on boot.

Code:
[Unit]
Description=Bluetti MQTT
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=30
TimeoutStopSec=15
User=your_username_here
ExecStart=/home/your_username_here/.local/bin/bluetti-mqtt --broker IP ADDRESS --port PORT —username USERNAME --password PASSWORD --interval 2 00:11:22:33:44:55

[Install]
WantedBy=multi-user.target
 
Thanks for bluetti-mqtt. I recently got myself a bluetti and was wondering how I was gonna monitor it and/or even run scripts etc on low battery.
I do not really require realtime consistent stats. So for what its worth ill share my use case.
I changed the interval to every 15 seconds.
I also don't really care much for having it integrated into homeassistant but I do want to graph for longer periods for stats.
So initially I wanted to hack it to try and send to influxdb then thought not to bother I already run Telegraf/InfluxDB/Grafana stack so I used a Telegraf input mqtt_consumer to poll mqtt every 15 seconds then push the results into InfluxDB and then slapped a quick dashboard around this that I can now use to send alerts and execute stuff using webhooks. This is my result.

View attachment 143793
Thanks for bluetti-mqtt. I recently got myself a bluetti and was wondering how I was gonna monitor it and/or even run scripts etc on low battery.
I do not really require realtime consistent stats. So for what its worth ill share my use case.
I changed the interval to every 15 seconds.
I also don't really care much for having it integrated into homeassistant but I do want to graph for longer periods for stats.
So initially I wanted to hack it to try and send to influxdb then thought not to bother I already run Telegraf/InfluxDB/Grafana stack so I used a Telegraf input mqtt_consumer to poll mqtt every 15 seconds then push the results into InfluxDB and then slapped a quick dashboard around this that I can now use to send alerts and execute stuff using webhooks. This is my result.

View attachment 143793
Hi @vodor - I love your dashboard! I am trying a similar thing with telegraph, influxdb and grafana. I think I have telegraf config'd and working but I don't have much experience with influxdb. Can you share how you setup your buckets and measurements in influxdb? Thanks so much!
 
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.

View attachment 116612
So is there anyway to have this running without the need to reinstall bluetti_Mqtt after each reboot?
 
Has anyone looked at doing an Openhab integration?
I now have this working in Openhab 4.0.1. I am using an RPi4 as my Openhab server. I installed Mosquitto on this server. I installed the Bluetti-MQTT package with PIP and followed all the other instructions to configure it. I installed MQTT Broker on this server and a remote server both pointing to the Mosquitto server. My Bluetooth is on the remote RPI 3 with an external BT dongle, as the internal BT was not strong enough to reach my Bluetti AC300. I also installed the Jinja Transformation addon. I searched for new Things using the HomeAssistant MQTT component. It immediately found my Bluetti AC300. I used MQTT Explorer to verify that all the data was coming in as configured. Setup the channels I wanted to see, and everything is working great. Thank you all for the work on this. The documentation is great, and it made it easy to install and configure.

1691786037465.png
 
Hello all,

I have recently bought a second hand AC300 with two B300. And came across this threat. So I also wanted to connect my AC300 to Home Assistant.

I don't like the fact that when I want to control the AC300 by wifi, it first go's unencrypted to Singapore and back. So I installed Python on macbook air running windows 10. And installed the bleutti-mqtt package through pip. All went well.

The only problem I did face was that when I want to try to start the service, the program exited on a error that match was a none type in bluethoot\__int__.py line 28.
So did some digging in the code (I not a python programmer, but can read it well) and this is what I figured out:

The name string in "def build_device(address: str, name: str):" contains the the device name that contains of model and serial number. Only there are 3 characters at the end of this string that care blank. I print the name string to the console with:
print('#' + name + '#')
And the console gives me:
#AC300123456789012345 #
And this is going to conflict with
DEVICE_NAME_RE = re.compile(r'^(AC200M|AC300|AC500|AC60|EP500P|EP500|EP600|EB3A)(\d+)$')

So what I did to make it work on my laptop is to trim the last 3 characters of the string. Only this is not a good fix in my opinion.
my fix isname = name[:-3]
My question is, where are the extra characters coming from?

When I run
bluetti-mqtt --scann
it is giving me the device name without the extra characters.
 
I recently bought a Bluetti AC180. I use a Hubitat (with homeasssitasnt bridge driver) and recently installed Homeassistant on a PI. I have mqtt-broker and bluetti_mqtt running on a Ubuntu 22.04 system.

Initially the bluetti-mqtt would get a fatal exception on startup. I managed to hack a work around for that by copying the ep600.py file to ac180.py and some modifications to load the ac180.py. This at least got to a point where it would send data too homeassistant.

I get two sensors
Battery percentage which is accurate with what I see on the AC180 front panel.
Total power generation with is always zero.

Two numbers Battery range start and end. I do not know what that is supposed to be.

So for now I can at least charge the AC180 when there is excess solar power and when the AC180's battery runs low, controlled via the rule machine in Hubitat. The AC180 for now powers a small aquaponics setup.

So I am looking for ideas on how to further modify the ac180.py to add functionality. I do have a bluetti-logger output but I am not sure that it is telling me.

And the AC180 only allows one device to connect at a time. So if bluetti-logger is running the APP wont connect, and visa versa. That sound like the norm for Bluetti.

Thanks for any advice.
 
Hello all,
maybe you can help me.
I control and monitor a Bluetti AC200MAX via the Home Assistant.
Unfortunately it does not work without problems, from time to time the Home Assistant loses the connection to the AC200MAX.
It also happens rarely that the ADD-ON "Bluetti to MQTT" is not started when booting from the Raspi. But this is not the main problem.

I have set the query interval to 10 seconds, but it is not really better.
When I get no connection at all, I have to restart the HA completely, then the connection is there again.

I don't know where else I can set something.

The Raspi is on the powerbox, so the Bluetooth range should not be a problem.

Technical data.
Home Assistant 2023.8.4 Supervisor 2023.08.1 Operating System 10.5 Frontend 20230802.1 - latest

Rasbeery Pi3 rpi3-64

attached the log file

thank you....
 

Attachments

  • AC200MAX.log.txt
    19.3 KB · Views: 7
  • HA Log.txt
    3.7 KB · Views: 3
Last edited:
Hello all,
maybe you can help me.
I control and monitor a Bluetti AC200MAX via the Home Assistant.
Unfortunately it does not work without problems, from time to time the Home Assistant loses the connection to the AC200MAX.
It also happens rarely that the ADD-ON "Bluetti to MQTT" is not started when booting from the Raspi. But this is not the main problem.

I have set the query interval to 10 seconds, but it is not really better.
When I get no connection at all, I have to restart the HA completely, then the connection is there again.

I don't know where else I can set something.

The Raspi is on the powerbox, so the Bluetooth range should not be a problem.

Technical data.
Home Assistant 2023.8.4 Supervisor 2023.08.1 Operating System 10.5 Frontend 20230802.1 - latest

Rasbeery Pi3 rpi3-64

attached the log file

thank you....

Problem fixed, has taken care of itself.
 
Hi - Having a little trouble connecting Bluetti_MQTT to an AC500.

I have managed installed Bluetti_MQTT and run a scan and tried to connect and tried to run the logger. Errors are indicating a failure to determine the device name, more specifically the code is looking for the characteristic UUID 00002a00-0000-1000-8000-00805f9b34fb which is supposed to determine the device name. This doesn't appear to be a characteristic published by the AC500. I was able to connect to the logger by cloning the git repository and changing the device name UUID to the serial string characteristic of 00002a24-0000-1000-8000-00805f9b34fb. This allowed this characteristic to be found (As it is a published one) and the logger to connect via bluetooth and return data. However there are a lot of dependencies on returning the actual device name when you run the mqtt service. I tried playing around with the code to change this name requirement but to no avail. Has anyone else run into this problem with the AC500 and got it to work?
 
I managed to connect by bypassing the 'name = await self.client.read_gatt_char(self.DEVICE_NAME_UUID)' and name decode. Entered in my device name into the client.py script. At least it is working for now.

I noticed I'm only getting 1 dc_input detail (ie. Total DC input plus one of the mppt controllers). Anyone had any luck in connecting to the second MPPT controller to get the data?
 

diy solar

diy solar
Back
Top