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.
 
Back
Top