Skip to main content

Solar Forecast LangGraph

OpenSSF Best Practices

Fuzzing: RC only

CI Coverage PyPI Python License

LangGraph workflow for solar forecasting with:

  • Weather data agent — OpenMeteo API (free, no key required)
  • Historical generation loader — From inverter-monitoring webhook
  • Panel configuration schema — Azimuth, tilt, capacity, losses
  • Forecast model — Physical (clear-sky + clouds) + Statistical (ML) + LLM reasoning
  • Inverter-control integration — Pre-charge battery before cloudy periods
  • Forecast validation — Evaluation requirements and current limitations (guide)

Release process

See the release strategy for validation, nightly, beta, RC and stable promotion rules, and the operator runbook for local commands.

Architecture

graph TD
    A[User Request] --> B[LangGraph Workflow]
    
    B --> C[Fetch Weather<br/>OpenMeteo API]
    B --> D[Fetch History<br/>inverter-monitoring]
    
    C --> E[Train Statistical Model]
    D --> E
    
    E --> F[Generate Forecast<br/>Physical + Statistical Ensemble]
    F --> G[Optional LLM Enhancement<br/>Base forecast on failure or when disabled]
    G --> H[Inverter-Control Hook<br/>Pre-charge decision]
    H --> I[Final Forecast Output]
    
    I -.-> J[Planned: accuracy tracking]
    J -.-> K[Planned: retraining scheduler]
    
    subgraph "Data Sources"
        C
        D
    end
    
    subgraph "Models"
        E
        F
        G
    end
    
    subgraph "Integrations"
        H
    end

Installation

From the stable release

As of 12 October 2026, PyPI and GitHub Releases both provide 0.1.4. The verified publication uploaded the existing approved wheel and sdist without rebuilding them.

python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
python -m pip install solar-forecast-langgraph==0.1.4

The same wheel is also available directly from GitHub:

python -m pip install "https://github.com/4alvit/solar-forecast-langgraph/releases/download/v0.1.4/solar_forecast_langgraph-0.1.4-py3-none-any.whl"

Select an explicit stable version and verify its SHA256SUMS and release-manifest.json when updating. Nightly, beta and RC tags are prereleases. PyPI publication remains a separate manual promotion of verified assets; creating a GitHub release does not publish it automatically. See distribution channels for the verified hashes and promotion procedure.

After installing, check the CLI is available:

solar-forecast --help

From source (for development)

git clone git@github.com:4alvit/solar-forecast-langgraph.git
cd solar-forecast-langgraph
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pre-commit install

Quick Start

# Copy example config and customize
cp site_config.example.py site_config.local.py
# Edit site_config.local.py with your panel details

# Run forecast (48h horizon, 30 days history)
solar-forecast --config site_config.local.py --horizon 48 --output forecast.json

Output example:

Forecast Summary:
  Site: my-solar-site
  Panel: south-roof
  Method: ensemble
  Horizon: 48 hours
  Total Energy: 42500 Wh
  Generated: 2024-01-15T10:30:00+00:00

Next 12 hours:
  2024-01-15 11:00: 1200W (1200Wh) [960-1440]
  2024-01-15 12:00: 2800W (2800Wh) [2240-3360]
  2024-01-15 13:00: 3500W (3500Wh) [2800-4200]

Configuration

Panel Configuration

from solar_forecast.config import PanelConfig, SiteConfig

panel = PanelConfig(
    name="South Roof",
    panel_id="south-roof",
    azimuth=180,  # 0=N, 90=E, 180=S, 270=W
    tilt=35,  # Degrees from horizontal
    capacity_kw=5.0,  # DC capacity
    module_count=14,
    latitude=52.37,
    longitude=4.90,
    # Optional losses
    shading_loss=0.0,
    soiling_loss=0.02,
    wiring_loss=0.01,
    module_efficiency=0.20,
    temperature_coefficient=-0.0035,
    inverter_efficiency=0.96,
    dc_ac_ratio=1.2,
)

site = SiteConfig(
    site_name="my-site",
    latitude=52.37,
    longitude=4.90,
    timezone="Europe/Amsterdam",
    panels=[panel],
)

See site_config.example.py for full example.


Forecast Methods

Method Description Use Case
physical Isotropic transposition of weather-adjusted radiation No historical data
statistical ML model on historical data Sufficient history (30+ days)
ensemble Weighted: 60% physical + 40% statistical Default; comparative accuracy is not yet established
llm_enhanced Optional LLM analysis of weather patterns Requires API credentials; field accuracy is not yet established

The physical fallback takes the three horizontal components from Open-Meteo: global (shortwave_radiation), direct (direct_radiation) and diffuse (diffuse_radiation), all in W/m². Direct horizontal radiation differs from direct normal irradiance (DNI). For sun above the horizon, the model projects the direct component onto the panel and adds isotropic sky diffuse and ground reflection (albedo 0.2):

POA = direct_horizontal × max(0, cos(incidence)) / cos(zenith)
    + diffuse_horizontal × (1 + cos(tilt)) / 2
    + global_horizontal × 0.2 × (1 - cos(tilt)) / 2

Thus a horizontal panel preserves global irradiance when direct + diffuse = global, and a panel facing away from the sun still receives diffuse radiation. The previous calculation incorrectly used the beam projection ratio to remove diffuse light. The replacement follows the isotropic transposition model, not an anisotropic Hay-Davies approximation. Eight offline reference cases in tests/fixtures/isotropic-pvlib-0.13.1.json were calculated using pvlib 0.13.1 get_total_irradiance(..., albedo=0.2, model="isotropic"); pvlib is not a runtime dependency. For reproduction, convert each fixture's horizontal direct input to DNI with direct_horizontal / cos(radians(zenith)).

New Python callers should pass direct_horizontal=. The historical dni= argument (or third positional argument) still means horizontal direct radiation; passing both names raises TypeError. The statistical feature named dni retains the same historical meaning to preserve fitted model compatibility. No extra cloud derating is applied. The solar position remains approximate; hourly weather averages are treated at the forecast timestamp. At/below the horizon output is zero. Near-horizon direct projection is sensitive to input consistency; these numerical checks do not establish real-site forecast accuracy.


Inverter-Control Integration

The workflow publishes forecast data and pre-charge requests to the Cerbo GX MQTT broker (Venus OS N/ namespace):

sequenceDiagram
    participant WF as LangGraph Workflow
    participant FC as Forecast
    participant CB as Cerbo GX MQTT
    participant IC as Inverter-Control

    WF->>FC: Generate 48h forecast
    FC->>WF: Forecast points with confidence
    WF->>CB: Publish solar_forecast/{site}/forecast_json (retain=True)
    WF->>WF: After 00:01 local, compare today's calendar-day kWh to threshold
    alt Low generation (< threshold for today)
        WF->>CB: Publish solar_forecast/{site}/pre_charge_request (retain=False)
        Note over CB,IC: Delivery adapter and controller safety policy must be configured separately
    end

Topics published:

The workflow suppresses pre-charge when there are no points for the panel's current local calendar day; it still publishes the available daily summary. A present zero-generation forecast remains distinct from missing data. MQTT publication alone does not prove controller delivery or physical charging. Repeated workflow runs can publish repeated requests: the integration must establish deduplication and an actuator-side safety gate before enabling automatic charging. This workflow does not provide that end-to-end guarantee.

Topic retain Payload
solar_forecast/{site_id}/forecast_json True Daily kWh summary (today_kwh, tomorrow_kwh)
solar_forecast/{site_id}/pre_charge_request False Pre-charge trigger for low today forecast (horizon_hours=24, day=today)

Environment variables:

INVERTER_CONTROL_ENABLED=true          # Enable the hook
MQTT_BROKER=localhost                # Cerbo GX MQTT broker host
MQTT_PORT=1883                       # MQTT port
SITE_ID=default                      # Site identifier used in topic paths
PRE_CHARGE_THRESHOLD_WH=6000         # Pre-charge if today's calendar-day forecast < this (Wh)
TOU_EXPENSIVE_START_HOUR=22          # Optional: suppress pre-charge during expensive grid window
TOU_EXPENSIVE_END_HOUR=6

The expensive tariff window uses the selected panel's timezone, including its daylight-saving rules. The container's TZ does not change this decision. Start hours are inclusive and end hours are exclusive; 22 to 6 spans midnight, and an end hour of 24 ends at midnight. For example, a panel in Europe/Amsterdam suppresses pre-charge from 22:00 to 06:00 Amsterdam time even when the container runs in UTC. Forecast publication continues while pre-charge is suppressed.


Forecast Validation

The implementation trains from historical generation and produces forecasts. It does not yet persist forecast-versus-actual pairs, calculate operational MAE/RMSE/MAPE/bias, or automatically retrain based on measured errors. Unit tests use synthetic weather/generation and check behavior; they are not evidence of accuracy on a real installation.

See forecast validation for the required public data, chronological holdout, baselines, and metrics before claiming that one method is more accurate or using forecasts for operational decisions.


Development

Run Tests

pytest tests/ -v --cov=solar_forecast

Lint & Format

ruff check .
ruff format .

Type Check

mypy solar_forecast/

Project Structure

solar-forecast-langgraph/
├── solar_forecast/
│   ├── __init__.py          # Public exports
│   ├── config.py            # Panel/Site configuration schemas
│   ├── weather.py           # OpenMeteo client
│   ├── history.py           # Historical data loaders
│   ├── model.py             # Physical/Statistical/LLM models
│   ├── workflow.py          # LangGraph workflow
│   └── main.py              # CLI entry point
├── tests/
│   ├── test_config.py
│   ├── test_weather.py
│   ├── test_model.py
│   └── test_workflow.py
├── .github/workflows/ci-checks.yml # Reusable CI checks
├── pyproject.toml           # Package config
├── site_config.example.py   # Example configuration
└── README.md

Roadmap

  • Measure optional LLM forecast adjustments against held-out field data
  • Automated model retraining scheduler
  • Prometheus metrics export
  • Grafana dashboard template
  • Multi-site support in single workflow
  • Battery SoC optimization (not just pre-charge)
  • Shadow modeling from 3D terrain

Docker

The release pipeline builds linux/amd64 and linux/arm64 OCI artifacts and attaches them to GitHub releases. Publishing those verified bytes to GHCR is a separate explicit operation; pushes to main and prereleases do not deploy a container or move latest.

Before configuring Docker or Portainer, verify that the intended stable version has been published to ghcr.io/4alvit/solar-forecast-langgraph, then pin its image digest. The distribution runbook describes the verification and publication boundary.


License

MIT License — see LICENSE for details.

Contributing and security

See CONTRIBUTING.md for development, bug reports and proposals, SECURITY.md for confidential vulnerability reports and deployment boundaries, and the OpenSSF evidence index for assessment scope and verification.

HTTPS transport and runtime requirements are described in TLS policy.

Project responsibilities and decisions are documented in Governance, expected conduct in the Code of conduct, and priorities in the Roadmap. The security assurance case records controls, evidence and unresolved limits.

Release-candidate fuzzing

The production panel-configuration validator and effective-capacity calculation receive synthetic JSON. Accepted configuration must serialize losslessly and yield finite nonnegative capacity bounded by rated DC capacity. No weather service, LLM, inverter or MQTT broker is contacted.

RC-only fuzzing policy, local reproduction and failure handling.

Release artifact identity, build receipts and local reproduction are documented in release packaging.

Metadata

Release files for solar-forecast-langgraph 0.1.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for solar-forecast-langgraph 0.1.10
File Size Uploaded Provenance Actions
solar_forecast_langgraph-0.1.10.tar.gz 71.6 kB With provenance Details for solar_forecast_langgraph-0.1.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for solar-forecast-langgraph 0.1.10
File Interpreter ABI Platform Actions
solar_forecast_langgraph-0.1.10-py3-none-any.whl Python 3 none any Details for solar_forecast_langgraph-0.1.10-py3-none-any.whl

Total release size: 108.7 kB

Release files / solar_forecast_langgraph-0.1.10.tar.gz

Download URL solar_forecast_langgraph-0.1.10.tar.gz
Size 71.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9820b3f5cd758e779d04e82129b72dc81f52afae939deaab9a6697523de48b9e
BLAKE2b-256 checksum
How to use checksums
0dd68643462e85fca5dcec1bf4e7d522dd7704e53ae9038a2e654a3e418b8807
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / solar_forecast_langgraph-0.1.10-py3-none-any.whl

Download URL solar_forecast_langgraph-0.1.10-py3-none-any.whl
Size 37.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f198ca06bd979dfc62d6acda562dd89a949888b3a443ef5738c7471f0588511e
BLAKE2b-256 checksum
How to use checksums
2e2b33980574f8f45a9825222bd86a81563f931bf750ad19b8ff4265ad5f9bab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Security for solar-forecast-langgraph 0.1.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for solar_forecast_langgraph-0.1.10.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page