Prevent Enphase export with negative prices

I think you have it a bit backwards. The owner is the one with read-only access; it’s the installer and/or maintainer who can control the system.

Did you try the app with that “self-installer owner account”? Did it give you control access?

If not, how exactly are you getting the authentication token from enphase (entrez) to make the api calls to disable/enable the power production?

If my app isn’t giving you control access, but you use the same credentials to do your own api calls to control production, then you might hold the missing piece of puzzle :smiling_face_with_three_hearts:

I do have 2 accounts. First had my own owner account, but wanted to have access to the control settings as well. So as by the Reddit suggestions, I did do all the Enphase university courses and contacted Enphase to give me the self installer access so I could use enlighten manager. However, they won’t provide you anymore because nowadays you can buy it for €300.

After a lot of back and forth, they came with the solution to let me create a new self installer account. Normally you can’t assign a self installer account as a new installer nor maintainer when a site is installed by a company. But Enphase can. The assigned me to my site but then I had read-only access only. After contacting them again, they told me that they would assign my self-installer account whit owner access to the site, after which I finally had all the control rights. All of this very recently :slight_smile:

I did use my self-installer account to sign in to your app, but it tells me i don’t have controll access. For my own usage I do generate the entrez token on my self installer account, as my original account doesn’t give me the wanted rights. I am more than happy to debug some things for you, just tell me what you need!

Not sure if you already checked it, but the HA integration decodes the entrez JWT token to determines the access level. Just checked my own tokens with cyberchef:

owner account:
{
“aud”: “……”,
“iss”: “Entrez”,
“enphaseUser”: “owner”,
“exp”: 1780176465,
“iat”: ……,
“jti”: “………”,
“username”: “…….”
}

Self installer account:
{
“aud”: “…….”,
“iss”: “Entrez”,
“enphaseUser”: “installer”,
“exp”: 1780213074,
“iat”: …..,
“jti”: “……..”,
“username”: “…..”
}

support for IQ charger would be great

This is literally what i’m looking for when pairing the device (“installer” or “maintainer”). If the app says you don’t have controller access, then this is not what the app got back when getting the token.

How exactly are you getting your token?

This is what I am doing:

    const tokenRes = await fetch('https://entrez.enphaseenergy.com/tokens', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        session_id: loginData.session_id,
        serial_num: this.envoySerial,
        username: this.userEmail,
      }),
    });

Yes I’m planning on integrating the charger (and batteries) down the road.

I’m mimicking the original way of getting tokens manually. This is my code:

def get_token(user, password, envoy_serial, site_name):
  session = requests.Session()

  data = {'username': user, 'password': password}
  response = session.post('https://entrez.enphaseenergy.com/login', data=data)

  soup = BeautifulSoup(response.text, "html.parser")
  csrf_input = soup.find("input", {"name": "_csrf"})
  if csrf_input:
    csrf_token = csrf_input.get("value")
  else:
    raise Exception("Login Error")

  data = {'serialNum': envoy_serial, 'Site': site_name, '_csrf': csrf_token}
  response = session.post('https://entrez.enphaseenergy.com/entrez_tokens', data=data)

  soup = BeautifulSoup(response.text, "html.parser")
  token_html = soup.find("textarea", id="JWTToken")
  if token_html:
    token = token_html.text.strip()
  else:
    raise Exception("Token Error")

  return token

Interesting… faking a weblogin, instead of using the api, yields a different JWT… apparently?

I’ll see if i can add this as a parallel method to the existing login flow.

I guess so. Tested your API endpoint, and my token appeared as a owner instead of installer indeed. Not sure, maybe there is an undocumented parameter that can be set for the API endpoint to switch to an installer account, but that’s just guessing.

Thanks for the effort already!

I implemented the scraping method. The app will now get a JWT through both methods and pick the one with control level access.

I need to wait for the certification process to be completed before I can release a new version though.

Installed the app and was able to switch of and off. Within about 20 seconds the full capacity was back. :ok_hand:t3:

A flow to automatically switch on/off gave me an error. But have to look into it more closely.

Regardless, some questions.

  1. The device gives at night often a negative value, while the device of the Enphase inverter app gives 0.

  1. Sometimes the device is unavailable. Any idea what can cause that?

  2. When switching off, does it impact Enphase batteries?

  3. While I am really grateful and happy with this app, it does not fully address the topic of this thread, since Enphase system can still export energy from the batteries if the prices are negative. My intent to mention this is just to share a thought if you intent to work out this app to support Enphase batteries as well.

Thats weird. I’m just showing what the Envoy is reporting. But it might be a good idea to clamp this value to 0 indeed.

Yes, this can have multiple causes. All of them (that i know of) are addressed in the next version. Amongst others, I’m going to drop support for the “envoy.local” hostname, as its not reliable.

We’re not controlling batteries, but the batteries will react to the situation of course, depending on their settings.

Yes I intent to add support for other Enphase products (batteries & charger), but I’m focusing on the PV system first for now.

Without sunlight, the inverters and the IQ gateway are in a sort of standby mode and consume a small amount of energy: approximately 10 watts (the number of inverters affects this value).

Rrrrrrrrrrrrright… @Timelezz must have the Metered gateway that’s measuring the actual production/usage. With me --having unmetered-- it’s just showing what the gateway itself is reporting: 0 at night.

But like i said, i’ll clamp it a minimum of 0 to prevent unwanted readouts.

Hello,

Great app development—everything looks very promising, especially the integrations.

However, I only have an installer account (with access to multiple systems witch i installed), and I am currently unable to control the inverters at my own home. I receive a message stating that I am not an installer.

If I can assist with debugging or testing in any way, please let me know!

Maybe you’d add a fake installer account anyhow

This is fixed for a number of situations in the new version that is now on the public test branch (1.2.1).
Please try the test version and let me know if it works for you!

The previous version (1.1.0) has been accepted by Homey is now officially available!

Dedicated topic: [APP][Pro] Enphase Controller

Please post feedback, suggestions, requests and testresults there. Thanks!

Yes, this one works :+1:t2::flexed_biceps: