Skip to main content

MQTT interface to Bluetti power stations

Project description

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 some 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.

Supported sensors and switches:

  • AC input power sensor (W)

  • DC input power sensor (W)

  • AC output power sensor (W)

  • DC output power sensor (W)

  • Total battery percent

  • AC output switch

  • DC output switch

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.

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

bluetti_mqtt-0.9.2.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bluetti_mqtt-0.9.2-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

Details for the file bluetti_mqtt-0.9.2.tar.gz.

File metadata

  • Download URL: bluetti_mqtt-0.9.2.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for bluetti_mqtt-0.9.2.tar.gz
Algorithm Hash digest
SHA256 9c369cf88d3effd1b188c68c27a553b7bc51fa73ca88322bb299751d88012ed7
MD5 1fbcddc6c775d52cdd5a40a3f5b9f5af
BLAKE2b-256 899f9cd483fc6286fd3eebd33d8b5d90a62f9c23240135679f94d3701d9bc430

See more details on using hashes here.

File details

Details for the file bluetti_mqtt-0.9.2-py3-none-any.whl.

File metadata

  • Download URL: bluetti_mqtt-0.9.2-py3-none-any.whl
  • Upload date:
  • Size: 26.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for bluetti_mqtt-0.9.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4fa6e54b88672ce13de127601c0d0fea98086f1caec0ab977c7ca7e2ba194d23
MD5 45b19c5c7605926434f8a4b5a1486833
BLAKE2b-256 245d23acc8aea7b10b44c4798db217dc7740001d4e51102a1318cbe04c566686

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page