You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+48-15Lines changed: 48 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,30 +1,67 @@
1
1
# python_enlighten_api
2
-
Enphase Enlighten API application to pull data and monitor panel performance and send alerts on anomalies
2
+
Enphase Enlighten API & Google Sheets application to pull data and monitor panel performance and populate a Google Sheet with historical and visual data. This allows tracking individual panel performance over the lifetime of the system. Most of the functionlaity provided here is also provided by the Enphase Enlighten website and app, but this allows for granular panel tracking and performance over time.
Requires Python 3.6.8 or later installed. Much effort has been taken to ensure this application does not require additional modules besides what is included standard with Python.
* Follow the instructions here to add a new application to your developer account: https://developer.enphase.com/docs/quickstart.html
11
19
2. Open run_inverter_daily_stats.py and set the following in the User Settings section:
12
20
* user_id: within MyEnlighten go to your account Settings and find the API Settings user ID
13
21
* site_id: within MyEnlighten the Site ID should be displayed (or if using the web browser should be in the URL [https://enlighten.enphaseenergy.com/pv/systems/:SITE_ID/overview]
14
-
3. Set the following in the Enlighten Settings section:
22
+
* api_url: The Enphase API, most likely: https://api.enphaseenergy.com/api/v2/systems
15
23
* api_key: within the https://developer.enphase.com/admin/applications page copy your app's API Key
24
+
* spreadsheet_id: The SpreadSheet ID from Google Sheets. See step 5.
25
+
4. Setup a Google API key for your python script and put the following files in your main working script directory: credentials.json, token.pickle.
* Allow your API token to access your Google Sheets account: https://console.developers.google.com/apis/api/sheets.googleapis.com/overview?
28
+
5. Google Sheet Setup
29
+
* The google sheet can be accessed from: https://docs.google.com/spreadsheets/d/1B9pT3fS1Vb2RyltW2USYqwb0Y48A22HzXnojsDLgvhw/edit?usp=sharing. It is a working copy of an example system setup. You may need to manually clear and remove data to use.
30
+
How to Setup:
31
+
1. You'll need to make a copy of this sheet to your personal Google Drive.
32
+
2. Populate each of your inverter serial numbers into the 'Panel Data-Template' Sheet.
33
+
3. Copy and Paste, using values and transpose, your inverter serial numbers into the 'Last 7 Days' sheet.
34
+
4. Update the 'Dashboard' Sheet panel layout to match your panels.
35
+
5. Update the 'Dashboard' Sheet panel numbers and serial numbers to match your panel data
36
+
* Note: Enphase Enlighten did not provide a good way to do this. So I manually had to match up each inverter serial number with the panel number in the layout by tracking panel energy produced over a few days on the 'Panel Data-<Year>' sheet vs the Enphase Enlighten website/app. After a few days each panel's historical data output allowed me to match up each panel on the Dashboard/Panel Data Sheet with the layout of the Enphase app.
37
+
38
+
### Running
39
+
The Enlighten API has a long lag time between when data is updated on their end. If you run these scripts once a day after the Enlighten data updates AND before your solar is producing power (e.g.: 4am) you get the total lifetime power produced by each inverter, including the previous day.
40
+
41
+
Run with run_inverter_daily_stats.sh or copy the logic this script is using.
42
+
43
+
#### Setting Automated Cron Jobs
44
+
If you're using Linux, you can add these scripts to crontab jobs to run automatically at night by:
45
+
46
+
Run:
47
+
48
+
>crontab -e
49
+
Add a crontab job:
50
+
51
+
# At 4am local time run the python script via shell script to ensure we're in the right directory
This repository contains a few scripts used to hit the Enphase Enlighten API and collect data. The scripts inclide:
24
61
25
62
### run_inverter_daily_stats.py
26
63
27
-
Runs the Enlighten API route 'inverters_summary_by_envoy_or_site' to collect the lifetime energy produced by each inverter. If you call this route once a day before your solar is producing power (e.g.: 4am) you get the total lifetime power produced by each inverter, including the previous day. If you track this total lifetime energy value every day, you can then subtract the current day's total from the previous day lifetime total. That gives you the daily production value for that inverter. Note: if your Envoy is connected via low bandwidth Cellular, data only refreshes to Enlighten every 6 hours. So perform this route the next day in the early morning to ensure you get complete data.
64
+
Runs the Enlighten API route 'inverters_summary_by_envoy_or_site' to collect the lifetime energy produced by each inverter. The Enphase API lacks the granulatiry of seeing per inveter daily states (documented here: https://developer.enphase.com/forum/topics/per-inverter-stats). So this script provides a means to do that. If you call this route once a day before your solar is producing power (e.g.: 4am) you get the total lifetime power produced by each inverter, including the previous day. If you track this total lifetime energy value every day, you can then subtract the current day's total from the previous day lifetime total. That gives you the daily production value for that inverter. Note: if your Envoy is connected via low bandwidth Cellular, data only refreshes to Enlighten every 6 hours. So perform this route the next day in the early morning to ensure you get complete data.
28
65
29
66
The resulting data is stashed in a .json file. The file organizes the data by microinverter (by ID), then by day. So you can easily parse this historical data for daily production values.
30
67
For example:
@@ -61,14 +98,10 @@ For example:
61
98
}
62
99
}
63
100
64
-
65
-
## Setting Automated Cron Jobs
66
-
If you're using Linux, you can add these scripts to crontab jobs to run automatically at night by:
67
-
68
-
Run:
69
-
70
-
>crontab -e
71
-
Add a crontab job:
72
-
73
-
# At 4am local time run the python script via shell script to ensure we're in the right directory
0 commit comments