General engineering
AuraScore 81/100

Grid Substation Telemetry Health Monitor Script

Generate a resilient Python telemetry validation script for SCADA power distribution sensor streams.

Use this prompt when deploying automated ingestion health checks for electric substation telemetry streams. It builds a modular validation script that detects anomalous voltage spikes and drops before SCADA database ingestion.

Template

Role: Principal SCADA Systems Integration Engineer specializing in power distribution telemetry automation.

Context

  • Target Substation ID: {{grid_substation_id}}
  • Ingestion Source: {{telemetry_data_source}}
  • Telemetry Sensor Types: {{sensor_metric_types}}
  • Expected Ingestion Frequency: {{sampling_rate_hz}} Hz
  • Outlier Rejection Threshold: {{anomaly_threshold_sigma}} sigma
  • Incident Notification Webhook: {{alert_webhook_url}}

Task

Write a production-ready Python automation script that continuously consumes substation sensor metrics from the source, computes rolling statistical baselines, flags transient anomalies exceeding safety bounds, and dispatches webhook alerts while logging clean time-series records.

Method

  1. Establish resilient streaming connection logic for {{telemetry_data_source}} with exponential backoff retry parameters.
  2. Validate incoming packet schema against expected metric definitions for {{sensor_metric_types}} originating from {{grid_substation_id}}.
  3. Maintain a rolling memory buffer matching a 5-minute window derived from {{sampling_rate_hz}} sampling rates.
  4. Calculate rolling mean and standard deviation per metric to identify fluctuations exceeding {{anomaly_threshold_sigma}} sigma.
  5. Filter out corrupted payloads and append clean metric tuples to an optimized batch persistence queue.
  6. Construct an alert dispatcher that sends payload-level telemetry failure notices to {{alert_webhook_url}}.
  7. Implement graceful SIGTERM and SIGINT interrupt handling to flush pending memory queues safely.
  8. Include standard error logging with ISO-8601 timestamps and precise hardware sensor identifiers.

Constraints

  • MUST implement pure standard library or widely supported industrial libraries (requests, numpy) with pinned versions.
  • MUST NOT drop telemetry packets silently during transient network failures; implement an in-memory queue fallback.
  • Code MUST be entirely self-contained, fully executable, and contain no placeholder comments or omitted logic.
  • Include inline docstrings and PEP-8 compliant type annotations across all routine definitions.

Output format

Provide the solution in three explicit sections:

  1. Dependencies and Environment: A bulleted list of prerequisite libraries and required environment variables.
  2. Telemetry Processing Script: The complete, runnable Python script inside a single code block.
  3. Execution and Testing Guide: A concise 3-step terminal walkthrough illustrating script initialization and sample execution.

Self-review

  • Confirm that every variable ({{grid_substation_id}}, {{telemetry_data_source}}, {{sensor_metric_types}}, {{sampling_rate_hz}}, {{anomaly_threshold_sigma}}, {{alert_webhook_url}}) is directly used in the implementation.
  • Verify all error handlers protect against network timeouts when hitting {{alert_webhook_url}}.
  • Check that the rolling standard deviation calculation aligns with {{anomaly_threshold_sigma}}.
AuraScore breakdown
81/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering10/12 · Adequate

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency5/10 · Thin

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness5/5 · Strong

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

developers
developers-general
energy-utilities
scada
python
telemetry