Matthew1471 / Enphase-API

Enphase-API is an unofficial project providing an API wrapper (including local/LAN Gateway API) and the documentation for Enphase®'s products and services.
GNU General Public License v3.0
76 stars 10 forks source link

POST request to force discharge of battery #23

Open chrisbeach opened 2 months ago

chrisbeach commented 2 months ago

I'd like to force my Enphase batteries to export to the grid when the export rate is high.

I notice a GET request to /ivp/sc/sched produces the following output, which contains a field Force Discharge

{'ACB_agg_energy': 0,
 'ACB_agg_soc': 0,
 'Agg Backup Energy': 0,
 'Agg VLS Energy': 500,
 'Charge From Grid Allowed': True,
 'ENC_agg_energy': 10000,
 'ENC_agg_soc': 100,
 'Force Discharge': False,
 'Num_of_acb': 0,
 'Num_of_enc': 2,
 'acb_current_mode': 1,
 'acb_debug_mode': -1,
 'agg_soc': 100,
 'max_energy': 10000,
 'sched_mode_key': ['ID - Idle',
                    'ZN - Zero Net',
                    'CG - Charge From Grid',
                    'DG - Discharge to Grid',
                    'ND - No Discharge',
                    'DL - Discharge to Load',
                    'CP - Charge From PV',
                    'HEMS Discharge',
                    'HEMS Charge']}

I have tried various forms of JSON POST request to the /ivp/sc/sched endpoint to try to set Force Discharge to True but all the requests have been rejected so far with { "err": "400 - Bad Request", "msg": "Unable to parse JSON request." }'

I'd really appreciate if someone could point me in the right direction with this. I reckon I could shave years off the payback time of my system if I could export excess energy from my battery.

chrisbeach commented 1 month ago

Enphase recently introduced a new feature to their app to schedule a daily forced discharge of the battery.

I'd still prefer to control it from an API though...