evcc-calendar
Docker app from cmdrsabre's Repository
Sets a one-time evcc charging plan (target SoC and time) for your car from calendar appointments read through Home Assistant.
Overview
Readme
View on GitHubevcc-calendar
Sets a one-time evcc charging plan (target SoC and time) for your car from appointments in a Home Assistant calendar. Every 30 minutes it reads the appointments of the next 6 days, classifies car trips, determines the route via OpenRouteService, calculates the energy needed for the outbound and return trip and sets the plan in evcc. It starts in dry-run mode: nothing is written and nothing is sent.
The web UI and messages are available in English (default) and German. Set
language: deinconfig.yamlor change it in the UI under Settings.
Install and configure
Pick one way. All three start in dry-run mode (nothing is written to evcc, nothing is sent).
You need (all ways):
- Home Assistant with a calendar entity and a long-lived access token (HA token)
- evcc, reachable from the host, with its API key and your vehicle set up
- a free OpenRouteService API key (ORS key)
1. Docker (Compose)
Requires: Docker with Compose.
- Get the files and the data folder:
mkdir evcc-calendar && cd evcc-calendar && mkdir data curl -O https://raw.githubusercontent.com/cmdrsabre/evcc-calendar/main/docker-compose.yml curl -o .env https://raw.githubusercontent.com/cmdrsabre/evcc-calendar/main/.env.example - Edit
.env: fill inHA_TOKEN,EVCC_API_KEY,ORS_KEY. Never share this file. Other host port:HOST_PORT(default 8180). docker compose up -d(first start createsdata/config.yamlfrom the example).- Edit
data/config.yaml(see Configure), thendocker compose restart. - Open
http://localhost:8180and set the password for the useradmin.
Logs: docker compose logs -f. Update: docker compose pull && docker compose up -d.
2. Unraid app
Requires: Unraid with Docker enabled.
- Apps → search
evcc-calendar→ Install. The app always installs the latest stable release (latest), never a pre-release. - Fill in
HA_TOKEN,EVCC_API_KEY,ORS_KEY, then Apply. - Edit
/mnt/user/appdata/evcc-kalender/config.yaml(created on first start, see Configure), then restart the container. - Open the WebUI (
http://<unraid-ip>:8180) and set the password for the useradmin.
To try a beta release: edit the container, set Repository to ghcr.io/cmdrsabre/evcc-calendar:<tag> (tags on the package page), Apply. Set it back to :latest afterwards.
3. Manual (clone and run)
Requires: Python 3.12 (3.9+ runs the tests), git.
- Clone and install:
git clone https://github.com/cmdrsabre/evcc-calendar.git && cd evcc-calendar python -m venv .venv && . .venv/bin/activate pip install -r requirements.txt mkdir data && cp config.example.yaml data/config.yaml - Edit
data/config.yaml(see Configure). Also setdb_path: data/state.dbandweb: {host: 127.0.0.1, port: 8180}(port 80 needs root). - Set the keys in your shell (not in a file in the repo):
export HA_TOKEN=... EVCC_API_KEY=... ORS_KEY=... - Try it:
python -m evccplan once --dry-run --config data/config.yaml - Run it:
python -m evccplan serve --config data/config.yaml, openhttp://localhost:8180, set the password foradmin.
Configure
Edit config.yaml (Docker/Unraid: in the data folder). The minimum:
home.address(orlat/lon): where trips startha.url,ha.calendar(one entity or a list of calendars),ha.notify_targets(notify entities per level)evcc.url,evcc.vehicle(name from evcc/api/state, e.g.db:1), optionalevcc.ui_url(address your browser uses for the "evcc" button in the header, defaultevcc.url)language: defor German (defaulten);rulesfor title words like car/train
Everything else has defaults, most values can also be changed in the UI under Settings.
MQTT (optional)
evcc.mqtt in config.yaml (or the "MQTT" group in the Settings tab; only the password is environment-only, EVCC_MQTT_PASSWORD). Plain MQTT with user and password, no TLS.
read_evcc: true: the live status comes from evcc's retained topics (<topic>/site/#,loadpoints/#,vehicles/#) instead of polling. If MQTT fails, evcc is polled over HTTP. Planning runs still use the evcc API.publish: true: after every run the next plan is published retained under<publish_topic>/(planas JSON, plusplan/soc,plan/time,plan/title,plan/action,run/time,run/ok,run/dry_run,run/problems,status). Without a plan the plan topics are empty.- With
publish, Home Assistant also finds a device "evcc calendar" through MQTT discovery (prefixhomeassistant): "Appointment 1" to "3" (the next appointments with a place or a choice of yours; title as state, start, departure, status, distance, target, preheating as attributes, no addresses) and a problem sensor. Topics:<publish_topic>/slot/<n>/…,problems. control: true(default off) adds per appointment a preheat switch and selects for charge target and mode, plus a "check now" button (dry run). Commands go to<publish_topic>/cmd/…; retained commands are ignored. A command applies to the appointment shown in that slot at that moment, so slots move up when an appointment starts.- Security: MQTT here is unencrypted, anyone with access to the broker can read the appointment titles and, with
control, change the planning. Restrict the broker. If you switch publishing off, remove the device in Home Assistant yourself.
ICS calendars (optional)
Besides Home Assistant calendars, appointments can be read directly from an ICS subscription URL, with no OAuth. Add ics to config.yaml and put the URL into the environment variable named in url_env (it is a secret and never shown in the UI, logs or error messages):
ics:
- name: Family # label on the calendar card, unique
url_env: ICS_URL_FAMILY
- Google: calendar settings, "Integrate calendar", "Secret address in iCal format". Google may serve the feed a little behind the live calendar. iCloud (public link,
webcal://works), Outlook (published calendar) and Nextcloud (subscription link) work the same way. - Recurring appointments (including exceptions and moved single occurrences), time zones and floating times are handled; all-day and cancelled events are skipped like in Home Assistant calendars.
- Works alone or next to
ha.calendar. Withoutha.calendaronly the ICS feeds are read. Home Assistant is still needed for push, weather and the charge limit. - A feed that cannot be read falls back to its last state, like a Home Assistant calendar. Feeds are limited to 5 MB.
Preconditioning (optional)
Needs Home Assistant with a climate entity of the car. Choose it per vehicle under Settings ("Climate entity per vehicle"); only the vehicle the service plans for (evcc.vehicle) is heated.
- When: car plugged in and colder than
precond_threshold_c(15). Lead =precond_target_c(20) minus temperature, in minutes (at most 60), before the departure (appointment start minus travel time, withouttime_buffer_min). Each appointment has a switch: on by default, off by default for short trips (belowmin_car_km, or a target at or below the evcc minimum). - Temperature: the forecast outside temperature at departure plus 3 K (a parked car is rarely that cold). The car's own sensor is not used, vehicle clouds report it late or not at all.
- The command is sent once; the car ends the heating itself.
- The charge plan gets extra time for
precond_heater_kw(3). - While heating, once the plan target is reached, the loadpoint is set to
smartwith "always charge" for this session (minpvon older evcc versions) and a session limit of 100 % so the heater runs from the grid. Previous values come back when the climate reports off, the charge level rises by 2 points anyway, the car is unplugged, or 15 minutes after the departure. - With
dry_run: trueyou only see what would happen.
Raise the charge limit automatically
If the charge limit set in the car is below vehicle_limit_min, the plan cannot be reached. You get a push as soon as the car is plugged in with such a limit. With ha.charge_limit.entity (a number or input_number entity of your car integration, e.g. number.ioniq_5_ac_charging_limit) the service sets it to ha.charge_limit.value (default 100, range 50 to 100) via Home Assistant, once per plan. The switch auto (default true) can also be changed in the UI under Settings once an entity is configured.
- Confirmation comes from evcc (
vehicleLimitSoc), not from the Home Assistant entity: cloud-based vehicle integrations often need 10 to 60 minutes, and the HA Bluelink integration polls only about every 2 hours. - If the limit is still too low after 3 hours, it is set once more; after that you get a push that it has to be changed by hand.
- In dry-run mode nothing is set; the warning says what would happen.
Go live only after the dry run looks right for a few days: set
dry_run: falseinconfig.yamland restart. Only one instance may run live.
Commands
python -m evccplan once --config config.yaml --dry-run: single run, JSON output, writes nothing.python -m evccplan serve: service with status page (default in the container).
Rules in brief
- Only appointments with a time and a location. The trip always starts at home.
- Classification: whole word "Auto"/"Bahn" (car/train) in title or description, then
rules(title words, case-insensitive), otherwise car (clear). "Unclear" only means a contradiction (car and train both in the text); it caps the target atunclear_cap_socand sends a push. - One-way distance below
min_car_km(4 km): walk/bike, not a car appointment (not planned, not chained). The keyword "Auto" still forces car. - Target = (energy for outbound and return trip +
reserve_soc), rounded up to 5 %, at most 100 %. Only planned if above the evcc minimum. - Departure time = appointment start − travel time −
time_buffer_min. The charge deadline is earlier bycharge_buffer_min(3), pluscold_buffer_min(12) belowtemp_threshold_c, so the target is reached slightly early. - Overlapping car appointments are reported as a conflict: the first one is planned with enough charge for the longer of the overlapping trips.
- Consecutive car appointments (≤
chain_window_h= 5 h from return to the next departure) form a chain (status "Folgetermin"): if the time at home is not enough to recharge, the target of the first appointment is raised. When there is no time to drive home in between (or the charge gained at home is worth less than the detour), the appointments form a tour: the legs are routed from one appointment to the next and the charge is planned for the whole tour once, instead of a round trip per appointment. - The service only changes plans it set itself. Manual one-time plans and all repeating plans are left untouched.
- Preconditioning (if configured) also changes the loadpoint mode and session limit for the duration of the heating.
Notifications
Sent through notify.send_message in Home Assistant with target entities per level (ha.notify_targets):
confirmations ("Ladeplan gesetzt") to the app, warnings additionally to Telegram, errors additionally as an Alexa announcement.
Each target gets its own call; a push counts as sent when at least one target accepted it. Text for entities whose id contains telegram is escaped for MarkdownV2 (HA's default parse mode there).
Each message is sent only once per occasion.
Once a minute the service checks the cached live status from evcc (no planning run, no extra requests) and sends:
- a warning 10 minutes before the planned charge start if the car is not plugged in,
- an info when the car comes back below the assumed charge (the reserve) and charging therefore has to start at least 10 minutes earlier (a higher charge level sends nothing),
- a warning when the plan can no longer be reached in time.
If a push fails, the same message is tried again only after 5 minutes. Overlapping car appointments are planned for the longest of the trips, with the deadline of the one that has to leave first.
Failure handling
- evcc not responding: 3 attempts per run. Then a push "ALARM: evcc ist nicht erreichbar" via Home Assistant (at most every 6 h) and a red notice on the status page. The plan is not changed.
- Calendar not readable: 3 attempts. Then the service continues with the last read appointments and still serves evcc, with a red notice on the status page and, if possible, a push. Without a stored state (first start) the run aborts with an error.
- Push via Home Assistant not possible: the situation is shown in red on the status page and logged at ERROR level in the container log. An emergency channel outside Home Assistant (e.g. Unraid notifications) is not built in yet.
- OpenRouteService not reachable: stored addresses and routes keep being used. Everything else is not planned; one summary notice instead of many single ones.
Tests
pip install -r requirements-dev.txt && python -m pytest
Web UI (v0.2)
- On first access you set the password for the fixed user
admin(at least 8 characters). Afterwards you log in with it. Forgot the password: deletestate.db. This also resets all overrides made in the UI. - Per appointment you choose Automatisch / Auto / Kein Auto (automatic / car / no car) and a charge target in 5 % steps. A charge target means: charge here.
This also works for appointments without an address or with an unclear address; these use
manual_drive_min(45 min) as travel time. - A chosen charge target is used exactly as set, without reserve, rounding or the cap for unclear classification. If it is not enough for the trip, the card warns you.
- Every change immediately triggers a run in the configured mode. With
dry_run: truenothing is written to evcc. The "Jetzt prüfen" button always only calculates (dry run). - Overrides apply per appointment instance (UID and date) and are deleted two days after the appointment.
- Keep the network trusted: the UI is served over HTTP. For access from outside, put a reverse proxy with HTTPS in front
(it sets
X-Forwarded-Proto: https, and the cookie is then markedSecure). - Images are optional.
Settings and history (v0.3)
- The Einstellungen tab edits consumption values, reserve, charge power, trip limits and the car/train rules. Changed values are stored in the database
and win over
config.yaml; "Auf config.yaml zurücksetzen" removes them. URLs, tokens and keys are not editable in the UI. - The Verlauf tab lists the last 300 runs with their result. Deleting
state.dbalso clears settings and history.
Next charge, cost and sessions (v0.5)
- Each planned charge in the calendar shows when charging is planned (timeline bar with now and plan time), its duration and cost; the bar of the card marks the
actual state of charge and where the plan wants it, so a deviation is visible at once, plus whether charging is ahead of or behind the plan. While the car is plugged in the window comes from evcc, otherwise it is estimated from the plan time and
charge_power_kw. - Maximum cost of the next charge: grid energy (with
charge_loss_margin) times the price from evcc. PV share is not deducted, hence "maximum". If evcc has no price, nothing is shown. If the car is not plugged in, the state of charge on arrival is assumed to bereserve_soc. - The history lists finished charging sessions with their real cost (needs evcc's session database, read only).
Your own vehicle image
The bundled blue car (evccplan/static/img/car.webp) is the default. Your own image overrides it without changing any project file:
- Put an image named
car.webp(alternativelycar.png,car.jpg) into thepersonalfolder next to the database.- Mac, native:
data/personal/car.webp - Unraid:
/mnt/user/appdata/evcc-kalender/personal/car.webp(the folder is mounted into the container, no restart needed) - elsewhere:
personal_dirinconfig.yaml
- Mac, native:
- Reload the page. The image appears on the vehicle card.
Rules: the login page always shows the default image. Your own image is only served after login and then replaces the default.
If your own image is missing, the default stays. The personal/ folder (and data/) is in .gitignore, so the image never ends up in the repository.
Recommended: a cut-out car (transparent background) in side view, about 1200 pixels wide, under 8 MB. The UI does not crop or convert anything.
Later (not before 0.3): set an image per vehicle reported by evcc in the UI, with automatic cropping and format conversion.
Languages
The language (en default, de) applies to the UI, push messages and API errors. Log output is always English. The keywords "Auto"/"Car" and "Bahn"/"Train" in an
appointment are recognised in both languages whatever the setting is. To add a language, copy evccplan/static/locales/en.json to <code>.json, translate the
values (keep the keys and the {placeholders}) and select it in the UI; tests/test_i18n.py checks that all languages have the same keys and placeholders.
Versions
Changes in detail: CHANGELOG.md. The version is in evccplan/__init__.py. Before 1.0 the middle number rises with new features,
the last one with bug fixes. Version 1.0 would be the open-source release.
| Version | Highlights |
|---|---|
| 0.8.1 (current) | Optional preconditioning through a Home Assistant climate entity, with extra charging time and minimum charging while heating; MQTT discovery for Home Assistant with the next appointments and optional commands |
| 0.8.0 | Optional MQTT: live status from evcc's topics instead of polling, next plan published for Home Assistant |
| 0.7.1 | Fix: OpenRouteService moved to api.heigit.org, geocoding and routes work again |
| 0.7.0 | Lateness warnings respect the charge buffer, single status chip, evcc button, notification routing tab with quiet hours, car charge limit raised via Home Assistant |
| 0.6.2 | Back-to-back appointments are planned as one tour with direct legs instead of a round trip each (far lower target), correct charge window for chained appointments |
| 0.6.1 | Calendar view hides appointments without charging (toggle), push fixes: per-target delivery, Telegram MarkdownV2 escaping, no warnings for past plans |
| 0.6 | Several calendars with a name label, overlap conflicts, charge buffer (extra when cold), pushes for "not plugged in" / "starts earlier" / "plan not reachable" |
| 0.5 | Charge window, progress and cost forecast per appointment (with PV share), real cost of finished sessions, shorter run history, warning when a plan cannot be reached |
| 0.4 | Live status (plugged in, charging, power, PV / grid / home), link to GitHub |
| 0.3 | Settings and history tabs, English and German |
| 0.2 | Login, per-appointment overrides, new UI, Docker image on ghcr.io |
| 0.1 | Calendar, route, plan in evcc, dry run, push via Home Assistant |
Future ideas
Not scheduled for any version yet:
- Live run button (a run in live mode started from the UI)
- Bluelink consumption (real consumption from the car instead of the configured values)
- Filter for wrongly entered appointments
- Google OAuth login
- Home Assistant optional (other notification channels; calendars can already be read via ICS)
License
MIT. Third-party components and notices: THIRD_PARTY_LICENSES.md.
Categories
Related apps
Explore more like this
Explore allLinks
Details
ghcr.io/cmdrsabre/evcc-calendar:latestRuntime arguments
- Web UI
http://[IP]:[PORT:80]/- Network
bridge- Shell
sh- Privileged
- false
- Extra Params
--user 99:100 --sysctl net.ipv4.ip_unprivileged_port_start=0
Template configuration
Port of the web UI
- Target
- 80
- Default
- 8180
- Value
- 8180
Holds config.yaml, state.db and the optional personal/ folder
- Target
- /data
- Default
- /mnt/user/appdata/evcc-kalender
- Value
- /mnt/user/appdata/evcc-kalender
Home Assistant long-lived access token
evcc API key
OpenRouteService API key
Container time zone
- Target
- TZ
- Default
- Europe/Berlin
- Value
- Europe/Berlin