Skip to content

Latest commit

 

History

24 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PVOptimizer

Home Assistant automations that adjust battery max charge power from a PV forecast, state of charge (SOC), and simple schedule rules—with Pushsafer notifications at 07:00, optional 12:00 (if not yet full), and when the battery first reaches the near-full threshold.

Home Assistant: see compatibility (target 2024.1+ for the YAML as shipped). License: MIT. Changes: changelog.md. Current Release: 1.4.0 / 20260818-01.

When publishing on GitHub, consider topics such as home-assistant, photovoltaics, battery-storage, energy-management, evcc, yaml.

Business purpose (why it exists)

This setup assumes the battery is charged from PV only. PVoptimizer moderates home-battery charging when the remaining day forecast is strong so feed-in stays smoother (fewer export spikes), neighbors and the grid operator see earlier, more gradual solar export when the EV is idle, and lower currents can be easier on the cells. On ~8 kWp systems, steadier behavior also helps EVCC / wallbox ramp (e.g. 1P 16 A ~3.7 kW3P 6 A ~4.1 kW3P 10 A). It subtracts average house load (battery_discharge_avg_3m × 1.1) plus a fixed 1.5 kWh heat-pump allowance from the remaining PV forecast; if that net budget cannot cover the battery gap, it raises the charge cap to the standard maximum; otherwise it spreads the gap linearly so the battery is full by 16:00. After 16:00, if SOC is still below the target, it uses standard max. When SOC is at or above a set threshold (default 95 % in YAML), the hourly run restores the standard max charge cap before exception-day and forecast rules. A configurable weekday (default Friday, 2500 W) still overrides 16:00 / forecast / WP math whenever SOC is below that threshold. Between sunset and sunrise (sun.sun below horizon), the hourly run sets standard max charge so midnight and intended overnight/grid behaviour stay flexible — except on the exception weekday, which still wins. Evening reset returns the standard cap from a helper. Full detail: docs/pvoptimizer.md.

Background: Comparable tools & stacks (EMHASS, Predbat, examples, evcc).

Contents

Path Purpose
docs/related_projects.md Public repos: EMHASS, Predbat, YAML examples, forecast integrations, evcc
docs/pvoptimizer.md Full design, high-SOC max-cap branch, Open-Meteo, optional DWD pessimization, robustness, decision tree
Testing & verification Check config, manual run, traces, notifier gating, reset
docs/apexcharts_power_day_swipe.yaml Swipe Card (HACS): dieselbe Tages-Leistung für heute … vor 3 Tagen zum Durchwischen
docs/apexcharts_power_day_card.yaml ApexCharts Card (HACS): PV, Netz o. Wallbox, Batterie laden, 2× Wallbox — Tagesansicht
docs/assets/apexcharts_power_day_example.png Screenshot der Tages-Leistung (Flächen für PV + Batterie laden); gilt für Einzelkarte; Swipe = gleiche Kurven, mehrere Tage
docs/energy_dashboard_entities.md Optional: table of HA entity IDs for PV / battery / grid / wallbox charts (installation-specific)
docs/heat_pump_integration.md Heat pump: 1.5 kWh allowance in the charge formula; daily Utility Meter remains diagnostic
Optional Lovelace card Mushroom card: power + max charge cap (input_number)
scripts/sync-to-home-assistant.sh Sync yaml/*.yaml → HA automations/ + integrations/ (default HA_CONFIG_ROOT=/Volumes/config)
docs/pvoptimizer_dashboard.md Dashboard view: autonomy (Sungrow kWh), 90-day import/export chart, optimizer status — canonical live home: PV dashboard /dashboard-pv/pv-optimizer; template: pvoptimizer_dashboard.yaml
yaml/pvoptimizer_autonomy.yaml Optional package: daily Sungrow meters, autonomy counter, threshold helper
yaml/pvoptimizer_charge.yaml Main automation (copy into HA config/automations/)
yaml/pvoptimizer_reset.yaml Evening reset automation
changelog.md Release history, release IDs (YYYYMMDD-NN), and upgrade notes (Keep a Changelog format)
LICENSE MIT

Release IDs

Release IDs use YYYYMMDD-NN, where NN is the running number for that calendar day.

Version Date Release ID
1.4.0 2026-08-18 20260818-01
1.3.0 2026-08-06 20260806-01
1.2.0 2026-07-16 20260716-01
1.1.0 2026-05-24 20260524-01
1.0.0 2026-05-12 20260512-01
  1. Copy yaml/pvoptimizer_charge.yaml and yaml/pvoptimizer_reset.yaml to config/automations/. Add yaml/pvoptimizer_helpers.yaml via packages: (e.g. config/integrations/)—not under automations/—unless you merge the input_number block elsewhere.

  2. At the top of your automations.yaml list (or wherever you keep automations), add:

    - !include automations/pvoptimizer_charge.yaml
    - !include automations/pvoptimizer_reset.yaml
  3. Ensure configuration.yaml includes automations.yaml (typical: automation: !include automations.yaml).

  4. Define the required helpers and entities listed in docs/pvoptimizer.md. Keep/create input_select.pvoptimizer_exception_weekday as a Home Assistant UI helper with options MontagSonntag; it is not defined in the package to avoid duplicate helper IDs. Replace notify.lanar if you use another notifier.

  5. Reload automations (Developer tools → YAML) or restart Home Assistant.

Keep repo and live config in sync: from the repo root, run ./scripts/sync-to-home-assistant.sh (or set HA_CONFIG_ROOT if your config is not /Volumes/config). Then reload YAML in HA as needed.

Testing and verification: docs/pvoptimizer.md — Testing and verification.

Planned work (todo)

Rough backlog for upcoming releases—not implemented yet:

  • Blueprint: Port the hourly charge automation into a Home Assistant blueprint for easier installs and entity wiring.
  • Logging: Extend or refine logging (system_log / diagnostics) for traces and dashboards.
  • Charge boost: Add a “charge boost” control (e.g. button or automation trigger) for temporary higher charge ceilings.
  • Pause charge: Add a “pause charge” control to hold or reduce charging independently of hourly forecast logic.

Disclaimer

This repository documents and ships YAML templates. Adapt entity IDs, capacities, and notifier services to your installation. No warranty; battery and inverter settings affect hardware and grid behaviour—validate changes in your environment.

Initialize a local repo when you are ready: git init, then add remote and push.

About

Home Assistant automation to moderate the PV Battery charge based on PV forecast and consumption

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages