Enphase Envoy - Current state of things

Im trying to get the sample request to work, but I dont know the format for my Envoy Serial number…can any one guide me?

The EnPhase site says:

curl --location -g --request GET 'https://api.enphaseenergy.com/api/v4/systems/{system_id}/summary?key=4a6580c04b9e6282058df02d6454e659' \
--header 'Authorization: Bearer unique_access_token'
</pre>
curl --location -g --request GET 'https://api.enphaseenergy.com/api/v4/systems/121732007xxx/summary?key=ab56932686997d0fca5e67e345789540' \
--header 'Authorization: Bearer eytesting123NiJ9.eyJhcHBfdHlwZSI6InN5c3RlbSIsInVzZXJfbmFtZSI6ImNocmlzdG9waGVyX2FuZ3VzQGhvdG1haWwuY29tIiwiZW5sX2NpZCI6IiIsImVubF9wYXNzd29yZF9sYXN0X2NoYW5nZWQiOiIxNTgzMzEzMDU2IiwiYXV0aG9yaXRpZXMiOlsiUk9MRV9VU0VSIl0sImNsaWVudF9pZCI6IjQ3ZjEyNThmZmRjMjA1NzhmZTI5M2Q2MTQ0MGRmZDE1IiwiYXVkIjpbIm9hdXRoMi1yZXNvdXJjZSJdLCJpc19pbnRlcm5hbF9hcHAiOmZhbHNlLCJzY29wZSI6WyJyZWFkIiwid3JpdGUiXSwiYXRpIjoiYjg3NGM1MTctNjI5OC00MDc5LWFmZTUtMmNlNGMyM2IwN2JlIiwiZXhwIjoxNjc0ODA0NDc3LCJlbmxfdWlkIjoiMTk0MTc3MyIsImp0aSI6IjUzN2M3OTc3LWIyM2QtNDc5OC04YTU3LWFmMmMyN2FmN2UzYSJ9.KUaeZ1jGYxzV1_insvDbZWGvpgju_CO1_PkxKYr6a7YS6p_Efxe4fcIDOurGETcYOtVZgwhi1pUrN0RBlbfDTM41qQmdx7O1LP9KuForFiY_fU8OGznilJ8M3MjARdq85n49gp51re0KHYh1uEp-WAsvZDpmdWMEfxacaxSXaXE'
</pre>

The cURL output error is:

{
    "message": "Not Found",
    "details": "System not found for {:id=>\"121732007xxx\"}",
    "code": 404
}

You are attempting to get data from the internet via enphase cloud which is updated every 15 mins at best which is how often the envoy uploads its data to enphase cloud. This enphase cloud service also has a limit of how many queries you can make for free.

This discussion is mostly focussed on getting data directly from the envoy on the local area network every minute or less.

Hi @del13r

Yes I’m trying to access the EnPhase cloud service. Let me explain… I have one HA instance running at my home and that has the main solar system installed. Everything works well with the standard EnPhase integration. However, I have a second EnPhase system installed at another location together with a battery system. I want to get data from that second system to be able to monitor consumption and Production for some basic battery charging automatons (15 minute data is fine), but as it’s not on the same home network I haven’t been able to connect it in to my HA using its gateway number. So I’m trying to access the second system using the cloud API. (I have both EnPhase systems registered under my single EnPhase account such they are both selectable as independent systems in Enlighten).
I came across this thread in my search for how to access the EnPhase cloud service. I managed to get as far as generating the client ID, API and Access token. But I can’t pass the final quiry to get the system data. The command line cURL requires the system identity number “{system_id}” but the EnPhase number doesn’t pass…
I was going for some guidance on the structure of the system id format to enter in to the cURL.

SOLUTION: OK I figured it out… ‘systemid’ is actually the site ID and not the Envoy id.

@del13r

I know that you are good at these things, are you able to guide me to get the data from my REST:

If I run this cURL on the reqbin.com

curl --location -g --request GET 'https://api.enphaseenergy.com/api/v4/systems/3793806/summary?key=TESTING123997d0fca5e67e412438110' \
--header 'Authorization: Bearer eyTESTING123NiJ9.eyJhcHBfdHlwZSI6InN5c3RlbSIsInVzZXJfbmFtZSI6ImNocmlzdG9waGVyX2FuZ3VzQGhvdG1haWwuY29tIiwiZW5sX2NpZCI6IiIsImVubF9wYXNzd29yZF9sYXN0X2NoYW5nZWQiOiIxNTgzMzEzMDU2IiwiYXV0aG9yaXRpZXMiOlsiUk9MRV9VU0VSIl0sImNsaWVudF9pZCI6IjQ3ZjEyNThmZmRjMjA1NzhmZTI5M2Q2MTQ0MGRmZDE1IiwiYXVkIjpbIm9hdXRoMi1yZXNvdXJjZSJdLCJpc19pbnRlcm5hbF9hcHAiOmZhbHNlLCJzY29wZSI6WyJyZWFkIiwid3JpdGUiXSwiYXRpIjoiYjg3NGM1MTctNjI5OC00MDc5LWFmZTUtMmNlNGMyM2IwN2JlIiwiZXhwIjoxNjc0ODA0NDc3LCJlbmxfdWlkIjoiMTk0MTc3MyIsImp0aSI6IjUzN2M3OTc3LWIyM2QtNDc5OC04YTU3LWFmMmMyN2FmN2UzYSJ9.KUaeZ1jGYxzV1_insvDbZWGvpgju_CO1_PkxKYr6a7YS6p_Efxe4fcIDOurGETcYOtVZgwhi1pUrN0RBlbfDTM41qQmdx7O1LP9KuForFiY_fU8OGznilJ8M3MjARdq85n49gp51re0KHYh1uEp-WAsvZDpmdWMEfxacaxSXaXE'
</pre>

The output from EnPhase is:

{
    "system_id": 3793702,
    "current_power": 0,
    "energy_lifetime": 943,
    "energy_today": 8,
    "last_interval_end_at": 1672206300,
    "last_report_at": 1672207041,
    "modules": 0,
    "operational_at": 1671720300,
    "size_w": 0,
    "source": "meter",
    "status": "normal",
    "summary_date": "2022-12-28"
}

here is my REST and the sensors:

rest:
  - resource: https://api.enphaseenergy.com/api/v4/systems/3793806/summary?key=TESTING123997d0fca5e67e412438110
    method: POST
    scan_interval: 900 #EnPhase only get data every 15 min.
    headers:
      Authorization: Bearer eyTESTING123NiJ9.eyJhcHBfdHlwZSI6InN5c3RlbSIsInVzZXJfbmFtZSI6ImNocmlzdG9waGVyX2FuZ3VzQGhvdG1haWwuY29tIiwiZW5sX2NpZCI6IiIsImVubF9wYXNzd29yZF9sYXN0X2NoYW5nZWQiOiIxNTgzMzEzMDU2IiwiYXV0aG9yaXRpZXMiOlsiUk9MRV9VU0VSIl0sImNsaWVudF9pZCI6IjQ3ZjEyNThmZmRjMjA1NzhmZTI5M2Q2MTQ0MGRmZDE1IiwiYXVkIjpbIm9hdXRoMi1yZXNvdXJjZSJdLCJpc19pbnRlcm5hbF9hcHAiOmZhbHNlLCJzY29wZSI6WyJyZWFkIiwid3JpdGUiXSwiYXRpIjoiYjg3NGM1MTctNjI5OC00MDc5LWFmZTUtMmNlNGMyM2IwN2JlIiwiZXhwIjoxNjc0ODA0NDc3LCJlbmxfdWlkIjoiMTk0MTc3MyIsImp0aSI6IjUzN2M3OTc3LWIyM2QtNDc5OC04YTU3LWFmMmMyN2FmN2UzYSJ9.KUaeZ1jGYxzV1_insvDbZWGvpgju_CO1_PkxKYr6a7YS6p_Efxe4fcIDOurGETcYOtVZgwhi1pUrN0RBlbfDTM41qQmdx7O1LP9KuForFiY_fU8OGznilJ8M3MjARdq85n49gp51re0KHYh1uEp-WAsvZDpmdWMEfxacaxSXaXE'
      Content-Type: application/json

Sensors:

    sensor:
    - name : "Ustou EnPhase system_id"
      value_template: >
        {%- for dict_item in value_json.dataList -%}
            {%- if dict_item.key == "system_id"-%} 
              {{dict_item.value}} 
            {%- endif -%}
        {%- endfor -%}
      
    - name : "Ustou EnPhase Current Consumption Wh"
      value_template: >
        {%- for dict_item in value_json.dataList -%}
          {%- if dict_item.key == "current_power"-%} 
            {{dict_item.value}} 
          {%- endif -%}
        {%- endfor -%}
      unit_of_measurement: 'Wh'
      device_class: energy
      
    - name : "Ustou EnPhase Energy Produced lifetime Wh"
      value_template: >
        {%- for dict_item in value_json.dataList -%}
          {%- if dict_item.key == "energy_lifetime"-%} 
            {{dict_item.value}} 
          {%- endif -%}
        {%- endfor -%}
      unit_of_measurement: 'Wh'
      device_class: energy
    
    - name : "Ustou EnPhase Solar Production Today Wh"
      value_template: >
        {%- for dict_item in value_json.dataList -%}
          {%- if dict_item.key == "energy_today"-%} 
            {{dict_item.value}} 
          {%- endif -%}
        {%- endfor -%}
      unit_of_measurement: 'kWh'
      device_class: energy
      
    - name : "Ustou EnPhase Number of Inverters"
      value_template: >
        {%- for dict_item in value_json.dataList -%}
          {%- if dict_item.key == "modules"-%} 
            {{dict_item.value}} 
          {%- endif -%}
        {%- endfor -%}

    
    - name : "Ustou EnPhase Total Array Size (W)"
      value_template: >
        {%- for dict_item in value_json.dataList -%}
          {%- if dict_item.key == "size_w"-%} 
            {{dict_item.value}} 
          {%- endif -%}
        {%- endfor -%}


    - name : "Ustou EnPhase System Status"
      value_template: >
        {%- for dict_item in value_json.dataList -%}
          {%- if dict_item.key == "status"-%} 
            {{dict_item.value}} 
          {%- endif -%}
        {%- endfor -%}

After a HA Restart I see the new sensors but there is no data:

My EnvoyS with Firmware R4.10.35 using the integration from GitHub - briancmpbll/home_assistant_custom_envoy succeeds installing but ends up in the Installing/Retrying loop and is getting the error below.
I’ve used the envoy IP, username: envoy, blank password and the envoy serial number.


Logger: custom_components.enphase_envoy
Source: custom_components/enphase_envoy/envoy_reader.py:730
Integration: Enphase Envoy (DEV)
First occurred: 1:20:33 PM (16 occurrences)
Last logged: 1:37:37 PM

Unexpected error fetching envoy Envoy [SERIAL] data: 0
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 225, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 181, in _async_update_data
    return await self.update_method()
  File "/config/custom_components/enphase_envoy/__init__.py", line 62, in async_update_data
    battery_data = await envoy_reader.battery_storage()
  File "/config/custom_components/enphase_envoy/envoy_reader.py", line 730, in battery_storage
    if len(ensemble_json) > 0 and "devices" in ensemble_json[0].keys():
KeyError: 0

The ensemble API isn’t available on your firmware version. Please try my version of the plugin GitHub - posixx/home_assistant_custom_envoy

1 Like

Hi All,

It seems a lot of involved people are watching this threat, however I need some help with a new installation:

The Enphase Envoy-S has the following firmware:

<envoy_info>
  <device>
    <software>D7.0.88</software>
    <apiver>1</apiver>
  </device>

One of the things I noticed is that the webserver always performs a HTTP redirect to HTTPS on any request. As the certificate is self-signed, I added this webserver certificate to both the docker-container running H.A., as on the hosts certificate store. From now I can successfully perform HTTPS requests:

* Server certificate:
*  subject: CN=envoy-XXXXXXXXXXXX
*  start date: Nov  9 08:46:36 2022 GMT
*  expire date: Nov  9 08:46:36 2023 GMT
*  common name: envoy-XXXXXXXXXXXX (matched)
*  issuer: CN=envoy-XXXXXXXXXXXX
*  SSL certificate verify ok.

Now when using the ‘DEV’ integration to add the gateway into H.A., I am getting the following error, and from the container log I can see the queries performed are only HTTP, and not HTTPS as the redirect is not followed and stuck in this loop (envoy-XXXXXXXXXX is the hostname resolvable from within the container):

2023-01-12 16:57:16.798 DEBUG (MainThread) [custom_components.enphase_envoy.envoy_reader] HTTP GET Attempt #1: http://envoy-XXXXXXXXXXX/api/v1/production: Header:None
2023-01-12 16:57:16.813 DEBUG (MainThread) [custom_components.enphase_envoy.envoy_reader] Fetched from http://envoy-XXXXXXXXXXXX/api/v1/production: <Response [301 Moved Permanently]>: <html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>openresty/1.17.8.1</center>
</body>
</html>

Questions:

  • Am I on the right track with this DEV integration for this specific device?
  • I am unable to report an ‘ISSUE’ on the GitHub page. How to approach the maintainer?

I have this same question…
Which github repo should we be using until this is pushed into core HASS?

Probably this one? posixx/home_assistant_custom_envoy (github.com)

I am also watching this thread, hoping to get some clues to integrate Enphase Envoy S, getting installed this week.

If this work with both fw5 and 7, why is this not the official plugin? Would prefer the native HA one vs a HACS version. Hopefully this replaces the current integration soon!

so here are all of the githubs I know of… (I ended up going with the first on one the list)

REF: Issues · briancmpbll/home_assistant_custom_envoy · GitHub
REF: GitHub - DanBeard/enphase_envoy: Custom component for enphase_envoy Firmware D7.0.0 +
REF: GitHub - jrutski/home_assistant_envoy_d7_fw: Update for D7 based firmware on Envoy gateways
REF: GitHub - posixx/home_assistant_custom_envoy

Kinda makes it a mess in my opinion when there are 4 paths available… can only imagine the issues this presents for troubleshooting. I hope one of these are pulled in as the source of truth to HA.

4 Likes

I successfully integrated the Enphase Envoy (DEV), which entity should I use for the Energy Dashboard?

Is it Envoy xxxxxxxxxx Lifetime Energy Production ?

@jrutski can you help?

I mostly use enphase as a background service and pull certain stats into other cards or the energy dashboard…

mushroom card
image

clicking the card above navigates me to a “Solar” page that has more info like…

also created a card to help predict the electric bill

@fireheadman how do you integrate to the energy dashboard?

Which sensors do you use?

If you are using template.sensors or helpers, how do you set it up?

Please help me. I got my Enphase connected to HA, and I saw lots sensors.

:pray:

This link explains how to setup enphase with energy dashboard. Enphase Envoy with Energy Dashboard

1 Like

Thanks @del13r , I read your guide. But, unfortunately, due to the D7.* firmware, I have to use the Enphase Envoy (DEV) integration from this forum thread. And the “today_s_energy” always 0.

I then convert the sensor.envoy_XXXX_current_power_production to kWh using Riemann Sum helper GUI. And I use this for the Energy Dashboard. It looks it works, at least it has the same value compared to the Enphase Enlighten mobile app (slightly different because Enphase app only has 1 decimal). I hope this is the correct way to get the solar production.

And for the Grid Import and Export, I use the reading from P1 meter connected to the smart meter. I think, this is the way if we have smart meter with P1 port. The reading should have been calculated with the solar panel production. Again, this is my understanding.

Gosh! What a very confusing to setup. I setup Home Assistant mainly for this Energy Dashboard, but it turned out super difficult, with non-working integration, limited documentation. I should not complain, I know. The devs have done very good job, but one of “core” functionality of HA is for this energy monitoring/management, and it is bad. /rant

2 Likes

Is there any idea why the official integration has not yet been updated to support the latest fw? My envoy was just updated and now cannot get it to login. Would much prefer the official Integration to avoid unnecessary churn, but if it isn’t going to be updated for a while will need to look at what options are available.

I did some digging around in GitHub to try and answer this question. Here is what I found.

Let’s start with who is the code owner for the enphase_envoy integration?

According to that list, the owner is

This is the most likely corresponding user in this forum

If we dig a little deeper into GitHub, we can see that the code owner for the enphase_envoy integration has most recently made some commits to another relevant code repository.

I think the common misconception is that just because an integration is “official”, doesn’t automatically mean that the manufacturer was involved or contributed at all. Most of home assistant is community contributions and I would expect no different here.

If I was on v7 firmware, (which I am not so I can’t help test unfortunately) I would have to assume that the jesserizzo repository is being used as the beta for the official integration. This assumption is based solely on the contributions of the official enphase integration code owner.

Maybe if I mention @gregtd, they can comment themselves on the current status.

1 Like

I restarted HA, and suddenly the Enphase integration didn’t work.
I deleted it, restarted HA.

And it failed to connect. How to debug this? My Enphase Enlighten App is working fine.

image

[SOLVED] For whatever reason, the Envoy didn’t connect to WiFi. You can see the WiFi connection status light was red, like this:

image

The Enlighten app received the last report from Envoy was 2 hours ago. I didn’t know how to restart it. I found how to enable AP-mode, to re-configure WiFi, but I didn’t want to do that.

Then, out of sudden, that red-light turned green!

Then I went to HA, re-add the integration. Success! All went fine, all data were still there. Let’s see tomorrow :smiley:

1 Like

Pretty much all of the many different forks/repository choices will be named (DEV) so they won’t get confused with the official integration.

Can I ask what the exact version and url of the repository you are using is so we can all be on the same page here?

Also, can I ask what your decision process was that led you to choosing that specific repo and version?

Example answers that can influence repo choices instead of using the official integration:

  • I have batteries and want to do X with them.
  • I am on version 4.x or 5.x or 7.x.
  • I am on v7.x and am having token trouble.
  • I have 2 independent envoys with different versions.

For example, if I was asking for help, I would visit http://envoy.local/home and grab the following information.

  • Part Number 800-00654-r06
  • Software Version D5.0.62 (5e57a9)

Then I would go to HACS (or whatever method you are using to load unofficial integrations) and go to integrations and click on the integration and then tap the 3 dots and click repository which is how you get the url.