ha-ef-ble icon indicating copy to clipboard operation
ha-ef-ble copied to clipboard

BLE Support for EcoFlow Smart Generator?

Open fkroepfl opened this issue 10 months ago • 43 comments

Hello,

first of all, thank you for your work on this project! I’m interested in using BLE communication with EcoFlow devices, specifically the EcoFlow Smart Generator (https://www.ecoflow.com/eu/smart-generator).

I have two questions regarding this:

  1. Does your implementation support BLE communication with the EcoFlow Smart Generator?
  2. If yes, is it possible to start and stop the generator using BLE commands?

I’d appreciate any insights you can provide. Thanks in advance!

fkroepfl avatar Jan 29 '25 12:01 fkroepfl

Hi @fkroepfl , sorry but since I have no smart generator in hands - I don't think I will reverse & support it. But, in general, if the generator uses the same protocol - theoretically it's possible to add to the integration but a bit of reversing and capturing the required commands.

rabits avatar Jan 29 '25 19:01 rabits

Hi @rabits, thank you very much for your response!

At this point, I don’t own a Smart Generator yet and haven’t made a final decision. Ideally, I’m looking for a generator that can be controlled locally, i.e., off-grid, directly from the ESS. The EcoFlow Smart Generator seemed like an interesting option, especially considering the frequent promotional offers.

However, relying on the EcoFlow Cloud for integration doesn’t seem practical for my use case. That’s why BLE control would have been an interesting alternative.

Thanks again for your input!

fkroepfl avatar Jan 29 '25 20:01 fkroepfl

Yeah, I really like the hardware but their reliance on cloud made me do this reverse-engineering project. But looking at it - I see no way to install it indoors and I don't plan to keep it or any other generator outside for a long time... So not sure how useful is it, but need to think about that a bit longer...

rabits avatar Jan 29 '25 22:01 rabits

I'm not sure if I understand the second part of your message correctly, but my thought was that since the smart generator is ‘outdoor capable’, as long as it is under cover (e.g. carport), to be able to make the BLE connection via https://esphome.io/components/bluetooth_proxy.html.

fkroepfl avatar Jan 30 '25 07:01 fkroepfl

I just ordered a d3+ and smart gen 3k. they communicate with each other over ble, i will be wanting HA control also, so hopefully i can contribute here soon :)

jcam avatar May 24 '25 13:05 jcam

I tried to add a feature to add currently unsupported devices to HA and provide us info that will help us add the support. Can someone with the device try installing pre-release version v0.16.0-a.1 from my fork, follow this guide and upload diagnostic info here?

GnoX avatar May 25 '25 13:05 GnoX

If someone else doesn't do so first, I should have my ecoflow things in about a week (d3+, smart gen 3k, alternator charger 800w) and would be happy to do this :)

Before I get to far, is there any reason I should avoid firmware updates? I was reading about how the mqtt override stuff may have been blocked, and I generally will only be using these things where there's no internet, so local control is very important.

jcam avatar May 25 '25 15:05 jcam

btw.: It looks like the EcoFlow Smart Generator 3000 (Dual Fuel) is available in the US, but not or not yet in the EU.

fkroepfl avatar May 25 '25 19:05 fkroepfl

@jcam

Before I get to far, is there any reason I should avoid firmware updates?

For example my system is completely offline. Not bug-free, my DPU's sometimes disconnecting from SHP for some reason, but until I will find a way to capture the firmware and write it to the device - I'm trying to avoid any upgrades.

rabits avatar May 25 '25 19:05 rabits

@GnoX here's the data for the sg3000 generator. Your a2 version worked :)

generator_config_entry-ef_ble-01JYZQ0P3PBPZT262D9NP927E2.json

What is the next step? I looked at both your repo and this one and it doesn't seem to give much detail on how to interpret the diagnostic data/packets or how to make a new device PR...

jcam avatar Jun 30 '25 06:06 jcam

Hey, thanks for the info - that diagnostics file is enough to add basic support. In fact, I had implementation for it already prepared, just needed to see the actual data from the device.

Check if version v0.17.0-a.1 works and if values make sense.

GnoX avatar Jun 30 '25 14:06 GnoX

Image Image

jcam avatar Jun 30 '25 15:06 jcam

Great to see it connecting already!

This generator doesn't have XT150, so those might not be valid options anyways (probably should disable by default). I have it in my kitchen and it has no fuel, so i haven't been able to test starting it.

I'm about to head out camping for a week, will be great to see some data from this, along with my delta 3's info.

Thank you! And, if you happen to have time to poke at #35 , I would be thrilled to be able to use home assistant automations to switch between charging and reverse charging based on whether the generator is running :) (along those lines, do you have a 'buy me a beer' button somewhere? <3

jcam avatar Jun 30 '25 15:06 jcam

On this one, one thing that you can do with the app is that when you hook up a propane cylinder, you can tell it approximately how much propane is left, and it will use that to calibrate the onscreen hours remaining/fuel %. Would be great to figure out which code to tweak to make that happen

jcam avatar Jun 30 '25 15:06 jcam

Ah, missed one small thing, try to redownload the same version.

This generator doesn't have XT150

Right, I confused it with the 4000 version, should be removed for now.

And, if you happen to have time to poke at https://github.com/rabits/ha-ef-ble/issues/35

I did in fact also add support for alternator charger in this version, you can test that one as well ;)

GnoX avatar Jun 30 '25 15:06 GnoX

Alternator/Charger looks nearly perfect! Only tweaks needed: "Open" is really whether it is turned on for charging or not. Ecoflow calls this "Start working" in the app, but I would call it like "Charge" or "Enable Charging" or "On" or something like that. Also it identifies as a Smart Generator (copypasta for the win! :) )

Image

Generator is also like 99% there! Only change I would make is that these 3 options actually mean: "closed" -> Off / Engine not running / Stop the engine if it is running or trying to start "opened" -> Start the engine (I think it would also be in this state if it was Running) "closing" -> it switches to this state when it has been told to start but isn't running yet. Choosing it through the interface does nothing, so it is more of a sensor output than an input

Image

jcam avatar Jun 30 '25 15:06 jcam

Oh, "Subordinate Battery Level" and "Subordinate Battery State"... These are actually the generator's internal battery charge level and charging state. I think it would be 1 for "charging" or 0 for "not charging" but i also haven't either started the generator yet, nor tried to plug something into the special trickle charger input port. not sure if it has a "fully charged" state also...

jcam avatar Jun 30 '25 15:06 jcam

Second "oh but also": on the alternator-charger, the app has a sensor for the external battery voltage, which we don't have here yet. not required, but nice to have.

And, for the operating mode, the internal names aren't super clear Battery Maintenance is one of the names on the app, the others are called "Charge" for driving_charge, and "Reverse charge" for parking_charge. Image

jcam avatar Jun 30 '25 16:06 jcam

And, regardless of the above, you've really made my week here! Now my micro home assistant box will be able to automatically control the extra battery charging! I'm heading out for the trip in a few minutes, so won't be able to test another update until I get back, but I really really appreciate the fast turnaround on this!!

jcam avatar Jun 30 '25 16:06 jcam

Ok, got it. Names should now match according to what you wrote.

on the alternator-charger, the app has a sensor for the external battery voltage

I just misspelled the sensor name, it should now be there

These are actually the generator's internal battery charge level and charging state. I think it would be 1 for "charging" or 0 for "not charging" but i also haven't either started the generator yet

There should be 6 states - idle, no_input, discharging, charging, normal_full and normal_low_pressure

Also, Those sensors that showed numeric states should now show their names - forgot to add them into options. You can redownload the same version again.

One FYI - I'm not super confident about Alternator Charger controls as it is quite hard to find it in the ecoflow app so I used a generic interface. I'm not sure about all of the values so cross check them with the app.

GnoX avatar Jun 30 '25 16:06 GnoX

Going back on what I said, I did end up downloading the new version :) I've already packed the gen and alt but will report back when i power everything up in a few hours

jcam avatar Jun 30 '25 17:06 jcam

In the general sense nearly everything worked great this week. I gotta get everything back out of my trailer so I can grab some screenshots. A couple things come to mind that might need small updates:

  • in device automations, some of the naming may still need to be cleaned up to match the other places they were updated
  • alt/chg i saw a couple of things, but I can move the conversation for that over to #35

Unfortunately I discovered at the last minute that my BT interface only seems to support 2 active connections, so if it tries to connect to the D3+, Alt/Chg and SG3k all at the same time, only 2 of them will work (and it's somewhat random which ones)... I'll make the switch to an esp32 BT proxy and try again.

jcam avatar Jul 08 '25 13:07 jcam

in device automations, some of the naming may still need to be cleaned up to match the other places they were updated

Are you referring to the state names or entity names? For state names, I did leave their naming the same as in raw data, just changed their translations. But it is probably better to rename them to stay consistent visually, I'll think about this.

GnoX avatar Jul 08 '25 15:07 GnoX

I finally got everything back running, and this time I'm using a bluetooth proxy, so I have all 3 devices attempting to connect. Looks like a small bug in the generator code:

2025-07-12 01:08:23.915 ERROR (MainThread) [custom_components.ef_ble.eflib.connection - F0:F5:BD:29:21:0A] Captured exception: Sensor sensor.ef_ge40161_engine_state provides state value '0', which is not in the list of options provided:
  File "/config/custom_components/ef_ble/eflib/connection.py", line 853, in listenForDataHandler
    processed = await self._data_parse(packet)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ef_ble/eflib/devices/smart_generator.py", line 163, in data_parse
    self.update_callback(field_name)

jcam avatar Jul 12 '25 05:07 jcam

Here is the deserialized status update, if it helps to determine what is missing. Looking it over, a few things don't look quite right... 3200 is the max surge output in AC watts (not DC... this generator doesn't have any DC output at all) 2600 is the max continuous output in AC watts (not the battery temp) frequency should be 60, not 50... i'll have to start up the generator to see if it is set wrong en_beep says false, but it does beep for everything

sys_status: 1
pow_out_sum_w: 0
dev_standby_time: 3
screen_off_time: 180
xboost_en: false
pow_get_ac: 0
generator_conn_dev_errcode: 0
current_time_task_v2_item {
  task_index: 65535
}
generator_low_power_en: true
generator_low_power_threshold: 0
generator_lpg_monitor_en: true
fuels_liquefied_gas_lpg_uint: 0
fuels_liquefied_gas_lng_uint: 0
en_beep: false
ac_out_freq: 50
pd_err_code: 0
cms_batt_soc: 0
cms_dsg_rem_time: 0
cms_chg_rem_time: 0
cms_oil_self_start: true
time_task_change_cnt: 0
pow_get_dc: 0
ac_out_open: true
generator_fuels_type: 2
generator_remain_time: 0
generator_run_time: 2857
generator_total_output: 0
generator_abnormal_state: 24
fuels_oil_val: 0
fuels_liquefied_gas_type: 0
fuels_liquefied_gas_uint: 0
fuels_liquefied_gas_val: 8.164
fuels_liquefied_gas_consume_per_hour: 0
fuels_liquefied_gas_remain_val: 0
generator_perf_mode: 1
generator_engine_open: 0
generator_out_pow_max: 0
generator_dc_out_pow_max: 3200
generator_sub_battery_temp: 2600
generator_sub_battery_soc: 41
generator_sub_battery_state: 0
generator_pcs_err_code: 0
plug_in_info_dcp_in_flag: false
plug_in_info_dcp_type: 0
plug_in_info_dcp_detail: 0
plug_in_info_dcp_dsg_chg_type: 0
plug_in_info_dcp_charger_flag: false

jcam avatar Jul 12 '25 05:07 jcam

Looks like a small bug in the generator code

Oops, just replaced the pre-release version, should be fixed now.

3200 is the max surge output in AC watts (not DC... this generator doesn't have any DC output at all)

I think some fields are set but unused for some variants - for this case DC output is only used in 4000 variant but ignored here.

frequency should be 60, not 50... i'll have to start up the generator to see if it is set wrong

I see that there is a configuration option for frequency but I don't think it would do anything. Specs say it only support one frequency, this field is also probably unused.

GnoX avatar Jul 12 '25 12:07 GnoX

Getting closer ;)

2025-07-12 10:07:28.246 ERROR (MainThread) [custom_components.ef_ble.eflib.connection - F0:F5:BD:29:21:0A] Captured exception: 'str' object has no attribute 'name':
  File "/config/custom_components/ef_ble/eflib/connection.py", line 853, in listenForDataHandler
    processed = await self._data_parse(packet)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ef_ble/eflib/devices/smart_generator.py", line 165, in data_parse
    self.update_state(field_name, getattr(self, field_name))
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ef_ble/eflib/devicebase.py", line 253, in update_state
    update(value)
    ~~~~~~^^^^^^^
  File "/config/custom_components/ef_ble/select.py", line 111, in state_updated
    self._attr_current_option = state.name.lower()
                                ^^^^^^^^^^

jcam avatar Jul 12 '25 14:07 jcam

frequency should be 60, not 50... i'll have to start up the generator to see if it is set wrong

I see that there is a configuration option for frequency but I don't think it would do anything. Specs say it only support one frequency, this field is also probably unused.

Frequency can be changed from the front control panel on the generator (and on the delta 3 plus too), so a configuration option and display of the value would be useful if they also work.

jcam avatar Jul 12 '25 15:07 jcam

Getting closer ;)

Eh, you fix one thing and break two other, thats how it goes :). Should be fixed, this time it should work. Hopefully.

Frequency can be changed from the front control panel on the generator (and on the delta 3 plus too)

Wait, can it? I see that it is displayed there but no way to change it.

Also out of curiousity, in what situation would you want to change it? I saw that in the messages but did intentionally not put it to HA as I didn't see it being useful.

GnoX avatar Jul 12 '25 17:07 GnoX

Yeah, on the SG3k you turn on the generator master switch to manual (might work in auto mode, but i didn't try), then hold down the IOT/wifi/pair button for 10 seconds and it will beep, next time you start it up it will come up in the other frequency.

On the delta3+, you can switch the frequency by holding down the AC button for 12 seconds when the unit is turned on and AC outputs are off.

I don't think you can change either from the official app.

jcam avatar Jul 12 '25 17:07 jcam