[RELEASE] New Enphase Envoy driver supports token based authentication

Hey fellas,

I just got my Hubitat C-7 and wanted to connect to my Enphase Envoy-S (monitored). But my firmware version is new, I was unable to use the driver provided in this forum.

Since the above driver still works with the most of the Envoy devices, I wanted to create a simple driver that works with Envoy devices with new firmware.

This driver simply can fetch the solar production data (now, day, 7-days and lifetime).
UPDATE : consumption data also available now [Major upgrade. Check for broken rules]

Driver (suggestions & feedbacks are welcome ) :

Please note, this driver is NOT working with any monitoring apps.

P. S. : I'm not a developer by profession. So my code might be ugly :face_with_peeking_eye: . But it'll work for sure :sunglasses:.

1 Like
  • Complience with dashboards, monitoring apps, rules, etc
  • Auto polling the status
  • Added a feature to get upto date about the new updates ( update information )
  • Started using state variables instead of attributes ( Still in migration version, So JWT token is still visible in both states variables and attributes )
  • Handled some error situations
  • Consumption also now available

I’m waiting for my enphase system to get installed hopefully before the end of this year. Can you tell me a little bit about what this driver does and what you’re doing in hubitat with your PV installation?


This driver can fetch the data (current production, today's production, past 7 days production and lifetime production ) from your Envoy.

Mortivation :
There's a better (and matured) driver I've mentioned in my OP but it didn't work with new Enphase Envoy firmware. So, I wrote a new once which works with new firmware.

Usage :
I'm using this data to trigger my car charger to charge the car when the production exceeding 2kw.

Not only that, you can write more rules based on your current production and daily production.

And I believe this driver also will work with the dashboard app created in the other thread I've mentioned. I'll give it a try and confirm.

I was so happy to see that someone with skills greater than mine was working on a solution to this new token setup.

I tried this out but can't seem to get into work.

Any ideas?

Also, just curious. Have you thought about using the free api instead of a local solution?

I cannot help you on this without looking at your driver code. You can test your token by providing it to the local web API. Additionally, you can add anothe function to validate the token ( you can refer my code block to get an idea on this ).

I didn't want to connect to the cloud API as I wanted everything to be executed locally (faster and free )

Happy coding :slight_smile:

I copied and pasted token from within device driver into local login and it worked fine. Maybe my enphase setup is a bit different? It's an envoy with software version D7.0.155 (9ec009). I'm not at all a coder, wish I was. But I can definitely try to send whatever code you might need. Your help is much appreciated.

I think I misunderstood your message. Are you using my driver here ? My version is D7.0.88. May be the've changed something in your device. But I can help on this.
Do you have postman app installed ?

No postman app. I will install though.

I can't tell for sure, @vpsupun, but I think you are using Enphase API v2? That is being depreciated in January and replaced with v4:

I haven't gone too far down the rabbit hole yet, but it looks like it is going to use a call method like OpenWeatherMap. In other words, you will have to sign up for a developer account on Enphase's website, get an unique API key that must be used for pull requests, use that to get data back, and limit the number of pulls to make sure it does not exceed the free plan limits.

Hi @Dogma_Woof ,
No I'm using the new API (local) by obtaining the token from https://entrez.enphaseenergy.com/tokens and using it for quering the local REST API.
it works perfectly to me with new firmaware. The benefit of this method is, it doesn't have any query limitations like cloud API.

Let me know once you have installed it. Let's do some testings why it's not working for you. It seems like your local API query for token validation is receiving a bad response.

If you're getting a valid token, please use the postman as follows.

open a new tab.
Request type : Get
URL : https://<your_enphase_envoy_IP>/auth/check_jwt
Click "Autherization" tab -> select Type "Bearer Token" -> Paste your token in the "Token" box
Click "Send"
You should recieve the response as <!DOCTYPE html><h2>Valid token.</h2>

I have the same error as mobstaj and can confirm I receive a valid token response via postman.

Thanks for the reply.
Could you please try diagnosis steps mentioned above ?

Apologies, which diagnosis steps? I was able to validate the token in postman, but receive the same error as the previous poster.

These steps.

Yes, those are the steps I've done and I receive the response you've noted. However, I still have the same error listed by the earlier user.

This issue is with the token header. The authorization type is incorrect--it should be Bearer, not Basic. It's strange that it worked in the first place.

All instances of :

Map<String> headers = [
    "Authorization": "Basic " + token

Need to be replaced with:

Map<String> headers = [
    'Authorization': 'Bearer ' + token

Thanks @augoisms - even with those updates I'm still getting the following error:

2023-01-04 10:30:27.893 AM java.lang.NullPointerException: Cannot invoke method contains() on null object on line 140 (method poll)

2023-01-04 10:30:27.882 AM HTTP get failed: status code: 401, reason phrase: Unauthorized

@user3923 Hmmm. I had the same error before and the root cause was the authorization header, but now I can't remember if I changed anything else. Here is my code if you want to give it a try

hubitat/enphase-envoy.driver.groovy at master · augoisms/hubitat · GitHub