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.
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
Hi
How do you find your “AppKey”?
Thanks
Wayne
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
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,
As of today,
I am successfully receiving data from ecoflow and passing it onto home assistant.
Yay!
Hey! Thanks for the responses! I’m finally also getting data. Appreciate the follow-ups!
Thanks for posting this! I’ve recently bought a Delta Pro and wanted to see how I might automate its charging and usage. Great to see they have an API that’s accessible so easily!
I thought I’d add here the changes that I’ve made to bring the sensor code “up-to-date” a little, using the new template sensor format. Nothing wrong with your way, it’s perfectly functional but I wanted to use the most recent formats where possible.
The rest
sensor is the same but removes the authentication since it isn’t required and I’ve reduced the update time to every 30 seconds. 5 seconds was a bit aggressive.
sensor:
- platform: rest
name: ecoflow_delta_pro
resource: !secret delta_pro_rest_url
scan_interval: 30
timeout: 30
headers:
User-Agent: Home Assistant
Content-Type: application/json
Accept: application/json
json_attributes_path: "$.data.data"
json_attributes:
- remainTime
- socSum
Here’s the biggest change which is to use the new template sensor format and also set the availability of the sensors based on the return of a valid integer from the original rest
sensor. I also use state_attr()
instead of the named attributes approach, which is another small change but “preferred”.
template:
- sensor:
- name: "EcoFlow Delta Pro - State of Charge"
state: "{{ state_attr('sensor.ecoflow_delta_pro', 'socSum') }}"
unit_of_measurement: "%"
state_class: measurement
unique_id: ecoflow_delta_pro_soc
device_class: battery
availability: "{{ state_attr('sensor.ecoflow_delta_pro', 'socSum') | int(default=-100000) > -100000 }}"
- name: "EcoFlow Delta Pro - Remain Time"
state: "{{ state_attr('sensor.ecoflow_delta_pro', 'remainTime') }}"
unit_of_measurement: "min"
state_class: measurement
unique_id: ecoflow_delta_pro_remain
icon: mdi:update
availability: "{{ state_attr('sensor.ecoflow_delta_pro', 'remainTime') | int(default=-100000) > -100000 }}"
Again, thanks for posting your original code and letting us all know that the API was even available!
Thanks for this additional info. I have 3 different EcoFlow devices, is there a way to use templates to create separate sensors without creating 3 different entries per device?
The only way I’m aware of is likely via the implementation of an actual integration which can list the serial numbers for all devices on your account and then create sensors for them. As it is, with the API available that we are using to do what we’ve done so far, it doesn’t seem that’s possible, so there would need to be a different API, or one with more information before you’ll see the features you’re asking for.
I’ve created another sensor that converts the total remainTime minutes in to days, hours and minutes to make for easier reading - it’s even grammatically correct about it.
template:
- sensor:
- name: EcoFlow Delta Pro - Friendly Remaining Time
state: >
{% set time = state_attr('sensor.ecoflow_delta_pro', 'remainTime') | int %}
{% set days = (time / 1440) | int %}
{% set leftover_minutes = time % 1440 %}
{% set hours = (leftover_minutes / 60) | int %}
{% set mins = time - (days*1440) - (hours*60) %}
{%- if days > 0 -%}
{%- if days == 1 -%}
{% set output = days ~ " day " %}
{%- else -%}
{% set output = days ~ " days " %}
{%- endif -%}
{%- endif -%}
{%- if hours > 0 -%}
{%- if hours == 1 -%}
{% set output = output ~ hours ~ " hour " %}
{%- else -%}
{% set output = output ~ hours ~ " hours " %}
{%- endif -%}
{%- endif -%}
{%- if mins > 0 -%}
{%- if mins == 1 -%}
{% set output = output ~ mins ~ " minute" %}
{%- else -%}
{% set output = output ~ mins ~ " minutes" %}
{%- endif -%}
{% endif %}
{{ output }}
state_class: measurement
unique_id: ecoflow_delta_pro_friendly_remain
icon: mdi:update
availability: "{{ state_attr('sensor.ecoflow_delta_pro', 'remainTime') | int(default=-100000) > -100000 }}"
And single digits (day in this case)