Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart Home Panels Support #26

Open
adampagot opened this issue Aug 1, 2022 · 132 comments
Open

Smart Home Panels Support #26

adampagot opened this issue Aug 1, 2022 · 132 comments
Labels
wontfix This will not be worked on

Comments

@adampagot
Copy link

Is it possible to support the smart home panel? If there is anything I could do to help please let me know.

@vwt12eh8
Copy link
Owner

vwt12eh8 commented Aug 2, 2022

The local API for the Smart Home Panel is Bluetooth only, and no TCP API is provided, so this integration cannot handle it.

If you want to support it, you will have to develop EcoFlow integration for Bluetooth or EcoFlow integration for ESPHome separately.

@vwt12eh8 vwt12eh8 added the wontfix This will not be worked on label Aug 2, 2022
@franki29
Copy link

Hi, you can use Node-Red. What smart home panel do you like to use?

@vwt12eh8
Copy link
Owner

Unfortunately I have never used Smart Home Panel myself.
The reason I'm not able to use TCP is based on speculation based on the behavior of the official app.

If you have an example of using it with NodeRed, please share it.

@franki29
Copy link

Hi, if you have not yet used one I would recommend:

https://www.openhasp.com
https://github.com/sieren/Homepoint
https://github.com/souravj96/max7219-mqtt-esp8266

All are working over a MQTT Broker, so you do not need Node Red for it unless you like to change some messages.
I am not a expert in Home Assistant, but it should be possible to send the hassio-ecoflow information using home assistant mqtt connector to the panels.

@lwsrbrts
Copy link

lwsrbrts commented Sep 3, 2022

Hi, if you have not yet used one I would recommend:

https://www.openhasp.com https://github.com/sieren/Homepoint https://github.com/souravj96/max7219-mqtt-esp8266

All are working over a MQTT Broker, so you do not need Node Red for it unless you like to change some messages. I am not a expert in Home Assistant, but it should be possible to send the hassio-ecoflow information using home assistant mqtt connector to the panels.

@franki29 I think you've misunderstood the OP. The "Smart Home Panel" is another Ecoflow product, not a display device. See: https://www.ecoflow.com/us/smart-home-panel for reference.

@franki29
Copy link

franki29 commented Sep 3, 2022

Oh sorry, yes I misunderstood. Sorry.

@lwsrbrts
Copy link

lwsrbrts commented Nov 11, 2022

Just wanted to add to this issue that, while I haven't done a full port scan on my Smart Home Panel, its details and control topics (as in, an MQTT topic) are populated in Ecoflow's MQTT server. So it does like like the Smart Home Panel offers more than just Bluetooth as a connection mechanism.

@Ne0-Hack3r
Copy link

The local API for the Smart Home Panel is Bluetooth only, and no TCP API is provided, so this integration cannot handle it.

If you want to support it, you will have to develop EcoFlow integration for Bluetooth or EcoFlow integration for ESPHome separately.

It appears SHP data is available and settings can be controlled via public MQTT server @ mqtt.echoflow.com ... not certain how to obtain the keys/schema for SHP but it would appear there may be a way to integrate SHP similar to Delta Pro with the caveat of being dependent on a cloud server...

@lk229
Copy link

lk229 commented Mar 24, 2023

It appears SHP data is available and settings can be controlled via public MQTT server @ mqtt.echoflow.com ... not certain how to obtain the keys/schema for SHP but it would appear there may be a way to integrate SHP similar to Delta Pro with the caveat of being dependent on a cloud server.

Have you looked into this further or made any progress? I can't really help figure this out, but I would be happy to help test if it proceeded that far. Monitoring individual circuits isn't that important to me, but switching circuits between automatic and battery using HA automation would be amazing. The Ecoflow app is so limited in that respect.

@adampagot
Copy link
Author

Currently access has been limited to beta testers. I have been selected as a beta tester. I have been able to switch automations on/off with a mqtt explorer app for windows. Unfortunately I have no experience developing for HA so trying to get things working in home assistant is going very slowly for me.

@lwsrbrts
Copy link

Have you looked into this further or made any progress? I can't really help figure this out, but I would be happy to help test if it proceeded that far. Monitoring individual circuits isn't that important to me, but switching circuits between automatic and battery using HA automation would be amazing. The Ecoflow app is so limited in that respect.

This has been achieved for the Smart Home Panel using Ecoflow's MQTT servers but implementation is non-trivial.

This all started here: v1ckxy/ecoflow-withoutflow#1 (comment) - which gives you an indication of where to be looking to do things.

When configuring your mosquitto.conf file however, follow this recommended format from @Ne0-Hack3r: v1ckxy/ecoflow-withoutflow#1 (comment) since that provides a method of subscribing to the topics in a non-specific manner and allows easy configuration of your HA sensors and controls.

I have slightly altered a PowerShell script I wrote to generate a suitable mosquitto.conf file.

#Requires Version 7
$useremail = '[user email address]' # Edit this
$password = '[user password]' # Edit this

# The normal use is Unicode encoding but must specify UTF8 instead.
$base64password = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($password))

$authObject = [PSCustomObject]@{
    os         = 'android'
    scene      = 'IOT_APP'
    appVersion = '4.0.0.53'
    osVersion  = '13'
    password   = $base64password
    oauth      = @{
        bundleId = 'com.ef.EcoFlow'
    }
    email      = $useremail
    userType   = 'ECOFLOW'
}

$Result = Invoke-RestMethod -Method Post -Uri 'https://api.ecoflow.com/auth/login/' -ContentType 'application/json' -Body $($authObject | ConvertTo-Json) -ResponseHeadersVariable 'Headers' -StatusCodeVariable 'StatusCode'

$TokenString = ConvertTo-SecureString -AsPlainText -Force -String $Result.data.token

$certificateData = Invoke-RestMethod -Method Get -Uri 'https://api.ecoflow.com/iot-auth/app/certification' -ContentType 'application/json' -Authentication Bearer -Token $TokenString


Write-Host "Ecoflow User ID: $($Result.data.user.userId)"

<#
Write-Host "Certificate (MQTT) User: $($certificateData.data.certificateAccount)"
Write-Host "Certificate (MQTT) Password: $($certificateData.data.certificatePassword)"
Write-Host "URL: $($certificateData.data.url)"
Write-Host "Port: $($certificateData.data.port)"
Write-Host "Protocol: $($certificateData.data.protocol)"
#>

$SHPserial = Read-Host "Please enter the correct serial number of your smart home panel"

Write-Host "Example mosquitto.conf file:"

"
connection ecoflow-bridge
address $($certificateData.data.url):$($certificateData.data.port)
remote_username $($certificateData.data.certificateAccount)
remote_password $($certificateData.data.certificatePassword)
cleansession true
remote_clientid ANDROID_$([guid]::NewGuid().ToString().ToUpper())_$($Result.data.user.userId)
try_private true
bridge_insecure false
bridge_protocol_version mqttv311
bridge_tls_version tlsv1.2
bridge_cafile /etc/ssl/certs/ca-certificates.crt

# Smart Home Panel
topic """" in 0 ecoflow/SHP/data /app/device/property/$SHPserial
topic """" both 0 ecoflow/SHP/set /app/$($Result.data.user.userId)/$SHPserial/thing/property/set
"

This basically describes how to configure mosquitto in HA to connect to Ecoflow's MQTT server to subscribe to the correct topics (and bring them to your HA MQTT server) such that you can configure sensors and other controls to act on and send actions to Ecoflow's MQTT server from HA, and have those actions happen on your SHP.

There are lots of example YAML configurations for sensors in the same thread as above, including ones for SHP.

@Ne0-Hack3r has a private Github repository where implementation is fairly well documented for SHP, but you would have to ask him for access of course.

An example control for the circuit mode might look something like:

mqtt:
 binary_sensor:
    - name: SHP Circuit 1 Auto
      object_id: shp_circuit_1_auto
      unique_id: shp_circuit_1_auto
      state_topic: "ecoflow/SHP/data"
      payload_on: "0"
      payload_off: "1"
      qos: 0
      value_template: "{{ value_json.params.loadCmdChCtrlInfos[0].ctrlMode if value_json['params']['id'] == 2 else this.state }}"
 sensor:
    - name: SHP Circuit 1 State
      object_id: shp_circuit_1_state
      unique_id: shp_circuit_1_state
      state_topic: "ecoflow/SHP/data"
      qos: 0
      value_template: "{{ value_json.params.loadCmdChCtrlInfos[0].ctrlSta if value_json['params']['id'] == 2 else this.state }}"
template:
  - select:
      - name: "SHP Circuit 1 Mode"
        unique_id: shp_circuit_1_mode
        state: >-
          {% if is_state('binary_sensor.shp_circuit_1_auto','on') %}Auto
          {% else %}
              {% set i = int(states('sensor.shp_circuit_1_state')) %}
              {% set o = {0:'Grid',1:'Battery',2:'Off'} %}
              {{ o[i] if i in o.keys() }}
          {% endif %}
        options: "{{ ['Auto','Grid','Battery','Off'] }}"
        icon: >-
          {% set i = int(states('sensor.shp_circuit_1_state')) %}
          {% set o = {0:'mdi:home-lightning-bolt-outline',1:'mdi:home-battery-outline',2:'mdi:home-off-outline'} %}
          {{ o[i] if i in o.keys() }}
        select_option:
          - service: mqtt.publish
            data:
              topic: ecoflow/SHP/set
              payload: >-
                {% set i = option %}
                {% set p = '{"from":"HA","id":"' %}
                {% set s = '","moduleType":0,"operateType":"TCP","params":' %}
                {% set id = 999900000+(range(10000,99999)|random) %}
                {% set o = {
                  'Auto':'{"sta":0,"ctrlMode":0,"ch":0,"cmdSet":11,"id":16},"version":"1.0"}',
                  'Grid':'{"sta":0,"ctrlMode":1,"ch":0,"cmdSet":11,"id":16},"version":"1.0"}',
                  'Battery':'{"sta":1,"ctrlMode":1,"ch":0,"cmdSet":11,"id":16},"version":"1.0"}',
                  'Off':'{"sta":2,"ctrlMode":1,"ch":0,"cmdSet":11,"id":16},"version":"1.0"}'
                  }
                %}
                {% if i in o.keys() %}{{p}}{{id}}{{s}}{{o[i]}}{% endif %}

@lk229
Copy link

lk229 commented Mar 24, 2023

This has been achieved for the Smart Home Panel using Ecoflow's MQTT servers but implementation is non-trivial.

@lwsrbrts Wow. Thanks for all this info and sample scripts. This is exactly what I need. I've got a lot to learn in order to implement this but it looks doable.

@adampagot
Copy link
Author

@lwsrbrts I've been fighting with the MQTT bridge, your instructions allowed me to set it up.
@Ne0-Hack3r Would it be possible to get access to your repo where you have more documents? I am a beta tester

@ipalchuk
Copy link

just for info... sorry if off topic.
nielsole/ecoflow-bt-reverse-engineering#2

@lk229
Copy link

lk229 commented Mar 25, 2023

@lwsrbrts Warning! Stupid Question Ahead:
I've used your Powershell script to create a mosquitto.conf file, but I can't figure out where it goes. Can you give a n00b some more help? I'm not sure if this is a stand-alone file or if it gets merged into an existing conf file.

I assume I'll be able to access the location using Samba. I'm running on a RPI 4 so don't think I can run Visual Studio and the File Editor seems to be limited to the config directory (unless that's where it goes). I've spent the last few weeks moving from Hubitat to HA and while I've learned a lot, I've got a very long way to go.

Thanks.

@adampagot
Copy link
Author

I think you need to activate custom configs first. In home assistant settings - device and services - supervisor - misqutto broker - visit - customize - set active to true.

Make sure you go to supervisor, not misqutto on the same screen

The file needs to go into \share\mosquito which you will need to create

I have samba and visual code studio, either would work, but I'm running on a odroid

@lk229
Copy link

lk229 commented Mar 25, 2023

Thanks @adampagot I followed your instructions and now have my mosquitto.conf file in the \share\mosquitto directory. Tomorrow I'll read through the referenced thread more thoroughly and try setting up a yaml file to access and maybe even control a circuit. Hopefully I'm able to piece this together as I'm coming into this with absolutely no prior MQTT knowledge.

@lk229
Copy link

lk229 commented Mar 25, 2023

I'm now at the point where MQTT Explorer can see the Ecoflow SHP topic but I don't really know where to go from here. I see all the samples of sensor definitions and control but don't know where the yaml coding for this should go. What file names, folders, are there pointers needed in configuration.yaml? I guess I'm still looking for basics that most would assume someone in the forum already knew.

Just started editing my configuration.yaml file and now have access to tested SHP items. Lots of work ahead but this has been a good breakthrough for me.

@Ne0-Hack3r Could I get access to your repo?

@lwsrbrts
Copy link

Just started editing my configuration.yaml file and now have access to tested SHP items. Lots of work ahead but this has been a good breakthrough for me.

@Ne0-Hack3r Could I get access to your repo?

All what follows assumes your HA MQTT broker is configured properly and is receiving messages in the correct topics.

Instead of modifying your configuration.yaml file directly, add this to it instead.

homeassistant:
  packages: !include_dir_named packages

Then download my YAML config gist for the Smart Home Panel from: https://gist.github.com/lwsrbrts/8d6a77b4306f284cd193635e5722ffcd

Some of the data access methods and set controls in the config were determined by @Ne0-Hack3r so I won't take credit for those.

Create a folder in the same location as your configuration.yaml file called packages

Then place the gist file as a .yaml extension in the packages folder.

From that configuration, I've created the following dashboards in HA - where you can also see some controls.

image

image

@lk229
Copy link

lk229 commented Mar 26, 2023

Lewis @lwsrbrts -
Thanks so much! I've added your smart_home_panel.yaml as instructed and cleaned up my configuration.yaml. I now have access to every function of my SHP and can control it through HA. Now I can automate switching circuits to/from battery use to get the most from my solar panels. Of course, my dashboard doesn't look as nice as yours, but it works perfectly.

Thanks again to you and Adam @adampagot for helping me out and making this possible.
Lee

@Ne0-Hack3r
Copy link

@lwsrbrts I've been fighting with the MQTT bridge, your instructions allowed me to set it up. @Ne0-Hack3r Would it be possible to get access to your repo where you have more documents? I am a beta tester

Done.

Everything in the repo is related to the Ecoflow public MQTT server. This access is not supported by Ecoflow and was gained by collaboration between a number of people on this and other forums (which began by decompiling the native app on Android IIRC). There is no guarantee it will continue to work once the official API is publicly released. Also, EF recently added filtering of client IDs which my documentation/scripts have not been updated to reflect.

Bottom line: I'm not sure how much of what is in the repo will work with the API. It will depend on how much data EF decides to provide via that mechanism and if they keep the same topic structure or not...

Hopefully it can be helpful to you for at least providing ideas and some insight into the YAML configuration for Home Assistant.

@Ne0-Hack3r
Copy link

I'm now at the point where MQTT Explorer can see the Ecoflow SHP topic but I don't really know where to go from here. I see all the samples of sensor definitions and control but don't know where the yaml coding for this should go. What file names, folders, are there pointers needed in configuration.yaml? I guess I'm still looking for basics that most would assume someone in the forum already knew.

Just started editing my configuration.yaml file and now have access to tested SHP items. Lots of work ahead but this has been a good breakthrough for me.

@Ne0-Hack3r Could I get access to your repo?

DONE

@Maxctran
Copy link

@Ne0-Hack3r Could I get access to your repo as well? I am trying to integrate charging with my AC solar production on my roof. I'm brand new to Home Assistant and Github so any help would be amazing. I have managed to get Home Assistant running and Delta Pros linked with the Hassio-ecoflow repo already.

@Ne0-Hack3r
Copy link

Maxctran

Done.

@aflusche
Copy link

Thanks to this thread and the other one linked above, I have tons of data coming from Ecoflow into Home Assistant. Small sample:

image

@Ne0-Hack3r I'd love access to your repo if possible to see what else can be done. For one, I saw mention in the other thread about you monitoring the Delta Pro state of charge. That's one of the main things I am wanting...

@romsch1
Copy link

romsch1 commented May 14, 2023

@Ne0-Hack3r nice job. Could you please grant me also access to your EcoFlow-Repo ? Thanks in advance :)

@Ne0-Hack3r
Copy link

@aflusche
@romsch1

Done and Done

@Ne0-Hack3r
Copy link

Anyone on this thread worked with the SHP automations via MQTT?
Anyone have a dashboard example that displays automation data or allows manipulating it?

I'm playing with this now but any ideas or examples are appreciated.

@aflusche
Copy link

aflusche commented May 15, 2023

Thank you!!

Anyone on this thread worked with the SHP automations via MQTT? Anyone have a dashboard example that displays automation data or allows manipulating it?

Not yet. My DREAM concept is for HA to monitor my DP battery level and smartly turn off non-critical circuits during an outage.

@lwsrbrts
Copy link

Just super quickly because I'm not currently near a computer but I'm actually using a slightly modified (updated by me) version of the hassio-ecoflow integration.

The original integration has been dormant for 2 years and there are a few bugs that needed fixing, but the original developer has seemingly abandoned the project. So I forked the repository and made all of the updates necessary to stop events and deprecation warnings being logged in Home Assistant. If you browse over to my GitHub page you will be able to see the repo. If you already have HACS installed, you should be able to add my repository manually.

Some of the newer Delta Pro units use a different Wi-Fi module which ecoflow updated with different firmware causing the integration to no longer work due to a closed port so your mileage may vary.

@lwsrbrts
Copy link

As for the energy dashboard, all of that information is simply taken from the sensors or I create separate sensors to amalgamate the data and have the sensors set up in a certain way such that they can be added to the energy dashboard. I do have a GitHub gist which shows all of the sensors for the smart home panel but if you have specific questions, I'm sure I can dig the answers out and give you the code if necessary

@CyberGWJ
Copy link

Thanks for the quick response. I do have HACS installed and will go to your github. One of my DP is year old the other I just got. Each DP has 1 extra battery attached. I checkout your gist and the dashboard you created is awesome. That's what got me started on getting this setup.

@CyberGWJ
Copy link

CyberGWJ commented Aug 23, 2024

@lwsrbrts I got the DPs into HA with no issues. Thanks for keeping this integration up to date.

@Ne0-Hack3r
Copy link

Ne0-Hack3r commented Aug 25, 2024

CyberGWJ

Invite sent.

There are YAML examples for DP and D2 as well as SHP1.

However, the updated repo for hassio-ecoflow by @lwsrbrts is the way to go for DP if your units will work with it...

https://github.com/tolwi/hassio-ecoflow-cloud is another approach to impersonating the app using the cloud server. Unfortunately, this is the only way to access SHP1 data but this integration does not support SHP.

I have a local fork of hassio-ecoflow repo myself that I have modified to create some additional entities and such so I've moved away from the YAML approach originally posted to my private repo as far as DP is concerned.

There is some work going on within the official API group that might result, eventually, in a true HA integration that supports SHP1 (and perhaps SHP2 and DPU eventually as well). In the mean time you can use the YAML in my repo as a starting point or head over to developer.ecoflow.com, sign up, get an access key, and build something for yourself around the official API (which supports both SHP1 and DP) using either YAML or Python and using either HTTP or MQTT or both.

@Ne0-Hack3r
Copy link

carfnann

Apologies for the late response. Haven't been hanging out on GitHub for a while...

Invite sent.

@CyberGWJ
Copy link

@Ne0-Hack3r Thanks for the invite. I will take look at the options.

@lwsrbrts
Copy link

As for SHP access, it looks like Ecoflow has finally closed the gap accessing their servers using an MQTT bridge in Home Assistant, at least in its current form. Ecoflow apparently have complained about the number of unauthorised "apps" accessing their servers. The response should really be "Give us local access to the data then your servers won't be a problem for you."

Anyway, gripes aside, in order to be able to control Smart Home Panel from Home Assistant using the method we've established up to now, you absolutely will need to sign up for the Ecoflow Developer portal and get yourself and accessKey and secretKey. Now that you have that....

I've used/copied/adjusted @digitalurban 's Python script to create a new PowerShell script which generates the connection information to get access to the public API endpoint via MQTT again.

Other than checking that I can see data flowing, that's as far as I've got with it up to now. This will need further engineering to see whether/if:

  • A bridge connection can be made using these new credentials for the public API.
  • If the connection remains stable and/or for how long, can it be mitigated.
  • The existing hard work done by @Ne0-Hack3r to create the YAML packages can be updated/modified to do all the same stuff we're already doing.
  • Probably a few other things...
# Configuration
$ACCESS_KEY = "your access key from Ecoflow Dev portal"
$SECRET_KEY = "your secret key from Ecoflow Dev portal"
$endpoint = "https://api-e.ecoflow.com"

function Get-Timestamp {
    return [int64](([datetime]::UtcNow - [datetime]'1970-01-01').TotalMilliseconds)
}

function Get-Nonce {
    return (Get-Random -Minimum 100000 -Maximum 999999).ToString()
}

function Get-Signature {
    param (
        [string]$access_key,
        [string]$secret_key,
        [string]$nonce,
        [string]$timestamp
    )
    
    # Sort parameters by ASCII value and concatenate them
    $strToSign = "accessKey=$access_key&nonce=$nonce&timestamp=$timestamp"
    
    # Create HMAC-SHA256 signature
    $hmac = New-Object System.Security.Cryptography.HMACSHA256
    $hmac.Key = [System.Text.Encoding]::UTF8.GetBytes($secret_key)
    $signBytes = $hmac.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($strToSign))
    $signature = -join ($signBytes | ForEach-Object { "{0:x2}" -f $_ })
    
    return $signature
}

function Get-MqttConnectionData {
    $nonce = Get-Nonce
    $timestamp = Get-Timestamp
       
    # Generate the signature
    $sign = Get-Signature -access_key $ACCESS_KEY -secret_key $SECRET_KEY -nonce $nonce -timestamp $timestamp
    
    $headers = @{
        "accessKey" = $ACCESS_KEY
        "nonce" = $nonce
        "timestamp" = $timestamp
        "sign" = $sign
    }
    
    # URL for querying device data
    $url = "$endpoint/iot-open/sign/certification"
    
    # Send request
    return Invoke-RestMethod -Uri $url -Method Get -Headers $headers
}

$connectionData = Get-MqttConnectionData
$connectionData

You'll see in the returned data there is a certificateAccount This is used in the MQTT topics that you need to subscribe to.

Based on the Ecoflow developer portal, these look as follows, and I can confirm this pattern works since I've tested it in MQTT Explorer. I actually tried first without the starting / but this doesn't work. I also sent a message on the .../set topic to configure the charge limit and that worked too. We'll have to see how things progress.

/open/CERTIFICATEACCOUNT/SMARTHOMEPANELSERIAL/set
/open/CERTIFICATEACCOUNT/SMARTHOMEPANELSERIAL/set_reply
/open/CERTIFICATEACCOUNT/SMARTHOMEPANELSERIAL/get
/open/CERTIFICATEACCOUNT/SMARTHOMEPANELSERIAL/get_reply
/open/CERTIFICATEACCOUNT/SMARTHOMEPANELSERIAL/quota
/open/CERTIFICATEACCOUNT/SMARTHOMEPANELSERIAL/status

@ebeiersdorfer
Copy link

ebeiersdorfer commented Aug 27, 2024

Appreciate the updated script. I saw my feed die out in the last couple weeks and figured that they'd locked it down since it would still pull data as long as I had the iOS app open. I submitted for my dev credentials the other day and got approved, just haven't had the time to adjust the connection yet. I'll give it a shot this weekend.

As you mentioned it would be nice if this just had a local API like the Delta Pro but I imagine we'll never get that.

@CyberGWJ
Copy link

Thanks for the heads up. I was planning on becoming a ecoflow developer. So, now guess I have too.

@lwsrbrts
Copy link

I've updated my mosquitto.conf and the YAML configuration to suit the public API connectivity - the only thing that is actually missing is the per circuit grid and battery use data - which is a shame because the dashboard looks bland without it.

image
image

I've prodded Ecoflow to add that data but I won't hold my breath.

Modifications were fairly minimal in truth...and in some cases, it simplifies things. I'll push a gist in a few minutes with the YAML and a suitably redacted mosquitto.conf so you can crib from it if required.

@lwsrbrts
Copy link

Here's the gist.

https://gist.github.com/lwsrbrts/50d6c8168fab3360e8619ec31aad422a

@Thomptronics
Copy link

Here's the gist.

https://gist.github.com/lwsrbrts/50d6c8168fab3360e8619ec31aad422a

In the mosquitto.conf file, I'm not sure what to put in for remote_username. Is it the same thing as the {CERTIFICATEACCOUNT} (a.k.a., certificateAccount) value? I assume remote_password is the same thing as the certificatePassword.

@lwsrbrts
Copy link

Yep, it's the certificateAccount value from the powershell.

@ebeiersdorfer
Copy link

@lwsrbrts it might be worth noting that the API endpoint can differ and may need to be updated in the mosquitto.conf and the Get-MqttConnectionCredentials.ps1 files. You can find your proper endpoint in the Developer Portal under the Host header. In my case my endpoint was "-a" and not "-e".

@lwsrbrts
Copy link

lwsrbrts commented Aug 29, 2024

Yeah, let's call that a hard-coding bug. 😁

EDIT: I'll update the gist.

EDIT: Thanks for the heads-up.

@Ne0-Hack3r
Copy link

@lwsrbrts thanks for taking this forward. I had done some playing with the official API using YAML packages but then started down the path of a full scale integration in python. This is more challenging but also more efficient/elegant that using YAML to do everything. However, I've had other distractions and a lack of time to devote to this effort and had also been waiting for EF to add things like the per circuit wattage reading for SHP to the API.

@lwsrbrts
Copy link

lwsrbrts commented Sep 1, 2024

I've spent the afternoon creating a PowerShell script that will retrieve data from the HTTP API. It's basically 5 functions and then a load of examples of how to use...well, technically, just one of those functions since the rest of the functions support that usage.

https://gist.github.com/lwsrbrts/cc02314a7ff203897061da8c7dffbab0

I'm not going to say it's completely bug free but I've done a fair amount of testing and that worked as I'd hoped..

The point of me doing this was to be able to understand how to use their HTTP API and I can best do that in PowerShell as that's my most comfortable language. I also wanted to make the first start on getting the per circuit battery and grid usage data from the HTTP API since that's missing from the MQTT quota responses and I can't determine any way to retrieve it via MQTT either.

Unfortunately my knowledge of Python, especially with HA integrations, borders on zilch knowledge so I can't apply this to an HA integration anyway but who knows, someone else might be able to take this and run with it.

@lwsrbrts
Copy link

lwsrbrts commented Sep 1, 2024

@lwsrbrts thanks for taking this forward. I had done some playing with the official API using YAML packages but then started down the path of a full scale integration in python. This is more challenging but also more efficient/elegant that using YAML to do everything. However, I've had other distractions and a lack of time to devote to this effort and had also been waiting for EF to add things like the per circuit wattage reading for SHP to the API.

It's a bit hacky but to get the battery and grid energy usage per circuit, I plan to do something with the script I created that uses the HA API to drop the data for the per circuit energy usage in to a sensor's attributes and then I can template off those. It's a start, if nothing else.

@dapiet888
Copy link

@lwsrbrts I have managed to get my data into HA but do not see any switches in my entities to start AC charging via the anderson ports as per your dash above. Is this yaml file the most recent one? https://gist.github.com/lwsrbrts/50d6c8168fab3360e8619ec31aad422a

@dapiet888
Copy link

@lwsrbrts thanks for all the support on getting this into HA!! All sorted after trial and error:). Managed to get my Grid tied solar automation to charge my DP's via AC when the Fronius hits 1000W :)

Question around the sensor names in the yaml. When i want to view the consumed data per circuit, the ID is "SHP Circuit 2 Consumed Energy" and i cant seem to change this in HA. I tried to update the yaml file like below but it did not update in HA. Am i doing something wrong or is it controlled by the EF API.

From
source: sensor.shp_circuit_2_power
name: SHP Circuit 2 Consumed Energy
unit_prefix: k
round: 3

To
source: sensor.shp_circuit_2_power
name: Kitchen
unit_prefix: k
round: 3

Screenshot 2024-09-12 at 20 52 11 Screenshot 2024-09-12 at 20 52 28 Screenshot 2024-09-12 at 20 53 06

Much appreciated

@lwsrbrts
Copy link

It's probably a quirk of how the Integral integration works. It's collecting data from a source sensor and applying a Riemann sum integral calculation to it. I suspect it's keeping the original name because that's what was declared when it first started collecting data and if it's in the energy dashboard, it stays as-is... https://www.home-assistant.io/integrations/integration/

Three solutions..in preference order.

  1. Leave the YAML as it was, and just rename the individual devices (circuits) from the energy dashboard - a feature added in a HA version this year.
    image

  2. Give each of the integration platform sensors a unique_id and then find them in the Entities section and change the name there.

  3. Remove them from the energy dashboard. Completely comment out the YAML, restart Home Assistant and then find and remove the entity. Uncomment the YAML, restart HA, add them back to the energy dashboard. But this option feels a bit nuclear to me.

@lwsrbrts
Copy link

lwsrbrts commented Sep 12, 2024

While I'm here, I've spent some time putting together an add-on for Home Assistant to pull energy usage data from the ECOFLOW HTTP API and publish that data in to sensors in Home Assistant: https://github.com/lwsrbrts/hassio-addons

Development is done on my own terms (read: I may or may not choose to respond to/accept/fix any issues raised). The only thing I'm not certain of is what architectures it actually supports since the add-on is basically Alpine Linux from HA's own base image but with PowerShell installed. All architectures (armhf, armv7, aarch64, amd64, i386) are declared but YMMV. I guess let me know if it doesn't install on a particular architecture.

Anyone is welcome to fork and modify to their own requirements - developing/publishing HA add-ons is actually quicker/simpler than integrations, so that's why I went that route.

I've also spent the week developing the PowerShell add-on, which enables you tun run PowerShell scripts in Home Assistant which I thought was particularly useful.

@dapiet888
Copy link

It's probably a quirk of how the Integral integration works. It's collecting data from a source sensor and applying a Riemann sum integral calculation to it. I suspect it's keeping the original name because that's what was declared when it first started collecting data and if it's in the energy dashboard, it stays as-is... https://www.home-assistant.io/integrations/integration/

Three solutions..in preference order.

  1. Leave the YAML as it was, and just rename the individual devices (circuits) from the energy dashboard - a feature added in a HA version this year.
    image
  2. Give each of the integration platform sensors a unique_id and then find them in the Entities section and change the name there.
  3. Remove them from the energy dashboard. Completely comment out the YAML, restart Home Assistant and then find and remove the entity. Uncomment the YAML, restart HA, add them back to the energy dashboard. But this option feels a bit nuclear to me.

Legend!!! Much appreciated and will stop pestering you now :)

@CyberGWJ
Copy link

@lwsrbrts Thanks for the new powershell add-on. I got it installed and is working fine. Was not aware that Home Assistant could run powershell. Used your original PS script to test retrieving additional items without any issues.

A couple questions.

  1. Can I add more sensors to the powerlshell script i.e. battery charge / discharge - 'backupChaDiscCfg.forceChargeHigh' 'backupChaDiscCfg.discLower'?
  2. Can this be used to update in the future?
  3. Could this possibility replace mqtt completely in the future?

Thanks again!

@lwsrbrts
Copy link

lwsrbrts commented Sep 13, 2024

Was not aware that Home Assistant could run powershell

So, there's 2 add-ons in the repo and my answers might change depending on what add-on you're using so, just for clarity....

So, technically speaking, Home Assistant can't natively run PowerShell, but it can run a docker container (that's all add-ons are!) that can run PowerShell.

My PowerShell add-on adds the ability to run any PowerShell script you like.

My ECOFLOW SHP Energy Usage add-on runs only a single script that talks to the ECOFLOW API to get some data and then to the Home Assistant REST API to create/update a couple of sensors with the data it retrieved from ECOFLOW. So, while it's still technically running PowerShell, its doing the kind of thing a container should be doing - being a one-hit-wonder.

A couple questions.

Sure, just bear in mind I'm answering on the assumption you're using my ECOFLOW SHP Energy Usage add-on...

  1. I would need to add that data request to the add-on's PowerShell script that it runs when it starts and add another couple of options, sensor name etc. I can do that and was considering it already, so I may just do that - shouldn't take too long.
  2. Not sure I follow, update the add-on? If you've installed one of my add-ons and I update it (publish newer code and bump the version number), you'll get a notification to upgrade in Home Assistant and a prompt to install it.
  3. Technically speaking, yes, it could BUT <- big but:
    • It only retrieves data. It has no ability to set anything. Obviously that is possible but it'd need a lot of development and I don't believe PowerShell is the correct language for that - and I'm not advanced in any other. I think it serves best as a method to pull data that's simply not available from their MQTT API (more on why below)
    • If I were adding much more, it'd be far better to just pull everything (there's a way to do that in a single call) from the HTTP API. It would still require the YAML to convert the retrieved data into usable entities/sensors though by templating off that data.
    • The polling frequency would need to be cranked up from 5 minutes to 5 seconds for some data (real-time power usage) to not go stale quickly and that might cheese ECOFLOW off and get your Dev access revoked. What we don't have are any quotas for the APIs and hammering them doesn't seem wise.
    • MQTT automatically receives the real-time data updates we care about without actually polling, so it feels like a better solution and the same connection can be used to set things easily too - and it probably uses less CPU cycles as well.

Hope that helps, I'm happy to chat about it more on the repo if you want to open an "issue" there?

@CyberGWJ
Copy link

@lwsrbrts thanks for all the support on getting this into HA!! All sorted after trial and error:). Managed to get my Grid tied solar automation to charge my DP's via AC when the Fronius hits 1000W :)

Question around the sensor names in the yaml. When i want to view the consumed data per circuit, the ID is "SHP Circuit 2 Consumed Energy" and i cant seem to change this in HA. I tried to update the yaml file like below but it did not update in HA. Am i doing something wrong or is it controlled by the EF API.

From source: sensor.shp_circuit_2_power name: SHP Circuit 2 Consumed Energy unit_prefix: k round: 3

To source: sensor.shp_circuit_2_power name: Kitchen unit_prefix: k round: 3

Screenshot 2024-09-12 at 20 52 11 Screenshot 2024-09-12 at 20 52 28 Screenshot 2024-09-12 at 20 53 06
Much appreciated

@dapiet888 I like the bar chart you did for the circuits. Could you share how you did that. I am new HA so I still have a lot to learn.

Thanks.

@CyberGWJ
Copy link

@dapiet888 nevermind I figured it out.

@Ne0-Hack3r
Copy link

@lwsrbrts

Is the watt hour data the only thing missing for you on the MQTT channel? Have you posted in the API group on FB asking why it is available via HTTP and not MQTT and requesting it be made available on MQTT? I believe this data is posted regularly by the device and is available via MQTT on the mobile app side so it should just be a matter of mapping it over to the API side. Why they did not simply choose to provide a mirror of the MQTT data channel with documentation for developers escapes me. Of course, with the new models (DPU, DP3, etc.) using encoded (protobuf) payloads it is nice to have them map to JSON on the API side. However, It would also have been fine to simply provide documentation of the protobuf structures for those devices.

In any case, it takes the API team months to do what the community can reverse engineer in a couple of weeks so the progression with the API has been slow. But the more people are asking for what we want the better the API will probably be in the long run.

@aflusche
Copy link

@lwsrbrts

Thanks for all your work in figuring out these changes. Is there some way to figure out the solar charging input wattage? We had that data in the older implementation, but now with this public API approach, I can't seem to pull that data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests