This repository automatically archives the daily "Greener Nights" forecast from the Octopus Energy GB API.
Web app to display the forecast (including previous greener nights that are no longer greener, smaller grey arrows): https://jpsingleton.github.io/greener-nights-history/
- Automated Scraping:
A GitHub Actions workflow (
.github/workflows/scrape.yml) runs daily, or whenever triggered, to fetch data from the Octopus Energy Greener Nights API. - Data Storage:
The retrieved forecast data is stored (and versioned) in a JSON file (
greener-nights-history.json) in this repository, creating an ongoing historical record. - Historical Tracking:
The workflow tracks whether each date was ever forecasted as a greener night (new
wasGreenerNightproperty), preserving this information even if subsequent forecasts change. - iCal Calendar Export:
An iCal/ICS calendar file (
greener-nights-history.ics) is automatically generated from the historical data, allowing you to subscribe to or import greener nights directly into your calendar application.
- The GitHub Actions workflow uses
curlto POST a GraphQL query to the Octopus Energy backend API - The response includes:
date: Forecast dategreennessScore: Numeric index of how "green" the energy isisGreenerNight: Boolean flag for greener night eligibility (current forecast)greennessIndex: Qualitative rating (e.g.LOW,MEDIUM,HIGH)
- A new parameter is added:
wasGreenerNight: New synthetic boolean flag indicating if this date was ever forecasted as a greener night
- The workflow merges new data with historical data using
jq:- For each date, if
isGreenerNightwas evertruein previous scrapes,wasGreenerNightremainstrue - This creates a permanent record of dates that were predicted to be greener nights, even if forecasts later change
- For each date, if
- The data is written to
greener-nights-history.json - A Python script (
generate_calendar.py) converts the JSON data into an iCal calendar file:- Creates calendar events for each date in the forecast
- Updates existing events when data changes while preserving historical entries
- Never removes events, maintaining a complete historical record
- Includes greenness score, index, and forecast status in each event
- If the data changes, it is automatically committed and pushed to the repository by the workflow for versioned history.
The wasGreenerNight property provides insight into forecast stability:
- First time seeing a date:
wasGreenerNight = isGreenerNight - Subsequent scrapes:
wasGreenerNight = wasGreenerNight OR isGreenerNight- Once
true, it staystrueforever for that date isGreenerNightcan still change based on new forecasts
- Once
Day 1 scrape:
{
"date": "2025-12-25",
"isGreenerNight": true,
"wasGreenerNight": true
}Day 2 scrape (forecast changed):
{
"date": "2025-12-25",
"isGreenerNight": false,
"wasGreenerNight": true
}This shows that December 25th was originally predicted to be a greener night, but the forecast was later revised.
{
"data": {
"greenerNightsForecast": [
{
"date": "2025-12-23",
"greennessScore": 52,
"isGreenerNight": true,
"greennessIndex": "MEDIUM",
"wasGreenerNight": true
},
{
"date": "2025-12-24",
"greennessScore": 35,
"isGreenerNight": false,
"greennessIndex": "MEDIUM",
"wasGreenerNight": true
}
]
}
}Simply visit the repository to access or download the latest historical and current forecast data from greener-nights-history.json.
Developers and researchers can easily pull the full change history using git.
https://jpsingleton.github.io/greener-nights-history/greener-nights-history.jsonSubscribe to the iCal feed in your calendar application using this URL:
https://jpsingleton.github.io/greener-nights-history/greener-nights-history.icsThis keeps your calendar automatically updated with the latest forecast data.
Each calendar event includes:
- ✅ or ❌ status indicator showing if it was ever forecasted as a greener night
- Greenness score and index
- Current forecast status vs. historical status
- Forecast reliability analysis: Compare
isGreenerNightvswasGreenerNightto identify forecast changes - Planning decisions: Use
wasGreenerNightto understand if a date was ever predicted to be greener - Data science: Study patterns in how forecasts evolve over time
- Calendar integration: View greener nights alongside your other events to plan energy-intensive activities
Octopus Energy's Greener Nights forecasts are useful for tracking when cleaner overnight (23:00-06:00) energy use is encouraged.
The API responses change over time, but Octopus does not provide a public archive. This workflow builds that archive automatically in a public, auditable way, while also preserving information about forecast changes through the wasGreenerNight property.
Maintained by @jpsingleton