Request icon
Script icon
Docker icon
If icon
Parallel icon
AIAgent icon
GoogleGemini icon
Switch icon
Create icon
SlackIncomingWebhook icon
Set icon
Log icon
Schedule icon

GB Grid Frequency Event Forensics with AI Incident Briefs

Detect GB grid frequency excursions from Elexon data, estimate lost generation with the swing equation, and alert with an AI incident brief.

Categories
AIData

Grid frequency is the heartbeat of a power system: when a large generator trips, frequency falls within seconds, and at 48.8 Hz Great Britain starts disconnecting customers automatically. This blueprint turns the free Elexon Insights API into a first-pass incident investigator that measures every excursion, estimates the power lost behind it and alerts with a grounded AI brief.

How it works

  1. Every 15 minutes, fetch_frequency downloads GB system frequency for the lookback_minutes window, with retries.
  2. detect_excursions (Python) groups samples outside band_hz into events and measures depth, RoCoF and duration. Severity is operational (outside 49.8 to 50.2 Hz), statutory (outside 49.5 to 50.5 Hz) or lfdd (48.8 Hz or below). A KV bookmark drops events already alerted on.
  3. has_new_events (If) stops quietly when nothing new happened.
  4. gather_context (Parallel) fetches the generation mix (FUELINST) and system warnings; both tolerate failure.
  5. estimate_physics (Python) sums synchronous kinetic energy from typical inertia constants and applies the swing equation: imbalance = 2E / 50 Hz × |RoCoF|.
  6. write_brief (AIAgent, Gemini) returns a JSON-schema brief citing only the computed numbers.
  7. route_alert (Switch) files a GitHub issue and pages Slack for statutory and LFDD events, and posts a Slack notice otherwise.

What you get

  • Excursions detected within 15 minutes, with severity, RoCoF and an estimated MW imbalance.
  • A structured incident brief in Slack and, for serious events, a GitHub issue.
  • No duplicate alerts across overlapping windows, and replays through the test_data input.

Who it's for

  • Battery and flexibility operators checking their frequency response.
  • Energy analysts and researchers tracking grid stability as inertia falls.

Why orchestrate this with Kestra

Per-task retries and failure tolerance mean a flaky public API degrades the brief instead of losing the alert. Parallel enrichment, routing and deduplication are declarative, and every run is an auditable, replayable execution. The numbers come from deterministic code; the model only explains them.

Prerequisites

  • Docker available to the worker, and outbound HTTPS to Elexon, Google AI, Slack and GitHub.

Secrets

  • GEMINI_API_KEY: Google AI Studio key for the brief.
  • SLACK_WEBHOOK_URL: Slack incoming webhook for alerts and failure notices.
  • GITHUB_TOKEN: token that can create issues in github_repository.

Quick start

  1. Add the three secrets and set github_repository to your own repository.
  2. Execute with band_hz set to 0.03 to see normal drift detected end to end.
  3. Replay a past event by uploading Elexon-format JSON as test_data, then enable the schedule.

How to extend

  • Replay NESO's 1-second files; coarse samples understate RoCoF and the imbalance.
  • Use your own fleet's inertia constants, or persist events to a database for trends.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.