Battery Maintenance β Full Cycle Automation β
Purpose β
This project implements a fully automated, scheduled full-cycle maintenance routine for a home backup battery system managed via Home Assistant.
The maintenance cycle:
- Discharges the battery to 15%
- Charges the battery to 100%
- Restores a 50% backup reservation
The goal is to preserve battery health, capacity accuracy, and long-term reliability while ensuring safety and recoverability at all times.
High-level Flow β
- User or automation starts maintenance (with confirmation)
- Controller script initializes state and helpers
- Phase 1 β Discharge battery to 15%
- Optional stabilization delay
- Phase 2 β Charge battery to 100%
- Optional stabilization delay
- Restore 50% backup reservation
- Mark maintenance as completed
At any time, the process can be safely cancelled.
Key Design Principles β
- Single controller script orchestrates the entire process
- Explicit phase tracking via helpers for UI and safety
- Idempotent cancel logic (safe to run multiple times)
- Fail-safe restore ensures backup mode is always returned to 50%
- No concurrent executions (
mode: single) - Manual and scheduled control supported
Core Helpers β
input_boolean.battery_maintenance_active
Indicates maintenance is running. Turning OFF requests cancellation.input_select.battery_maintenance_phase
Tracks the current maintenance phase (starting, discharging, charging, cancelled, completed, error, etc.).input_datetime.battery_maintenance_phase_start_time
Automatically updated at each phase transition. Used for progress tracking and UI.input_datetime.last_battery_maintenance_run
Records the last successful maintenance completion.
Safety Model β
- Cancel operation is idempotent
- Battery restore logic runs exactly once per cancel or completion
- Timeouts protect against stalled SOC changes
- Manual cancel is always respected immediately
- System can be safely recovered after Home Assistant restart
Manual Recovery β
If Home Assistant restarts or maintenance is interrupted:
- Run βBattery Maintenance β Cancelβ
- Battery will be restored to 50% backup reservation
- System returns to a known safe state
Status β
This system is actively used in production and has been validated during live maintenance runs.