Skip to content

Repository files navigation

ChargeData for Home Assistant

ChargeData is a fully local Home Assistant integration that learns EV charging behavior from Recorder data and predicts the remaining charge time, finish time, progress, and expected energy.

Features

  • Local-only learning: no cloud service, account, or telemetry.
  • Native UI setup: configure source entities through a Config Flow.
  • Historical bootstrap: reconstructs plausible sessions from cumulative 5-minute Recorder statistics.
  • Robust session boundaries: Recorder gaps longer than 10 minutes are hard boundaries; short/slow/overlong outliers are rejected.
  • Context-aware forecasts: matches by weekday/weekend, charging start time, and optional person/work context.
  • Restart-safe: completed and active sessions are stored in Home Assistant's .storage layer.
  • Transparent model: confidence, method, matched-session count, ETA range, source entities, and end-phase detection are exposed as attributes.

Installation with HACS

  1. Open HACS → Integrations → ⋮ → Custom repositories.
  2. Add https://github.com/thorethy1/ha-chargedata as category Integration.
  3. Install ChargeData and restart Home Assistant.
  4. Open Settings → Devices & services → Add integration → ChargeData.

Required inputs

  • A charging power sensor using a Home Assistant power unit (for example W or kW)
  • A cumulative charging energy sensor using a Home Assistant energy unit (for example Wh, kWh, or MJ)

Optional inputs improve behavior:

  • Charging status entity (binary_sensor, input_boolean, or switch)
  • Person and work-zone entities
  • Usable battery capacity entity in kWh
  • Per-session target-energy override entity in kWh

Sensors

Sensor Purpose
Status Idle, charging, or detected end phase
Remaining time Learned ETA in minutes
Finish time Timestamp calculated from the ETA
Progress Current session energy / expected total
Expected energy Learned total charge energy
Model quality Sample-size and stability score
Learned sessions Persisted model sample count
Current session energy Energy since session start
Current charging power Current source power in kW
Context Workday, weekday, weekend, or unknown
Estimated start battery Estimated start SOC from expected energy and usable capacity, assuming charging ends at 100% usable SOC

Learning behavior

The initial model uses cumulative Recorder statistics and keeps only sessions that are:

  • at least 0.5 kWh,
  • at least 15 minutes and no more than 8 hours,
  • between 0.8 and 22 kW average power,
  • composed of samples no more than 10 minutes apart.

For current sessions, a configured charging-status entity is authoritative. Without one, ChargeData confirms a stop only after the configured low-power delay. Predictions prefer at least three sessions with a similar start time (±4 hours) and context; otherwise they safely fall back to the broader history.

Privacy

ChargeData does not make network requests. It reads local Home Assistant states and Recorder statistics and stores its compact learned sessions locally. It never stores raw GPS coordinates.

Development

python -m venv .venv
.venv/bin/pip install 'pytest>=8.4' 'pytest-cov>=6.2' 'ruff>=0.12'
.venv/bin/pytest
.venv/bin/ruff check .

License

MIT

About

Home Assistant custom integration that learns charging behavior from V2G-compatible wallbox statistics and provides usage-based charging time predictions for optimized PV surplus utilization

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages