[New Binding] Enphase Envoy Solar System gateway

Thanks Hilbrand.
This is my debug output:

2023-07-17 17:07:32.596 [DEBUG] [ternal.handler.EnvoyConnectorWrapper] - Set Envoy version found in the Envoy data: 7.6.175
2023-07-17 17:07:32.599 [DEBUG] [ternal.handler.EnvoyConnectorWrapper] - Envoy version information used to determine actual version: 7.6.175
2023-07-17 17:07:32.600 [INFO ] [ternal.handler.EnvoyConnectorWrapper] - Connect to Envoy based on version number 7.6.175 using entrez connector
2023-07-17 17:07:33.041 [DEBUG] [nternal.handler.EnvoyEntrezConnector] - Failed to login to Envoy. Evoy returned status: 200. Response from Envoy: <!DOCTYPE html><h2>Valid token.</h2>

2023-07-17 17:07:33.042 [DEBUG] [.internal.handler.EnvoyBridgeHandler] - EntrezJwtInvalidException in Enphase thing enphase:envoy:myenvoy:
org.openhab.binding.enphase.internal.exception.EntrezJwtInvalidException: Could not login to Envoy with the access token. Envoy returned status:200
        at org.openhab.binding.enphase.internal.handler.EnvoyEntrezConnector.loginWithJWT(EnvoyEntrezConnector.java:169) ~[?:?]
        at org.openhab.binding.enphase.internal.handler.EnvoyEntrezConnector.getNewSessionId(EnvoyEntrezConnector.java:137) ~[?:?]
        at org.openhab.binding.enphase.internal.handler.EnvoyEntrezConnector.constructRequest(EnvoyEntrezConnector.java:96) ~[?:?]
        at org.openhab.binding.enphase.internal.handler.EnvoyConnector.retrieveData(EnvoyConnector.java:212) ~[?:?]
        at org.openhab.binding.enphase.internal.handler.EnvoyConnector.getProduction(EnvoyConnector.java:159) ~[?:?]
        at org.openhab.binding.enphase.internal.handler.EnvoyBridgeHandler.updateEnvoy(EnvoyBridgeHandler.java:334) ~[?:?]
        at org.openhab.binding.enphase.internal.handler.EnvoyBridgeHandler.updateData(EnvoyBridgeHandler.java:264) ~[?:?]
        at org.openhab.binding.enphase.internal.handler.EnvoyBridgeHandler.lambda$2(EnvoyBridgeHandler.java:161) ~[?:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
        at java.lang.Thread.run(Thread.java:829) [?:?]

From the message ‘Valid Token’ I would conclude that the token is valid, but the response misinterpreted?

It looks like the cookie to get the jwt from was renamed on the enphase portal. I’ve updated the binding. It should now be able to read the jwt again. See [New Binding] Enphase Envoy Solar System gateway - #94 by hilbrand with link to the download.

Hi Hilbrand,
thank you for the update. However, I get the following error when I try to install the new version:

FrameworkEvent ERROR
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.enphase [313]
  Unresolved requirement: Import-Package: org.jsoup; version="[1.15.0,2.0.0)"

I am on OH 4.0.2

Doh!. I messed up the jsoup dependency. For building the jar I need to modify the build steps a bit to include the jsoup, but these changes should not be in the pr. So I switching back and forth between these changes to also make sure the pull request is correct. Seems I make a mistake with building the jar. Anyway. I’ve updated the jar. It should now not complain about jsoup anymore.

Thanks Hilbrand for the quick reaction. Indeed no more complaints about a missing dependency. But I still cannot get it running. With Auto JWT I get:

2023-08-20 20:25:26.614 [DEBUG] [ternal.handler.EnvoyConnectorWrapper] - Set Envoy version found in the Envoy data: 7.6.172
2023-08-20 20:25:26.614 [TRACE] [.internal.handler.EnvoyBridgeHandler] - Check connection
2023-08-20 20:25:26.614 [DEBUG] [ternal.handler.EnvoyConnectorWrapper] - Envoy version information used to determine actual version: 7.6.172
2023-08-20 20:25:26.614 [INFO ] [ternal.handler.EnvoyConnectorWrapper] - Connect to Envoy based on version number 7.6.172 using entrez connector
2023-08-20 20:25:26.614 [TRACE] [.internal.handler.EnvoyBridgeHandler] - No configuration error
2023-08-20 20:25:26.615 [TRACE] [ase.internal.handler.EntrezConnector] - Retrieving session id from 'https://entrez.enphaseenergy.com/login'
2023-08-20 20:25:27.205 [TRACE] [ase.internal.handler.EntrezConnector] - Retrieving jwt from 'https://entrez.enphaseenergy.com/entrez_tokens'
2023-08-20 20:25:27.518 [DEBUG] [nternal.handler.EnvoyEntrezConnector] - Failed to find cookie with the JWT token from the Enphase portal. Maybe Enphase changed the website.
2023-08-20 20:25:27.518 [DEBUG] [.internal.handler.EnvoyBridgeHandler] - EntrezJwtInvalidException in Enphase thing enphase:envoy:enphase:
org.openhab.binding.enphase.internal.exception.EntrezJwtInvalidException: Unable to obtain jwt key from Ephase website. Manully configuring the JWT might make it work. Please report this issue.
        at org.openhab.binding.enphase.internal.handler.EnvoyEntrezConnector.loginWithJWT(EnvoyEntrezConnector.java:173) ~[?:?]
        at org.openhab.binding.enphase.internal.handler.EnvoyEntrezConnector.getNewSessionId(EnvoyEntrezConnector.java:139) ~[?:?]
        at org.openhab.binding.enphase.internal.handler.EnvoyEntrezConnector.constructRequest(EnvoyEntrezConnector.java:98) ~[?:?]
        at org.openhab.binding.enphase.internal.handler.EnvoyConnector.retrieveData(EnvoyConnector.java:212) ~[?:?]
        at org.openhab.binding.enphase.internal.handler.EnvoyConnector.getProduction(EnvoyConnector.java:159) ~[?:?]
        at org.openhab.binding.enphase.internal.handler.EnvoyBridgeHandler.updateEnvoy(EnvoyBridgeHandler.java:334) ~[?:?]
        at org.openhab.binding.enphase.internal.handler.EnvoyBridgeHandler.updateData(EnvoyBridgeHandler.java:264) ~[?:?]
        at org.openhab.binding.enphase.internal.handler.EnvoyBridgeHandler.lambda$2(EnvoyBridgeHandler.java:161) ~[?:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?]
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) ~[?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]

And with Auto JWT set to OFF, using the token I get:

2023-08-20 20:21:52.035 [DEBUG] [ternal.handler.EnvoyConnectorWrapper] - Set Envoy version found in the Envoy data: 7.6.172
2023-08-20 20:21:52.035 [TRACE] [.internal.handler.EnvoyBridgeHandler] - Check connection
2023-08-20 20:21:52.035 [DEBUG] [ternal.handler.EnvoyConnectorWrapper] - Envoy version information used to determine actual version: 7.6.172
2023-08-20 20:21:52.036 [INFO ] [ternal.handler.EnvoyConnectorWrapper] - Connect to Envoy based on version number 7.6.172 using entrez connector
2023-08-20 20:21:52.036 [TRACE] [.internal.handler.EnvoyBridgeHandler] - No configuration error
2023-08-20 20:21:52.051 [DEBUG] [nternal.handler.EnvoyEntrezConnector] - Failed to login to Envoy. Evoy returned status: 200. Response from Envoy: <!DOCTYPE html><h2>Valid token.</h2>

2023-08-20 20:21:52.051 [DEBUG] [.internal.handler.EnvoyBridgeHandler] - EntrezJwtInvalidException in Enphase thing enphase:envoy:enphase:
org.openhab.binding.enphase.internal.exception.EntrezJwtInvalidException: Could not login to Envoy with the access token. Envoy returned status:200
        at org.openhab.binding.enphase.internal.handler.EnvoyEntrezConnector.loginWithJWT(EnvoyEntrezConnector.java:178) ~[?:?]
        at org.openhab.binding.enphase.internal.handler.EnvoyEntrezConnector.getNewSessionId(EnvoyEntrezConnector.java:139) ~[?:?]
        at org.openhab.binding.enphase.internal.handler.EnvoyEntrezConnector.constructRequest(EnvoyEntrezConnector.java:98) ~[?:?]
        at org.openhab.binding.enphase.internal.handler.EnvoyConnector.retrieveData(EnvoyConnector.java:212) ~[?:?]
        at org.openhab.binding.enphase.internal.handler.EnvoyConnector.getProduction(EnvoyConnector.java:159) ~[?:?]
        at org.openhab.binding.enphase.internal.handler.EnvoyBridgeHandler.updateEnvoy(EnvoyBridgeHandler.java:334) ~[?:?]
        at org.openhab.binding.enphase.internal.handler.EnvoyBridgeHandler.updateData(EnvoyBridgeHandler.java:264) ~[?:?]
        at org.openhab.binding.enphase.internal.handler.EnvoyBridgeHandler.lambda$2(EnvoyBridgeHandler.java:161) ~[?:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?]
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) ~[?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]

I have re-created the envoy bridge thing, turned bundle OFF and ON, without success.
I am now back to the previous version (19-05-2023), with Token (Auto JWT turned off). This is working fine for me.

Ok. New try. I’ve updated the jar file (23-08-2023) with a fix for getting the cookie.

1 Like

This version works for me, with Envoy Softwareversie 7.6.172
I recreated the bridge thing, and had to restart openhab
Thanks for the effort

later i noticed that the evoy channels are missing, in the the latest version


i went back to the 19-05-2023 version

It should not be needed to recreate the bridge and restart openHAB. It should pick it up automatically.

I also tested it with the official version, created the bridge, added items to channels, uninstalled the binding, put the new jar in the addons folder. This resulted in the bridge automatically setting the thing online, and linking the channels. Therefor I’m not sure what goes wrong in your case.

I have deleted the envoy bridge thing again.
Changed the jar file in the addons directory to version 23-8-2023 version.
Recreated the envoy bridge thing again, an now the channels are presant.
So i don’t know what went wrong the previous attemt.

1 Like

Thanks Hilbrand! This version is also now working for me with Auto JWT.

1 Like

Hello,

first of all a big thank you for the binding. The version 23-8-2023 works great.
However, I have a feature request. So far, I can only retrieve the values for production and consumption. The values of the battery do not go with the binding. Is that possible via the local api or is that not possible? Would be nice if the battery values could also be retrieved.

Hi @hilbrand ,

Thanks for your great work. Your updated binding works well, as several other people also confirmed earlier. The enphase addon version in the current OH release will not work for a growing number of people, since Enphase is shipping/upgrading installations to firmware R7. It would be great to get the JWT compatibility in the release version of OpenHAB, so that no manual jar install is required anymore.

When are your changes expected to be integrated in the main tree / what is the delay there? You mentioned a PR against OH4, where can we see the progress on this PR?

Thanks again!

There seems to be some information available via local api http://<local ip enphase>/production.json. But I don’t know if that is any useful information.

The PR has already been merged and the binding is available since milestone version 4.1.0.M2

1 Like

Ah, missed that. Great news, thanks!

@hilbrand thanks for the work on this binding.
I have an old envoy-R, running software version R3.17.3. I am running OpenHAB 4.1.0.M3 as of last nightt. OpenHAB is no longer able to connect to the envoy, giving me the error:

2023-11-27 10:44:09.453 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'enphase:envoy:X' changed from OFFLINE (COMMUNICATION_ERROR): No connection could be made with the Envoy. Check your connection/hostname. to UNKNOWN
2023-11-27 10:44:09.533 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'enphase:envoy:X' changed from UNKNOWN to OFFLINE (COMMUNICATION_ERROR): No connection could be made with the Envoy. Check your connection/hostname.

The envoy is configured by IP address, not hostname, and it has not changed. I am still able to get to the envoy with a web browser. Any ideas how to debug this?

Turned DEBUG on:

2023-11-27 10:54:18.192 [DEBUG] [hase.internal.handler.EnvoyConnector] - Check connection to 'envoy/info.xml'
2023-11-27 10:54:18.332 [DEBUG] [hase.internal.handler.EnvoyConnector] - Checkconnection status from request is: 200
2023-11-27 10:54:18.333 [DEBUG] [hase.internal.handler.EnvoyConnector] - Check connection to 'envoy/info.xml'
2023-11-27 10:54:18.339 [DEBUG] [hase.internal.handler.EnvoyConnector] - ExecutionException: java.net.ConnectException: Connection refused

in a browser, the info.xml redirects to a 404.

I’m using OH 4.1. My python script stopped working due to requiring authentication, so I decided to try this binding. I have it set up and it goes online with no errors, but the production data is always reported as zero. Any idea why this might be happening? The inverter data looks okay.

Software version: D7.3.130 (91f206)

Here’s the production data from a TRACE log:

2024-02-22 16:02:17.016 [TRACE] [.internal.handler.EnvoyBridgeHandler] - Check connection
2024-02-22 16:02:17.468 [DEBUG] [nternal.handler.EnvoyEntrezConnector] - Home Response: <!DOCTYPE html><h2>Valid token.</h2>

2024-02-22 16:02:17.469 [TRACE] [nternal.handler.EnvoyEntrezConnector] - Retrieving data from 'https://192.168.86.210/api/v1/production' with sessionID 'xxx'
2024-02-22 16:02:17.485 [TRACE] [hase.internal.handler.EnvoyConnector] - Envoy returned data for '/api/v1/production' with status 200: {
  "wattHoursToday": 0,
  "wattHoursSevenDays": 0,
  "wattHoursLifetime": 0,
  "wattsNow": 0
}

Inverter data as a comparison:

2024-02-22 16:02:17.569 [TRACE] [hase.internal.handler.EnvoyConnector] - Envoy returned data for '/api/v1/production/inverters' with status 200: [
  {
    "serialNumber": "121715021260",
    "lastReportDate": 1708646503,
    "devType": 1,
    "lastReportWatts": 72,
    "maxReportWatts": 244
  },

I see from https://support.enphase.com/s/question/0D53m00009INBskCAH/local-api-return-0-for-wh-counters-for-production-after-new-firmware-update that we might need to use

http://IP/ivp/pdm/generation

instead of the current api/v1/production

opened an issue for this: [Enphase Binding] Reports 0 for all power/energy production values · Issue #16448 · openhab/openhab-addons · GitHub

@hilbrand would you have any suggestions or comments on this issue of the new location of the data in the Enphase? Thanks.