Skip to content

Solar Power Production Data

Aivant Goyal edited this page May 7, 2020 · 1 revision

On every owner dashboard, the user can see data about how much energy their project group's solar projects are producing. This data comes from the Enphase API. How it works is detailed below:

Generation Endpoint

There is an endpoint on peoplepower-node that takes in a solar project ID, a month (e.g. 03) and a year (e.g. 2020) as query parameters and pulls that month's data (up to the current day) from enphase and adds it to airtable. It stores the data in Airtable as a JSON string. It never deletes any data, it just updates the current month's data with the sum of all kilowatt hours so far.

Production Script

There is a script on the peoplepower-node repo (bin/generateProductionData) that, for each solar project, sends a request to the generation endpoint for the current month and year. This script can be run with the command babel-node bin/generateProductionData.js (or npx babel-node bin/generateProductionData.js)

Heroku Scheduler

We use Heroku Scheduler to set up a daily task to run this script every day. This way, the solar production data is always up to date.