[SOLVED] Enphase Battery: Charge and discharge entities

So if I understand it correctly, you can trigger them manually and the settings have effect in the Envoy? But the issues is you can’t schedule them?

Yes, that’s an unfortunate fact. ( HA issue 123216 ) Haven’t found solutions yet.

Correct, I can trigger them manually in the app UI, but not using the scheduled option in HA.

Does that sound about right and perhaps a bug, or is there something wrong with my setup?

Ah I see, from the app it works, but not from HA. If you are on Envoy firmware 8.2.24xx or newer that this is expected. Starting with that firmware the Envoy has changed behavior that ignores these methods that used to work in older versions. :sob:

Still in search for alternatives, but little progress. Enphase is still “not really embracing” open-home.

1 Like

Thanks @catsmanac – I raised a ticket to Enphase regarding this (a while ago) and today they’ve come back with:

regarding the ability to control charging and discharging via API using Home Assistant.

At this time, we do not have this feature available in the UK. However, I will make sure to add it to our list of future feature requests and inform my team.

Thank you for your understanding!

Oh well!

Thanks for sharing, @phillll
So this basically means that manual charging will not be available soon even if the AI is already using it in the UK.
That’s bad news also for the rest of Europe.
:tired_face:

1 Like

Hi all, I recently got an enphase system and batteries and was disappointed to learn that the home assistant integration doesn’t work in the UK. I have managed to make this work via using Restful commands. I know it’s not quite using the local api, but it may still be useful for automations for some.

  1. Capture Needed Info from the Web App
    1. Go to the Enphase Web App (e.g., https://enlighten.enphaseenergy.com/) and log in.
    2. Open Chrome DevTools (right-click → Inspect → Network tab).
    3. Go to the battery settling where the Toggle setting is located (e.g., “Charge from Grid”) so the web app sends the request.
    4. In Network clear the current data then toggle the battery to charge
      5. find the request URL like:

https://enlighten.enphaseenergy.com/service/batteryConfig/api/v1/batterySettings/<BATTERY_ID>?userId=<USER_ID>

6.	Extract from the headers/body:
•	<BATTERY_ID> (e.g., 1234567)
•	<USER_ID> (e.g., 9876543)
•	e-auth-token (long token string)
•	The JSON payload (e.g., {"chargeFromGrid": false})

Note: The token may expire periodically. You’ll need to repeat these steps when that happens.
  1. Define a rest_command in Home Assistant

In configuration.yaml (or a separate YAML file you use), add:

rest_command:
  set_enphase_battery:
    url: "https://enlighten.enphaseenergy.com/service/batteryConfig/api/v1/batterySettings/{{ battery_id }}?userId={{ user_id }}"
    method: PUT
    headers:
      content-type: "application/json"
      e-auth-token: "<YOUR_TOKEN_HERE>"
      username: "{{ user_id }}"
    payload: >
      {
        "chargeFromGrid": {{ charge_value }}
      }

Key Points
• battery_id, user_id, and charge_value are template variables you pass when calling the service.
• e-auth-token: Replace <YOUR_TOKEN_HERE> with the token from DevTools.

  1. Call the Service

You can call rest_command.set_enphase_battery in Developer Tools → Services, a script, or an automation.

Example: Developer Tools → Services

rest_command.set_enphase_battery
data:
  battery_id: "1234567"
  user_id: "9876543"
  charge_value: "false"

Click Call Service and watch the response in your logs.

Example: Automation Snippet

automation:
  - alias: "Toggle Enphase Battery"
    trigger:
      - platform: state
        entity_id: switch.enphase_battery_toggle
        to: "on"
    action:
      - service: rest_command.set_enphase_battery
        data:
          battery_id: "1234567"
          user_id: "9876543"
          charge_value: "true"
3 Likes

@chinedu40 – That sounds and looks great, however, not sure if it’s a little too far for me to implement, even though it’s something I really want and did completely expect to be part of the UK version.

Questions:
1. I don’t see Developer Tools → Services (Ignore, answer here)
2. When you mention battery_id, can I assume this is the Envoy gateway for the batteries, so if we have multiple batteries, this will charge all, rather than needing X id’s for each battery?
3. How does charging stop, or does the variable change to false?
4. I don’t see how/where the final part (Example: Automation Snippet) of your points is set up. How does this get entered, please?

Hi guys,
I just saw this on my enphase App today and wonder if this means the API reflects this somehow

Any thoughts?

With prior versions it would show in the entities at the right hand top in below picture (of a simulation of EU battery configurations). Not sure if that is still the case with the recent firmwares.

Never seen this reported before. Maybe you can share this in the HA issue on all this as well.

Not sure what I should think off this. They clearly have a way to detect 3th parties communicate with the Envoy. But why you should not disable charge from grid is unclear to me. Unless that’s a country rule.

Think you can’t change it from HA anymore, but assume you can change it in the app. So why tell you not to. Same for the storage mode, would you be able to change that mode.

Maybe ask them the question why?

An US user shared that the AI mode seems not ready for prime time, wonder if that is realted to this.

Do you have any other equipment that may triggered this? Like ev charger or anything else?

Hi @catsmanac
Thank you for your response.

I actually have - sorry.

I have a Soly Brain in place (didn’t pay much attention, because this EMS came with my PV system and it wasn’t able to do anything then monitor, which I do with HA).

Anyway, this EMS is based on gridX same as the EMS “heartbeat” of :zap: Heartbeat AI: Günstiger Strom aus Sonne & Wind.

Anyway, one of the key features is to charge from grid, which was (and still is) not possible with the Soly Brain.

So, I think this message above indicates another special agreement with Soly like with 1Komma5Grad, which supposedly already can charge from grid according to [Guide] Anbindung einer Enphase IQ-Battery an EVCC · evcc-io/evcc · Discussion #12103

In my case the “Charge from Grid” switch is still available (still on FW 8.2.4382).

I will also share this in the issue lik you’ve mentioned.

I am pretty sure that it’s not a local regulation here in Germany, but more related to the fact that the AI optimization is not handled by enphase, but the 3rd party (gridX EMS).
That would make sense as two AIs would not be able to negotiate which has the higher priority.
And deactivation of “charge from grid” would not leave room for any optimization of the PV system.

I did not pay much attention to the profile setting in HA (just tested the enphase App).
I just remember, that the App setting was not reflected in the HA setting.
Now it is (self-consumption) - which fits.
In the App, I still can choose between AI and self-consumption.
(this makes sense, because I might want to switch off the 3rd party and rely on enphase AI instead)
In HA I just have SC, savings, max Backup.

In the Installer App I still can switch both:
Charge from Grid and discharge to grid.
whereas the latter is not allowed in Germany at the moment AFAIK (and does not make sense on the low prices of 8 cent per kWh.

I like that I still have the choice and enphase just recommends the proper setting in the dialog above instead of babying us :wink:

Thanks for the feedback @NCO3. So the message was triggered by the Soly and not by HA as I was thinking first. Two AI models driving would indeed be creating conflicts.

yes, sorry for not being precise from the beginning.
However, I am happy that there is progress on the enphase side.

I will continue to monitor if my Soly Brain makes progress on this.

I am wondering though if the HA switch “Charge from grid” works on any of the enphase users.

Got some feedback for one case where it was: “used but not reliable. Some days, at 08:00am, I’ve 100% to use. Others. I’ve 60%, or 56%, or 47%”.

In the topic where you posted (Thanks) is also feedback how someone tries to control it by manipulating the tariff settings. And here’s anther thread on the issue. Overall it seems local control options are getting fewer and fewer :frowning:

I would be happy if I could charge the battery in any way and I don’t care if it’s locally or through a cloud.

My main problem is, that neither the 3rd party (gridx / Soly Brain) can charge from grid nor enphase.
Even a static charge would be ok for now (setting a time only).

I guess I need to disable the 3rd party, restart the gateway (if necessary?) and re-activate the enphase time settings manually.

Based on the other threads, that seems an option to try. BUT, I have no batteries myself so can’t provide actual hands-on results.

Currently it’s something you have to do from the Enphase App side as there’s no option in the integration to do that. I’m investigating into providing a way that those time settings can be send to the Envoy from HA, but that’ll take a bit more time.

That would be awesome!

By the way, the way I mentioned above does work.
I switched the EMS off, and set static times at noon today CET.
The batteries finally started charging with almost 4 kW.
I tried this many times before and I don’t know what changed.
So, I am concerned, that this will not work reliably on the long run.
Anyway, I will try again tomorrow and see if it still works.

If I can test anything, please let me know, and I am happy to assist if I can.

Hi Phil,

  1. Yes, you have one battery_id that will charge all the batteries
  2. Yes, if you change the variable to false it will stop the batteries charging.
  3. Once you’ve set up the rest_command, you’ll be able to use a helper to make a toggle switch which you can call in an automation. Alternatively, you can put the rest_command in a script that you can call as an action in your automation.
1 Like

Hi @NCO3.
Sorry to bring up an older thread. Is there any chance you could share your templates for converting negative values to positive and the Reimann left integral for your battery charge discharge?

1 Like