vincentwolsink / home_assistant_enphase_envoy_installer

This is a HACS custom integration for Enphase Envoys with firmware version 7 and up.
Apache License 2.0
54 stars 10 forks source link

[FEATURE] possibility to charge batteries from grid #129

Open keesvanbemmel opened 1 month ago

keesvanbemmel commented 1 month ago

Hi!

I would really like the possibility to charge my Enphase batteries from the grid if my dynamic contract hourly price is very cheap using an automation.

Do you know if it is possible to switch to a charging state from home assistant? Either by a switch or by setting the purchase and return prices of electricity in the envoy?

Cheers!

vincentwolsink commented 1 month ago

Hi, is there any way to trigger this from the Enphase app? I don't have batteries so I don't know.

keesvanbemmel commented 1 month ago

Only thing I can set is the import and export tariff I guess.

Based on this the envoy determines if it should charge of discharge Screenshot_20240513-205627

vincentwolsink commented 1 month ago

I found some endpoint were we can enable/disable charging from the grid. Don't know how well it works, but will try to implement it in a beta release soon.

vincentwolsink commented 1 month ago

Beta with charge switch and some other settings: 0.3.9-beta1

gritstub commented 1 month ago

Pretty new to Home Assistant, but trying my best to debug this. I do have batteries and running 0.3.9.

I've been playing with Batteries Charge From Grid / switch.batteries_charge_from_grid feature, but it doesn't seem to affect the setting in the Enphase app: Menu > Settings > Battery > Charge battery from the grid

gritstub commented 1 month ago

Not sure if this is how it works through HA/Local, but through the enlighten.enphaseenergy.com web app, I see this request when Disabling Charge battery from the grid

curl 'https://enlighten.enphaseenergy.com/service/batteryConfig/api/v1/batterySettings/XXXXXX?userId=XXXXXX' \
  -X 'PUT' \
  -H 'accept: application/json, text/plain, */*' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'content-type: application/json' \
  -H 'e-auth-token: XXXXXX' \
  -H 'origin: https://battery-profile-ui.enphaseenergy.com' \
  -H 'priority: u=1, i' \
  -H 'referer: https://battery-profile-ui.enphaseenergy.com/' \
  -H 'username: XXXXXX' \
  --data-raw '{"chargeFromGrid":false}' ;

and then this request when Enabling Charge battery from the grid

curl 'https://enlighten.enphaseenergy.com/service/batteryConfig/api/v1/batterySettings/acceptDisclaimer/XXXXXX' \
  -H 'accept: application/json, text/plain, */*' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'content-type: application/json' \
  -H 'e-auth-token: XXXXXX' \
  -H 'origin: https://battery-profile-ui.enphaseenergy.com' \
  -H 'priority: u=1, i' \
  -H 'referer: https://battery-profile-ui.enphaseenergy.com/' \
  -H 'username: XXXXXX' \
  --data-raw '{"disclaimer-type":"itc"}'
vincentwolsink commented 1 month ago

Hi @gritstub, the requests you discovered are via the Enphase cloud. This integration talks directly to the Envoy. There probably is a delay between changing the setting locally in the Envoy and updating the cloud.

keesvanbemmel commented 4 weeks ago

The beta seems to work but I'm not 100% sure yet, seems delayed (which is not strange) OR something else is going on.

Side question: I noticed that there is an "production" switch on the envoy device in this integration. Switching it doesn't seem to do anything, I was under the impression it would cease solar production?

vincentwolsink commented 3 weeks ago

@keesvanbemmel Some delay is expected. But it could be there is something else needed for the Envoy to trigger battery charging. But since I don't have a battery I don't know.

The production switch is indeed supposed to stop production. Also here some delay is expected (a few minutes). Although this functionality is half broken for a lot of users in the Netherlands (see this repo README).