MQTT interface to Bluetti power stations
Project description
This is fork of original repository, with added support for Bluetti AC180P
This tool provides an MQTT interface to Bluetti power stations. State will be published to the bluetti/state/[DEVICE NAME]/[PROPERTY] topic, and commands can be sent to the bluetti/command/[DEVICE NAME]/[PROPERTY] topic.
Installation
$ pip install bluetti_mqtt
Usage
$ bluetti-mqtt --scan
Found AC3001234567890123: address 00:11:22:33:44:55
$ bluetti-mqtt --broker [MQTT_BROKER_HOST] 00:11:22:33:44:55
If your MQTT broker has a username and password, you can pass those in.
$ bluetti-mqtt --broker [MQTT_BROKER_HOST] --username username --password pass 00:11:22:33:44:55
By default the device is polled as quickly as possible, but if you’d like to collect less data, the polling interval can be adjusted.
# Poll every 60s
$ bluetti-mqtt --broker [MQTT_BROKER_HOST] --interval 60 00:11:22:33:44:55
If you have multiple devices within bluetooth range, you can monitor all of them with just a single command. We can only talk to one device at a time, so you may notice some irregularity in the collected data, especially if you have not set an interval.
$ bluetti-mqtt --broker [MQTT_BROKER_HOST] 00:11:22:33:44:55 00:11:22:33:44:66
Background Service
If you are running on a platform with systemd, you can use the following as a template. It should be placed in /etc/systemd/system/bluetti-mqtt.service. Once you’ve written the file, you’ll need to run sudo systemctl start bluetti-mqtt. If you want it to run automatically after rebooting, you’ll also need to run sudo systemctl enable bluetti-mqtt.
[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 [MQTT_BROKER_HOST] 00:11:22:33:44:55
[Install]
WantedBy=multi-user.target
Home Assistant Integration
If you have configured Home Assistant to use the same MQTT broker, then by default most data and switches will be automatically configured there. This is possible thanks to Home Assistant’s support for automatic MQTT discovery, which is enabled by default with the discovery prefix of homeassistant.
This can be controlled with the --ha-config flag, which defaults to configuring most fields (“normal”). Home Assistant MQTT discovery can also be disabled, or additional internal device fields can be configured with the “advanced” option.
Reverse Engineering
For research purposes you can also use the bluetti-logger command to poll the device and log in a standardised format.
$ bluetti-logger --log the-log-file.log 00:11:22:33:44:55
While the logger is running, change settings on the device and take note of the time when you made the change, waiting ~ 1 minute between changes. Note that not every setting that can be changed on the device can be changed over bluetooth.
If you’re looking to add support to control something that the app can change but cannot be changed directly from the device screen, both iOS and Android support collecting bluetooth logs from running apps. Additionally, with the correct hardware Wireshark can be used to collect logs. With these logs and a report of what commands were sent at what times, this data can be used to reverse engineer support.
For supporting new devices, the bluetti-discovery command is provided. It will scan from 0 to 12500 assuming MODBUS-over-Bluetooth. This will take a while and requires that the scanned device be in close Bluetooth range for optimal performance.
$ bluetti-discovery --scan
Found AC3001234567890123: address 00:11:22:33:44:55
$ bluetti-discovery --log the-log-file.log 00:11:22:33:44:55
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file bluetti_mqtt_asyncio-0.16.4.tar.gz
.
File metadata
- Download URL: bluetti_mqtt_asyncio-0.16.4.tar.gz
- Upload date:
- Size: 23.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39cef44fa423429997f5bea66c9e6b7c2b078406da8818ff16be536ee593fcde |
|
MD5 | e8a7fef137a0e9a2b5e96ec43474fe55 |
|
BLAKE2b-256 | e4abb481e302f81939a3347bce1c5e2fd34ca26a066802e51b149f1af081a32c |
File details
Details for the file bluetti_mqtt_asyncio-0.16.4-py3-none-any.whl
.
File metadata
- Download URL: bluetti_mqtt_asyncio-0.16.4-py3-none-any.whl
- Upload date:
- Size: 34.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e820ef52af14d3861a7bba094e294c216d81899a59679f68711177f44a2a68d6 |
|
MD5 | 70405510f111667260de6782add348be |
|
BLAKE2b-256 | 72a33732705e3184889466e1d3f5db21a7edde1f90bf68a60b2cdd60d6c48b9b |