Hi!
Upfront: thanks to the HA creators and this wonderful community that allows for solutions like this ![]()
I wanted to share a project I’ve been working on to optimize my EV charging costs. It integrates Tibber’s dynamic pricing, a go-eCharger (API v2), and BMW CarData to create a fully automated, cost-aware charging schedule.
I built this because I wanted more than just “charge during the cheapest X hours.” I needed something that understands my current State of Charge (SoC), respects a monthly budget, and handles edge cases like negative energy prices.
GitHub Repository: nodomain/ha-cost-optimized-ev-charging
Features
- Dynamic Smart Scheduling: It doesn’t just blindly charge for 6 hours. It calculates exactly how many hours are needed based on the current SoC (from BMW CarData) and the Target SoC, then picks the absolute cheapest hours available.
- Overnight Charging: It seamlessly combines today’s and tomorrow’s prices (once available at 13:00) to find the optimal continuous charging window across midnight.
- Monthly Budgeting: You can set a monthly EV charging budget (e.g., 50€). The automation tracks costs separately from the house and stops charging if the budget is hit.
- Negative Price Handling: Fully supports negative energy prices! If you charge when prices are negative, it correctly reduces your accumulated monthly cost and frees up your budget.
- Voltage Protection: Monitors grid voltage and takes progressive action (warn → reduce current → stop) to protect your home grid.
- Efficiency Tracking: Compares the power delivered by the wallbox against the power received by the battery (via BMW API in my case) to show charging losses.
- Comprehensive Dashboard: Includes templates for a detailed full-page dashboard and a compact widget for wall-mounted tablets.
How it works
The core logic runs every minute (and on state changes). It fetches the 15-minute resolution prices from the official Tibber integration, calculates the required energy, finds the price threshold for the cheapest hours, and decides whether to force-start (frc=2) or force-stop (frc=1) the go-eCharger.
It’s built entirely using Home Assistant templates, sensors, and automations packaged into a single YAML file (using the packages feature), making it relatively easy to deploy.
Getting Started & Customization
I’ve included a deployment script in the repo that takes a .env file with your specific entity IDs (go-eCharger serial, Tibber home slug, etc.) and generates the final YAML files for your configuration and dashboard.
I know this setup is highly tailored to my specific hardware combination (Tibber + go-eCharger + BMW). However, I tried to structure the code cleanly, so I believe it serves as a solid baseline or inspiration if you want to adapt it to your own EV or wallbox integration. The core logic for price calculation and budgeting is quite universal.
Check out the README for full setup instructions.
I’d love to hear your feedback, suggestions, or any questions you might have!

