Trying to get info from my Ecoflow Delta Max battery

Hello,

I’ve recently bought a Delta Max from EcoFlow and I really like the product.
I’ve asked the support if I can get access to their API, they asked for my serial number and I got this URL in return (with the AppKey in it):
https://iot1.ecoflow.com/api/v1/devices/queryDeviceData?sn=MySerialNumber&appkey=MyAppKey

When I type the URL into a browser, I get something like this:
{"code":0,"message":"success","data":{"sn":"MySerialNumber","data":{"remainTime":407,"socSum":80}}}

Now, I’m just trying to get “remainTime” and “socSum” as sensors into HA.

Here is my code so far:

- platform: rest
  name: ecoflow_delta_max
  resource: !secret ecoflow_url
  scan_interval: 5
  timeout: 30
  authentication: digest
  headers:
    User-Agent: Home Assistant
    Content-Type: application/json
    Accept: application/json

- platform: template
  sensors:
    ecoflow_delta_max_time:
      value_template: "{{ value_json[0].data.remainTime }}"

    ecoflow_delta_max_soc:
      value_template: "{{ value_json[0].data.socSum }}"

But I got “unavailable” in return for the 2 template sensors and the result of the API call in ecoflow_delta_max is:
{"code":0,"message":"success","data":{"sn":"MySerialNumber","data":{"remainTime":407,"socSum":80}

My main goal would be to connect the battery to a smartplug and charge it only when my rooftop PVs produces energy or when it’s below 20%.

Could anyone help me with this?
I hope it can help other in the end because this is really a great product for a portable battery.

4 Likes

Not that I can help, but good products (I use them for UPS on among other things my HA installation, although there is a real UPS downstream as the switch a bit too slow at a blackout), and an HA integration would be much appreciated.

Hey,

For anyone interested, I figured it out:

- platform: rest
  name: ecoflow_delta_max
  resource: !secret ecoflow_url
  scan_interval: 5
  timeout: 30
  authentication: digest
  headers:
    User-Agent: Home Assistant
    Content-Type: application/json
    Accept: application/json
  json_attributes_path: '$.data.data'
  json_attributes:
    - remainTime    # Time remaining until batteryis fully charged or too low [Min]
    - socSum        # State of charge of the main battery + additional ones [%]


- platform: template
  sensors:
    ecoflow_delta_max_soc:
      friendly_name: "EcoFlow Delta Max - State of charge"
      unit_of_measurement: "%"
      device_class: battery
      value_template: >
         {% if states.sensor.ecoflow_delta_max.attributes["socSum"] is defined %}
           {{ states.sensor.ecoflow_delta_max.attributes["socSum"] }}
         {% else %}
           0
         {% endif %}

    ecoflow_delta_max_time:
      friendly_name: "EcoFlow Delta Max - Remain time"
      unit_of_measurement: "min"
      icon_template: mdi:update
      value_template: >
         {% if states.sensor.ecoflow_delta_max.attributes["remainTime"] is defined %}
           {{ states.sensor.ecoflow_delta_max.attributes["remainTime"] }}
         {% else %}
           0
         {% endif %}

I’ve asked EcoFlow and SoC and remain time are the only 2 things available at the moment.
So I was planning on getting smartplugs both on the wall and between the battery and the equipment of my rack, but I don’t have usable readings for now (somehow, my Meross smartplugs don’t measure the same power…).

If I have that, I can get how much power it takes when it charges/discharges, and then getting utility meters out of it, to eventually getting it integrated as a battery into the Energy Dashboard :yum:

5 Likes

That’s awesome, I have asked for the same thing and am waiting for a response.

I’m fairly new to Home Assistant, so could you maybe post the “Idiot’s guide” on where in HA can I enter your example code?

Cheers!

Hi there,

Yeah sure.
Remember that there are plenty guides (videos on Youtube, etc.) to help you start with Home Assistant.

To add custom code like this one, you need a way to edit .yaml files on the HA host.
The simplest way to do that (if you have the hypervisor) is to install the File editor: Configuration > Add-ons, Backups & Supervisor > Add-on store > File editor > Install

Onced installed, click on “Start on boot” and “Show in sidebar”. You might have to restart HA and refresh the cache of your browser.

Next, click on it, click on the folder icon on the top left and open configuration.yaml

The only thing you have to do next is to copy/paste the code I’ve written.
I use “!secret” for the resource filter so all sensitive data is stored in another file (easier to share) but you don’t need that. You can put the URL directly.

1 Like

Thanks for the info. I do not have a device yet but plan to buy one.

The request seems only working through internet. Have you tried replacing iot1.ecoflow.com by a local IP ?

Does the mobile app still working if you are on the same network, without internet ?

Thank you

Thank you for the info, much appreciated. I am responding to let anyone else that, like me has the standard “River” model that the “data” returned for it is empty; there is no state of charge or anything else really.
I have contacted Ecoflow to ask them about it and am awaiting a response.

Update: Got a response form Ecoflow, and they enabled the remainTime and socSum info for the API, so now they are visible on the web page.
I tried pasting your code into the configuration.yaml file of HA, both under the “default_config:” and under the “discovery:”, but can’t find it as an integration in HA. Any help would be appreciated (sorry, for some reason I can’t message you directly)

Good point, the local IP.

So, I’ve just tried but no luck so far.
I’ve replaced…
https://iot1.ecoflow.com/api/v1/devices/queryDeviceData?sn=

by:
https://IP_Address/api/v1/devices/queryDeviceData?sn=…
https://IP_Address/v1/devices/queryDeviceData?sn=…
https://IP_Address/devices/queryDeviceData?sn=…

…But no luck no far.

Still, I’ve changed my iPhone recently and didn’t came back to the app yet.
When I did, the app asked me to check devices on my local network. So there’s maybe a way.

image

Iznogood,

When you add sensors by the rest platform, you can’t see any integration afterwards.
It just creates news sensors in Configuration > Devices & Services > Entities.
You can then add them on a lovelace card just like any other sensor.

In order to see an integration in HACS (and then maybe one day an official integration), someone need to code it, put it in Github, let it validate and then maintain it.

I’m not able to do all of that and I don’t think it’s worth it just for 2 sensors in read mode (you can’t interact with the product from HA or the API as of now).

But if someone is willing to do so, great !

Hi @BeyondPixels
Perhaps I didn’t state the issue correctly. I’ll rephrase:
When I copy and paste the code you provided, in any section of the configuration.yaml file, it either comes back with errors, or HA crashes to Safe Mode.
What would be immensely helpful is a copy of your configuration.yaml, so I can see what preceeds your code; from my limited experience is appears that when HA reads the configuration.yaml, it gets stuck in some short of error that has to do with not understanding why is the code either at that location, or doesn’t have a header like “sensors:”
In any case, I didn’t ask you to create an integration just for me mate…

Never mind, got it by trial and error; for anyone else, add
sensors:

to the begging of the code provided by @BeyondPixels

1 Like

Hi

How do you find your “AppKey”?

Thanks
Wayne

1 Like

You have to contact their support.
They’ll ask you to give your serial and they’ll give you the URL (with the AppKey in it) in return (I’ll edit my fist post to clarify).

If you could ask for more features in their API like AC/DC in/out current, it could be great.
Maybe if enough of us is asking for it, they’ll do it :-).

I asked for Power Output, Power Consumption - we will see if they add any new values!

Thanks for all the good work on this so far everyone!

I have an Ecoflow River that I have in a sauna I built that is off-grid in our woods to run low-voltage lights. This weekend I ran wifi out there so the battery is now recognizable on the network. I would like to control the DC output power state so I can turn the lights on before we walk out there, but so far it doesn’t look like they give us switching access yet in the API.

I will start using your code as a base to start and see how far I can get. I will contact their support and see if any direct control from HA could be added.

Cheers

1 Like

I have a ecoflow river, got the sn and key but the data seems to be empty… Am I missing something?

Customer support said: "Dear customer,

We have checked with the engineering team that we can only provide the URL link.
For the connection part, Professional programming is required. "

This is what I get when I go the url:

“code”:0,“message”:“success”,“data”:{“sn”:“mysnxxxxx”,“data”:{}}}

Any help would be greatly appreciated.
Thanks!

I’m having the same issue. I have a River Pro and a River Mini Wireless. I received both URLs with the SN and AppKey, but I get an empty data set in the JSON returned, same as you.

I’ve been chatting back and forth with the support team… while they are willing, they are not very helpful, you just gotta keep chatting with them i think…

Just got this from customer service:

Dear customer,

Sorry for the inconvenience.
We have just confirmed with the engineering team that our server is during the upgrading process and the API connection is not available now. We will fix it within 48 hours. Could you please wait a little bit?

Stay safe & Best regards,