diy solar

diy solar

Monitoring Bluetti Systems

Thanks for doing this - I'm going to start playing with this - my end goal is putting this information into Home Assistant - would love it if I could figure out how to get this running on a esp32 w/ ESPHome
 
Good work/info! I am also interested in this and eventually integrating an EcoFlow Delta Pro into either HA or SmartThings. I have both. I gave WireShark a try a few days ago to capture some wifi packets off my AP which the Ecoflow is connected to and watched the comm between the EF app on my phone to the DP. The first test was just to see if I could capture so did not dive into decoding to much.

From googling around I understand that if you ask EF support for access to their server api they will send you token to do so. I did find some Python code for another EF model but according to what I read googling around is that EF Support changed up the api and broke the code. It looks like they also use MQTT to communicate. Anyway, I suspect that eventually they will actually publish the api and allow customers to do their own thing.

I did ask EF support if there was a browser based url/page I could access to view/manage the EF but they said not as of now. I suspect this will be coming in the near future also.
 
Last edited:
@chromedshark
nice work.
do you plan a HACS -Integration for home assistant?
I have the supervisor container version installed with the store access available. I have 4 different servers (RPI3, Linux, Win2012 Server, etc) running docker managed by Portainer. No going back to native OS installs if I can avoid it.

Update: I see now that HACS is a seperate install from the supervisor add-on store. I sure wish the UI was a little more simplfied and an all-in-one "install all" container/script provided.
 
Last edited:
Found what I was looking for. moving future talk on EF/HA integration to the software forum.

 
Very interesting work. As far as I could see this relies on the bluetooth connection. Is there a way to connect to e.g. the AC300 via Wifi?

Thanks
 
Oops, just realized I wasn't getting email notifications.

As far as I could see this relies on the bluetooth connection. Is there a way to connect to e.g. the AC300 via Wifi?
@NiklasG I currently have no plans to support wifi. I don't know of any way to connect to the AC300 directly over wifi (it's got open ports on it, but I don't know how to talk to them). The only way I know to control it over wifi is to have it connect to your network, change the DNS server you send it over DHCP to one you control and which publishes an A record to point iot.bluettipower.com to your own server. If you do all these things the communications protocol is nearly identical to the one over bluetooth. I have a working implementation in Ruby, but it's too difficult for a non-technical user to get set up at the moment, so I'm not really interested in supporting it. Is there a particular reason you'd rather control it over wifi?

do you plan a HACS -Integration for home assistant?
@Thanatos Maybe? I considered this when I was starting to write things, but I wasn't sure how many people actually want to place their home assistant server close enough to their Bluetti product to be in bluetooth range. Development has currently slowed because I kinda burned myself out on this spending most weekends working on it for 4 months.

if I can help with development in any way I'd love to!
@jonnycyborg I am definitely not a lawyer, but I have intentionally avoided decompiling any of the app source code because it's fairly clear that even if that act might be legal in some jurisdictions, using the results of the decompilation is much much less so. I'd really rather not set up an opportunity for Bluetti to sue me, and in the US at least, using Wireshark to collect packet traces and reverse engineering that way is legal. If you're interested in helping, providing bluetooth captures of the app talking to the EB3A and doing specific things would be super helpful.

LowerStatusPageParser has a different offset and length
@jonnycyborg Do you mean that the app polls at a different offset and length, or do you mean that when you send a
QueryRangeCommand(0x00, 0x00, 0x46) that you get an error from the EB3A? All the other devices I've seen start at 0x0A, but I didn't see much downside to collecting those extra bytes at the beginning (although I guess it's probably wasteful to poll them if I'm not going to use them).

MidStatusPageParser and ControlPageParser were returning unexpected results so temporarily had to remove from polling
@jonnycyborg Do you mean that they weren't working at all, or just that the data in them didn't look right after parsing? If they were working but had odd data I'd be curious if you can run the bluetti-logger command included in the python package and email/PM me the data. I'm currently not recommending people post full logs anywhere because I don't know whether the device serial numbers are private or not.

Due to the different app/firmware/protocol versions, it'll be quite the task to support all devices, but I hope we can take this info and start adding support for new devices like the EB3A.
I have logs from the EP500, AC300, and AC200M, so it shouldn't be that difficult. The current architecture is clearly not going to scale if I want to support every Bluetti device, but I have some ideas about how to restructure things to make that feasible.
 
@chromedshark
thank you very much for your wonderful work.
Since Bluetti does not offer a logging function, a simple integration via HACS would make a lot of sense.
Anyone who has an AC 300 and home assistant would certainly place both close to each other to connect via Bluetooth.
You put a lot of effort into developing this. With a HACS integration it would be available to all home assistant users and your hard work would be recognized and made available to many users.
For the problem with the low transmission range of Bluetooth, I could try to tinker something that sends the Bluetooth data with an ESP32 via WiFi.
 
Last edited:
I wasn't sure how many people actually want to place their home assistant server close enough to their Bluetti product to be in bluetooth range. Development has currently slowed because I kinda burned myself out on this spending most weekends working on it for 4 months.

@chromedshark - there are a lot of us that certainly appreciate your work

Would you consider a donation or similar page so we could support you ?

Re Home Assistant; perhaps even your own repo on the Add On store, similar to this
 
Last edited:
@chromedshark - Thankyou for pulling this together - very impressive!

While I couldn't follow how you backwards engineered the protocol I was able to get the code running and monitoring my AC200Max which arrived today :)

the values posted to mqtt make sense except for ac_output_mode - are you able to explain what you have defined in class OutputMode:
STOP = 0
INVERTER_OUTPUT = 1
BYPASS_OUTPUT_C = 2
BYPASS_OUTPUT_D = 3
LOAD_MATCHING = 4

STOP is obvious but the others??

Thankyou
 
the values posted to mqtt make sense except for ac_output_mode - are you able to explain what you have defined in class OutputMode
I'm fairly certain that only STOP and INVERTER_OUTPUT apply for the AC200M. The other 3 values have to do with how some of Bluetti's device can pass through AC power direct from the wall. There's a post on the official Bluetti forums detailing the other three modes.
 
Would you consider a donation or similar page so we could support you ?
I'd feel bad accepting money for something that I'm not providing any guarantees for. I'm working on this because I enjoy it, which sometimes means that I need to take a break to keep going.

Another developer submitted a patch to add Home Assistant auto-discovery, and based on my testing today it looks close to something I can release. Personally I spent my Sunday laying the groundwork for EB3A support, with the next thing on my mind being support for multiple attached battery packs. After that I'll have to see what's involved in doing an add-on build for Home Assistant (or maybe somebody will beat me to it).
 
I'm fairly certain that only STOP and INVERTER_OUTPUT apply for the AC200M. The other 3 values have to do with how some of Bluetti's device can pass through AC power direct from the wall. There's a post on the official Bluetti forums detailing the other three modes.
For my my unit I have seen at least 3 of the states in my testing:
  • STOP - ac and dc off
  • INVERTER_OUTPUT - running without the charger connected
  • BYPASS_OUTPUT_C - running with the charger when I first purchased the unit and testing out light loads from DC and AC

This aligns with the definitions in the post you linked!

Would love to see the definitions added to the class or maybe publish some custom attributes like charging, bypass, etc… just an idea… will raise an issue on git and go from there :)

BTW I noticed there are commands to turn AC/DC on and off but in the app we can turn the whole unit off. - did you happen figure out what to write to execute this function?

Thankyou!
 
great tool - due to Bluetti does not provide any logging function out of the box. Many thanks for your excellent work.
I've your tool running on a Raspberry Pi 3B and log the data via iobroker.

1.) My device is a AC300 with two B300 (Pack 2 and Pack 3) and I'm litte bit confused about the output of the tool. Let me shortly explain:

MidStatusPageParser(ac_output_mode=BYPASS_OUTPUT_D, internal_ac_voltage=226.7V, internal_current_one=0.1A, internal_power_one=23W, internal_ac_frequency=50Hz, internal_current_two=1.3A, internal_power_two=299W, ac_input_voltage=225.2V, internal_current_three=1.1A, internal_power_three=223W, ac_input_frequency=50Hz, dc_input_voltage=66.6V, dc_input_power=13W, dc_input_current=0.2, pack_num_max=4, pack_num=4, pack_battery_percent=21%, pack_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')])

App on my Mobile shows: Pack 2: 10% and Pack 3: 32% - total 21%
internal_power_two=299W - this value seems to be right
internal_power_tree=223W - this value must be totally wrong

2.) Also the pack_voltages are always 0

3.) the script sometimes randomly get a "Device disconnected" message and it seems to try to login again. But this seems to fail and
the script does not exit

DEBUG:root:Got a message from BluettiDevice(address='xx:xx:xx:xx:xx:xx', type='AC300', sn='xxx'): ControlPageParser(ups_mode=PV_PRIORITY, pack_num=1, ac_output_on=True, dc_output_on=False, grid_charge_on=False, time_control_on=True, battery_range_start=20%, battery_range_end=100%, auto_sleep_mode=ONE_MINUTE)
DEBUG:bleak.backends.bluezdbus.manager:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service000f/char0013): ['org.bluez.GattCharacteristic1', {'WriteAcquired': <dbus_next.signature.Variant ('b', True)>}, []]
DEBUG:bleak.backends.bluezdbus.client:Write Characteristic 0000ff02-0000-1000-8000-00805f9b34fb | /org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service000f/char0013: b'\x01\x03\x00\x00\x00F\xc48'
DEBUG:bleak.backends.bluezdbus.manager:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service000f/char0013): ['org.bluez.GattCharacteristic1', {'WriteAcquired': <dbus_next.signature.Variant ('b', False)>}, []]
DEBUG:bleak.backends.bluezdbus.manager:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx): ['org.bluez.Device1', {'ServicesResolved': <dbus_next.signature.Variant ('b', False)>, 'Connected': <dbus_next.signature.Variant ('b', False)>}, []]
DEBUG:bleak.backends.bluezdbus.client:Device disconnected (/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx)
DEBUG:bleak.backends.bluezdbus.client:_cleanup_all(/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx)
DEBUG:bleak.backends.bluezdbus.manager:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service000f/char0010): ['org.bluez.GattCharacteristic1', {'Notifying': <dbus_next.signature.Variant ('b', False)>}, []]
DEBUG:bleak.backends.bluezdbus.client:Disconnecting (/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx)
DEBUG:bleak.backends.bluezdbus.client:already disconnected (/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx)
DEBUG:bleak.backends.bluezdbus.client:Connecting to device @ xx:xx:xx:xx:xx:xx with hci0
DEBUG:bleak.backends.bluezdbus.manager:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx): ['org.bluez.Device1', {'Connected': <dbus_next.signature.Variant ('b', True)>}, []]
DEBUG:bleak.backends.bluezdbus.manager:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx): ['org.bluez.Device1', {'ServicesResolved': <dbus_next.signature.Variant ('b', True)>}, []]
DEBUG:bleak.backends.bluezdbus.manager:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service000f/char0010): ['org.bluez.GattCharacteristic1', {'Notifying': <dbus_next.signature.Variant ('b', True)>}, []]

4.) internal_power_one=65365W (example)
in the logfile, I can often see, that internal_power_one value is over 65000 - maybe this a negative values?
examples:
internal_power_one=814W,
internal_power_one=842W,
internal_power_one=65344W,
internal_power_one=65354W,
internal_power_one=65365W,
internal_power_one=65343W,
internal_power_one=65367W,
internal_power_one=1074W,
internal_power_one=809W,
internal_power_one=821W,
internal_power_one=65370W,
internal_power_one=65370W,
internal_power_one=65359W,
internal_power_one=65132W,

Please let me know if you need more details and/or a logfile from my device.

Many thanks!
René
 
Last edited:
Thanks for doing this - I'm going to start playing with this - my end goal is putting this information into Home Assistant - would love it if I could figure out how to get this running on a esp32 w/ ESPHome
Hello, everyone

At this point, many thanks again to the programmers of the bluetti-mqtt :giggle:. Is it currently possible to use the code from Github (bluetti-mqtt) with an ESP32? Or does someone know how to set it up?

Thank you for your help.
 
Is it currently possible to use the code from Github (bluetti-mqtt) with an ESP32? Or does someone know how to set it up?
My guess is that it’s not possible. Typically you’d need to use micro python with the ESP32, and there are a lot of things that wouldn’t work there (Bleak & asyncio, just to start). It’s possible the parsing code would run in micro python, but you’d likely need to rewrite everything else.
 
My device is a AC300 with two B300 (Pack 2 and Pack 3) and I'm litte bit confused about the output of the tool
Yeah, I’ve noticed that the ”internal” values I’m pulling sometimes make absolutely no sense, but they’re not always bad or I wouldn’t be bothering. Feel free to ignore them.

The battery voltages are always 0 because I haven’t yet written any code to page through each of the attached batteries. My goal is to do that next.
 
hello, i run the bluetti-mqtt on an raspberry pi ... is it poaaible to run this in backgruond or on startup an backgrount.
at this time the mqtt updates stop when i close the session
 
is it poaaible to run this in backgruond or on startup an backgrount
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.
 
Great work here! I just signed up here as this may be the only resource at the moment where you can find information on bluettis bluetooth programming. I am currently trying to receive the incoming watts from the DC input via ESP32. However, I am not a bluetooth expert. But I have a small program hull that apparently connects to the Bluetti. However, I don't have a valid 'characteristings' ID, which in my sample code should look something like '"beb5483e-36e1-4688-b7f5-ea07361b26a8"'. I was hoping in the Python code posted here to find this information. In 'ep500p.py' this information seems to be there, but I don't know how to convert it to the above format?

Can anyone help me further?
 
Back
Top