Skip to content

tegonal/sun-set-analytics

Repository files navigation

Download AGPL 3 Quality Assurance Newcomers Welcome

sun-set-analytics

This project enables users to analyse the degradation of their solar panels over time. It compares the produced energy of a photovoltaic system (PV production) with an estimate of the expected yield at that location.


❗ You are taking a sneak peek at the next version. It could be that some features you find on this page are not released yet.
Please have a look at the README of the corresponding release/git tag. Latest version: README of v0.1.0.


Table of Content

Development

As a pre-requisit, pnpm is required. Install it based on https://pnpm.io/installation.

  • Copy src/.env.example to src/.env.local and adjust configuration to your needs.
  • run pnpm i
  • run pnpm dev

Installation

You can start sun-set-analytics based on the published docker image. To start the docker image, you need to

  1. Create your own .env configuration as a copy from .env.example (i.e. define the app database loaded from file:///data/sun-set-analytics.db)
  2. start docker, exposing endpoint and mount writable directory to the location where the sqlite database should be stored: i.e. docker run --rm --env-file .env -p 3000:3000 -v /tmp/:/data/ ghcr.io/tegonal/sun-set-analytics:latest

Documentation

Setup user and installation

On the first start, you first need to create a new user. Based on the role selected, the user has different permissions. A User can manage installations and the PV production data of the owned installations. An Admin can additionally create new users.

Be aware that at the moment no additional check prevents a user to upgrade his role to an Admin account

After registering and login to the system, a user can create new installations. The installation will automatically assigned to the current user as owner. Only this user can see and manage the installation afterwards.

API Key

To be able to use the additional rest API's, the user needs to enable a API Key in his profile.

Create api key

Read more about the API Strategy in the payload documentation.

Import data

Upload PV production data

The application provides custom endpoint to be able to upload PV production data. Those data are automatically enriched with data from either

based on the availabily and the configuration in the installation (enabled or not).

The upload endpoint expects a json message compatible to the following json schema:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "measured_production": {
      "type": "array",
      "items": [
        {
          "type": "object",
          "properties": {
            "from": {
              "type": "string",
              "format": "datetime"
            },
            "to": {
              "type": "string",
              "format": "datetime"
            },
            "production": {
              "type": "number"
            }
          },
          "required": [
            "from",
            "to",
            "production"
          ]
        }
      ]
    }
  },
  "required": [
    "measured_production"
  ]
}

A full example looks like:

 curl -H 'Authorization: users API-Key $API_KEY' -X POST $HOSTNAME/api/installations/$INSTALLATION_ID/import-production-data --data '{
  "measured_production": [
    {
      "from": "2022-02-11T20:00:00Z",
      "to": "2022-02-11T21:00:00Z",
      "production": 1.45
    }
  ]
 }'

Where you need to provide API_KEY, HOSTNAME and INSTALLATION_ID depending on you setup and provide a valid json payload. The unit for the energy production is kilowatt-hours (kWh).

Calling this endpoint will:

  1. Enrich and import pv_production data based on the provided time interval
  2. Re-Calculate monthly statistics for the given installation and time interval

Re-importing will not delete any existing records in this time interval. Those need to be cleaned up manually

Delete PV production data

An additional endpoint allows delete PV production data for an installation an a given time interval. To do so, call the following endpoint:

 curl -H 'Authorization: users API-Key $API_KEY' -X POST $HOSTNAME/api/installations/$INSTALLATION_ID/delete-production-data?from=$FROM&to=$TO

Where you need to provide API_KEY, HOSTNAME and INSTALLATION_ID depending on you setup and define with FROM and TO as ISO datetime values the time interval to be deleted. This will:

  1. Delete PV production data for the given installation and time interval
  2. Re-Calculate monthly statistics for the given installation and time interval

Re-fetch PV production data

An additional endpoint allows re-fetching estimate PV production data for an installation an a given time interval. To do so, call the following endpoint:

 curl -H 'Authorization: users API-Key $API_KEY' -X POST $HOSTNAME/api/installations/$INSTALLATION_ID/recalculate-estimated-production?from=$FROM&to=$TO

Where you need to provide API_KEY, HOSTNAME and INSTALLATION_ID depending on you setup and define with FROM and TO as ISO datetime values the time interval to be re-fetched. This will:

  1. Re-fetch the estimated production data and update the records
  2. Re-Calculate monthly statistics for the given installation and time interval

Re-calculate monthly statistics

To re-calculate the monthly statistics based on the data you can call the following endpoint:

 curl -H 'Authorization: users API-Key $API_KEY' -X POST $HOSTNAME/api/installations/$INSTALLATION_ID/recalculate-monthly-stats?from=$FROM&to=$TO

Where you need to provide API_KEY, HOSTNAME and INSTALLATION_ID depending on you setup and define with FROM and TO as ISO date values.

Analyze statistics

After importing PV production data, the monthly statistics can be analyzed based on different comparisons. The following charts should demonstrate the different charts.

Measured vs. estimated production history

Measured vs. estimated production history

Measured vs. estimated production history, yearly comparison

Measured vs. estimated production history, yearly comparison

Measured vs. estimated production history, lines

Measured vs. estimated production history, lines

Difference between estimated measured production history

Difference between estimated measured production history

Difference between estimated measured production history, yearly comparison

Difference between estimated measured production history, yearly comparison

Ratio between estimated measured production history

Ratio between estimated measured production history

Ratio between estimated measured production history, yearly comparison

Ratio between estimated measured production history, yearly comparison

Status of the project

The aim of this project was to provide a basic platform to be able to import, track and compare long term PV production data. The tool was created as an MVP in the context of a Tegonal Open Source Week, in which the whole company contributes to new or existing open source software. There is currently no upcoming work planned on the project. Please share your ideas, experiences or other inputs either issues, discussions or direct contributions.

Contributors and contribute

Our thanks go to code contributors as well as all other contributors (e.g. bug reporters, feature request creators etc.)

You are more than welcome to contribute as well:

License

sun-set-analytics is licensed under GNU Affero General Public License v3

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 5