Distributed Generator Failover Validation Script Builder
Create an automated health-check and dry-run failover verification script for backup generation.
Use this template to generate robust automation scripts for validating electrical backup generators and microgrid assets. The output provides automated pre-flight diagnostics and readiness testing.
Role: Lead Electrical Reliability Automation Engineer with expertise in microgrids and emergency backup power assets.
Context
- Primary facility / substation: {{substation_identifier}}
- Controller telemetry interface: {{generator_telemetry_endpoint}}
- Compliance / firmware standard: {{firmware_standard}}
- Minimum fuel reserve level: {{minimum_fuel_threshold}}
- Incident paging channel: {{notification_channel}}
- Audit trail log retention: {{audit_retention_days}}
Task
Author an automated Bash/Python validation script that queries {{generator_telemetry_endpoint}} at {{substation_identifier}}, validates generator readiness against {{firmware_standard}} and {{minimum_fuel_threshold}}, performs a non-interrupted simulated transfer switch test, and writes an audit log preserved for {{audit_retention_days}} while notifying {{notification_channel}} on degraded readiness.
Method
- Establish secure programmatic connection to {{generator_telemetry_endpoint}} using local control network protocols.
- Query battery cranking voltage, coolant jacket temperature, oil pressure, and fuel percentage.
- Validate that current fuel level exceeds {{minimum_fuel_threshold}} and battery charging circuit is active.
- Inspect controller software versions against {{firmware_standard}} to flag uncertified firmware builds.
- Initiate a dry-run transfer switch diagnostic command to confirm transfer readiness without load drop.
- Evaluate breaker closure latency times against utility safety standards.
- Generate a cryptographically hashed execution log and save to local disk configured for {{audit_retention_days}} retention.
- Dispatch an alert to {{notification_channel}} containing readiness score, component flags, and maintenance notices.
Constraints
- MUST NOT initiate an actual electrical open-transition breaker trip during automated testing cycles.
- MUST enforce connection timeouts to prevent script hanging if the controller fails to respond.
- Code MUST exit with standard operational exit codes (0 for healthy, 1 for degraded, 2 for critical failure).
- All diagnostic messages MUST include local ISO timestamps and {{substation_identifier}} in the header.
Output format
1. Script Header and Variable Definitions
- Shell environment declarations and parameter definitions matching context (15-25 lines).
2. Validation and Diagnostic Script
- Complete, runnable automation script with diagnostic subroutines and error handling (90-160 lines).
3. Crontab / Scheduler Definition
- Single crontab or systemd timer snippet demonstrating periodic execution (5-10 lines).
Self-review
- Ensure no test routine causes unintended phase synchronization errors or grid islanding.
- Verify all context variables appear explicitly within the script logic.
- Confirm that log rotation logic cleanly accounts for {{audit_retention_days}}.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.