Skip to main content

Ability to get data from the solar edge api into a influxdb

Project description

solaredge-influxdb

A Python application that fetches solar energy data from the SolarEdge API and stores it in InfluxDB.

Features

  • Retrieves real-time and historical energy data from SolarEdge inverters
  • Automatically calculates sunrise/sunset times to optimize API calls during daylight hours
  • Stores data in InfluxDB for time-series analysis and visualization
  • Supports multiple data types: inverters, meters, and equipment
  • Timezone-aware data collection
  • Docker support for easy deployment

Prerequisites

  • Python 3.11+
  • InfluxDB instance (local or cloud)
  • SolarEdge API key
  • Latitude and longitude of your solar installation

Installation

Using Poetry

git clone https://github.com/yfredrix/solaredge-influxdb.git
cd solaredge-influxdb
poetry install

Using pip

pip install solaredge-influxdb

Using Docker

docker build -t solaredge-influxdb .
docker run -e API_KEY=<your_api_key> -e LATITUDE=<latitude> -e LONGITUDE=<longitude> solaredge-influxdb

Configuration

Configuration is managed through environment variables and/or a config.toml file.

Environment Variables

  • API_KEY - Your SolarEdge API key (required)
  • LATITUDE - Latitude of your solar installation (default: 52.3676)
  • LONGITUDE - Longitude of your solar installation (default: 4.9041)
  • INFLUXDB_URL - InfluxDB connection URL (configured in config.toml)
  • INFLUXDB_TOKEN - InfluxDB authentication token (configured in config.toml)

Configuration File

Create a solaredge_influxdb/config.toml file:

[influxdb]
url = "http://localhost:8086"
token = "your-influxdb-token"
org = "your-org"
bucket = "solaredge"

Usage

Running the Application

python -m solaredge_influxdb

Running with Custom Parameters

from solaredge_influxdb.app import app

app(
    api_key="your-api-key",
    latitude=52.3676,
    longitude=4.9041,
    timezone_str="Europe/Amsterdam",
    timewindow=15,  # Data collection interval in minutes
    force=False  # Force collection regardless of daylight
)

Force Mode

Use force=True to collect data regardless of sunrise/sunset times:

API_KEY=<key> python -m solaredge_influxdb --force

Data Collection

The application automatically:

  1. Calculates local sunrise and sunset times
  2. Only collects data during daylight hours (with configurable buffer time)
  3. Fetches equipment data, meters, and energy metrics from SolarEdge
  4. Stores the data in InfluxDB with timestamps

Testing

Run the test suite:

poetry run pytest

With coverage:

poetry run pytest --cov=solaredge_influxdb

Project Structure

solaredge_influxdb/
├── __init__.py
├── __main__.py
├── app.py              # Main application logic
├── config.toml         # Configuration file
├── influxdb/           # InfluxDB client and utilities
│   ├── __init__.py
│   └── client.py
└── solaredge/          # SolarEdge API client and data models
    ├── __init__.py
    ├── client.py
    ├── equipment.py
    ├── meters.py
    ├── models.py
    └── site.py

Requirements

  • Python 3.11+
  • requests >= 2.31.0
  • influxdb-client >= 1.40.0
  • pydantic >= 2.6.1
  • loguru >= 0.7.2
  • pytz >= 2024.1
  • astral >= 3.2

License

See LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a pull request.

Support

For issues and questions, please open an issue on the GitHub repository. Uploading data from Solar Edge API towards Influxdb on a regular interval of 5 minutes to prevent rate limiting

Usage

Run the application with:

python -m solaredge_influxdb

Available CLI options:

  • --config-path: Path to the configuration file.
  • --latitude: Latitude of the solar panels.
  • --longitude: Longitude of the solar panels.
  • --api-key: API key for the SolarEdge API.
  • --timewindow: Optional time window in minutes used for the technical-data lookback window.
  • --force: Collect data even outside the daylight window.

Examples:

python -m solaredge_influxdb --config-path ./solaredge_influxdb/config.toml --timewindow 15
python -m solaredge_influxdb --force

By default, the application skips data collection outside the configured daylight window. Use --force to collect data even after sundown.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

solaredge_influxdb-2.0.0.tar.gz (23.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

solaredge_influxdb-2.0.0-py3-none-any.whl (25.2 kB view details)

Uploaded Python 3

File details

Details for the file solaredge_influxdb-2.0.0.tar.gz.

File metadata

  • Download URL: solaredge_influxdb-2.0.0.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for solaredge_influxdb-2.0.0.tar.gz
Algorithm Hash digest
SHA256 9cf2454f045cd4ff1f8f43df862a9b2316db09b5ecfb64474a1ce8fc1860c491
MD5 90b1a69d1abbe4a6b498600ae7b8b070
BLAKE2b-256 da366246a65c218f328ccec0c8e2e9ae60c6a8fa38054f0c2f605a77211c6aae

See more details on using hashes here.

Provenance

The following attestation bundles were made for solaredge_influxdb-2.0.0.tar.gz:

Publisher: python-package.yml on yfredrix/solaredge-influxdb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file solaredge_influxdb-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for solaredge_influxdb-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8768a7f1e428ee7cc1a623cdcdd80a178b96d4ba5acceb46e6df794a60eeab10
MD5 e235ace75378151f2dc2907a078f0fbb
BLAKE2b-256 63de0281fdf1222e4c3befe44b3552dc4e232667da50a3208efc652af06a7a43

See more details on using hashes here.

Provenance

The following attestation bundles were made for solaredge_influxdb-2.0.0-py3-none-any.whl:

Publisher: python-package.yml on yfredrix/solaredge-influxdb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page