diy solar

diy solar

Monitoring Bluetti Systems

@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.
FYI:
i had the same problem when I tried to manually integrate it into HA as described in Post #73 from superslide.
So it has nothing to do with the HACS integration.
Sometimes I have to power off the Mini PC to get the bluetooth working again, so I guess the problem is more likely a bluetooth driver problem.
Therefore I enabled Bluetooth Debugging in the configuration.yaml:
### Bluetooth Debug Log ####
logger:
logs:
homeassistant.components.bluetooth: debug

And then I connected via SSH to HA and after entering "bluetoothctl" the debug output runs continuously and I am waiting for the problem to occur:

CHG] Device 70:2A:D5:80:E8:82 ManufacturerData Key: 0x0075
[EP500P2214000153651]#
[CHG] Device 70:2A:D5:80:E8:82 ManufacturerData Value:
[EP500P2214000153651]#
42 04 01 01 6f 70 2a d5 80 e8 82 72 2a d5 80 e8 B...op*....r*...
[EP500P2214000153651]#
81 28 00 00 00 00 00 00 .(......
[EP500P2214000153651]#
[CHG] Device C2:A8:04:45:39:A1 RSSI: -63
[EP500P2214000153651]#
[CHG] Device 65:31:75:C2:A0:E0 RSSI: -62
[EP500P2214000153651]#
[CHG] Device 42:3D:05:29:F9:BE RSSI: -61
[EP500P2214000153651]#
[CHG] Device 2B:61:0B:3E:01:73 RSSI: -75
[EP500P2214000153651]#
[CHG] Device 4F:5F:D4:F5:80:41 RSSI: -70
[EP500P2214000153651]#
[CHG] Device 48:D3:8B:E0:24:64 RSSI: -72
[EP500P2214000153651]#
[CHG] Device 32:B9:46:0C:1B:06 RSSI: -65
........................
 
@chromedshark
Its running fine now for a couple of weeks, thanks again.
But total power generation always says 0 kWh...

Can you help me out?
thx
Just guessing: It might be that not every Bluetti device has this counter implemented. Do you see this summary since the first start in the official app ? (Usually at the bottom of the detail display)
 
Just guessing: It might be that not every Bluetti device has this counter implemented. Do you see this summary since the first start in the official app ? (Usually at the bottom of the detail display)
AFAIK and remember, the app does not show this value. Thanks for the hint.
 
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: 16
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?
 
Back
Top