
Big pickle Plan
To understand this blog post you need to read the post "Keeeping token cost down and evaluation test"
Plan Evaluation Criterion big-pickle Kimi K2.7 MAI Completeness 9/10 — full file tree, endpoints, cost analysis, error table 6/10 — good structure, lacks detail 3/10 — rough outline only Cost optimization 8/10 — great cost breakdown but polls every 15min unplugged 9/10 — polls only 18:00+20:00, API usage tracking 5/10 — mentions "low reads" no specifics Error handling 10/10 — 9 scenarios fully covered 3/10 — none specified 2/10 — none specified Auth flow 9/10 — full OAuth PKCE + VCP 8/10 — same approach, less detail 3/10 — no specifics UI/UX 9/10 — htmx+Tailwind, Chart.js, 4 pages 5/10 — vanilla JS, no chart 1/10 — no UI mentioned Practicality 8/10 — single container, simple deploy 8/10 — Cloudflare Tunnel for OAuth 4/10 — too vague to implement Winner: big-pickle — it's the most complete, production-ready, and well-thought-out plan by a significant margin. Kimi K2.7 has a few smart refinements worth incorporating. MAI is too thin to compete.
Tesla Cheap-Hour Charger — Optimized Plan
Goal
A Docker app that charges a Tesla during Denmark's cheapest electricity hours, reaching a target SOC by morning departure, staying well within the $10/month Tesla Fleet API credit (<$2/month budget).
Architecture
┌──────────────────────────────────────────────┐
│ Docker Compose │
│ │
│ ┌──────────────────────┐ ┌───────────────┐ │
│ │ App Container │ │ VCP Sidecar │ │
│ │ (Node.js + Express) │ │ (Go proxy) │ │
│ │ │ │ port 4040 │ │
│ │ - Auth flow │ └───────┬───────┘ │
│ │ - Scheduler (cron) │ │ │
│ │ - Price fetcher │ │ │
│ │ - Optimizer │ │ │
│ │ - Web UI │ │ │
│ │ - API usage tracker │ │ │
│ └─────────┬────────────┘ │ │
│ │ │ │
│ ┌────▼───────────────────────▼────┐ │
│ │ /app/data/ (mounted volume) │ │
│ │ ├── config.json │ │
│ │ ├── ec_private_key.pem │ │
│ │ ├── price_cache.json │ │
│ │ └── api_usage_log.json │ │
│ └──────────────────────────────────┘ │
└──────────────────────────────────────────────┘
Stack: Node.js + TypeScript + Express 5, htmx + Tailwind CSS, Chart.js via CDN, VCP sidecar (Go), JSON file storage, node-cron
Conservative Daily Cycle (from Kimi — optimized to minimize API calls)
| Time | Action | Tesla API calls | Cost |
|---|---|---|---|
| 14:00 CET | Fetch Energinet DK1 prices | 0 | $0 |
| 18:00 | Poll SOC once (vehicle_data?endpoints=charge_state) | 1 Data ($0.002) | $0.002 |
| Compute cheapest window, plan schedule | — | — | |
| If not plugged in → abort night (no re-checks) | 0 | $0 | |
| 20:00 | Optional: re-check if SOC changed dramatically | 1 Data ($0.002) | $0.002 |
| Window start | wake_up + charge_start | 1 Wake ($0.02) + 1 Cmd ($0.001) | $0.021 |
| Window end | charge_stop | 1 Cmd ($0.001) | $0.001 |
| Total/night | $0.024-$0.026 | ||
| Monthly | ~$0.72-$0.78 |
Schedule Algorithm (from big-pickle, improved)
- Fetch hourly spot prices from Energi Data Service (DK1/DK2 configurable)
- Add Danish Konstant tariffs:
- 00:00-06:00: 0.20 DKK/kWh
- 06:00-17:00: 0.45 DKK/kWh
- 17:00-21:00: 1.10 DKK/kWh
- 21:00-24:00: 0.45 DKK/kWh (Tariff tiers editable via UI)
- Read last known SOC from cache (from MAI — use cached state to avoid extra polls)
- If no cached SOC or cache >2h old → poll vehicle_data (1 call)
kwh_needed = (target_soc - current_soc) / 100 × battery_kwhhours_needed = ceil(kwh_needed / charger_kw × 1.15)(15% efficiency buffer)- Filter hours: [now, departure_time] excluding past hours
- Find cheapest contiguous window of
hours_neededlength - If no suitable window → skip night, log, notify
API Usage Tracker (from Kimi)
Each API call is logged to api_usage_log.json with timestamp, endpoint, and cost. Dashboard displays:
- Today's call count & cost
- Month-to-date total
- Projected monthly cost vs $10 credit
Manual Overrides (from Kimi)
Dashboard buttons:
- Charge Now — start charging immediately (ignores cheapest-window logic)
- Stop Charging — cancel current charge session
- Skip Tonight — skip scheduling for tonight only
Error Handling (from big-pickle)
| Scenario | Behavior |
|---|---|
| Car already at/above target SOC | Skip night. Log: "Already charged." |
| Not plugged in at check | Abort night. Log + optional ntfy notification. |
| Price API (Energinet) down | Use last cached prices. If no cache, skip night. |
| Tesla 429 rate limit | Exponential backoff: 1min → 5min → 15min → abort night. |
charge_start fails | Retry once after 30s. If still fails, log + ntfy + abort. |
charge_stop fails | Retry once after 30s. Log + ntfy. Car stops on its own at target SOC. |
| Container restart mid-charge | On boot: check vehicle_data. If charging and past window, stop. |
| Token refresh fails | Clear tokens. Re-auth required flag in UI. |
UI Pages (from big-pickle)
Dashboard (/)
- Large battery SOC display
- Charging status badge (Idle/Charging/Disconnected/Done/Planned)
- Next planned window: "Charging 03:00-05:00"
- Target SOC slider (50-100%)
- Departure time picker
- Monitor start time picker
- Manual override buttons: Charge Now, Stop, Skip Tonight
- API usage summary (today's calls, month cost)
Prices (/prices)
- 24h bar chart via Chart.js
- Cheapest hours highlighted in green
- Planned window highlighted in blue
- Current price indicator + tariff breakdown
Settings (/settings)
- Charger power (kW)
- Battery capacity (kWh)
- Car model dropdown
- Region selector (DK1/DK2)
- Active days checkboxes (Mon-Sun)
- Tariff tiers (editable)
- ntfy.sh topic (optional)
Setup (/setup)
- 3-step OAuth wizard (hidden when configured)
- Step 1: Enter Tesla Developer client_id + client_secret
- Step 2: Redirect to Tesla for authorization
- Step 3: Confirm success, show VIN, API usage tracker
Config Schema (from big-pickle, extended)
| Field | Type | Default | Source |
|---|---|---|---|
| target_soc | number | 80 | big-pickle |
| departure_time | string | "07:00" | big-pickle |
| monitor_start | string | "18:00" | big-pickle |
| charger_kw | number | 11 | big-pickle |
| battery_kwh | number | 75 | big-pickle |
| region | string | "DK1" | Kimi |
| active_days | bitmask | 62 (Mon-Fri) | big-pickle |
| tariff_tiers | object | Konstant model | big-pickle |
| ntfy_topic | string | "" | big-pickle |
| tesla_client_id/secret | string | — | big-pickle |
| use_fleet_telemetry | boolean | false | new — optional upgrade |
Project Structure (from big-pickle, optimized for 2-container setup)
tesla-cheap-charger/
├── docker-compose.yml
├── .env.example
├── app/
│ ├── Dockerfile
│ ├── package.json
│ ├── tsconfig.json
│ ├── src/
│ │ ├── index.ts
│ │ ├── config.ts
│ │ ├── scheduler.ts
│ │ ├── api-usage.ts ← from Kimi
│ │ ├── tesla/
│ │ │ ├── client.ts
│ │ │ ├── auth.ts
│ │ │ └── keys.ts
│ │ ├── prices/
│ │ │ ├── energinet.ts
│ │ │ └── tariffs.ts
│ │ ├── charging/
│ │ │ ├── optimizer.ts
│ │ │ └── executor.ts
│ │ ├── routes/
│ │ │ ├── api.ts
│ │ │ ├── auth.ts
│ │ │ └── pages.ts
│ │ ├── views/
│ │ │ ├── layout.html
│ │ │ ├── dashboard.html
│ │ │ ├── prices.html
│ │ │ ├── settings.html
│ │ │ └── setup.html
│ │ ├── notifications/
│ │ │ └── ntfy.ts
│ │ └── utils/
│ │ ├── time.ts
│ │ └── crypto.ts
│ └── public/
├── vcp/
│ ├── Dockerfile
│ └── (Go build from teslamotors/vehicle-command)
└── data/
├── config.json
├── ec_private_key.pem
├── price_cache.json
└── api_usage_log.json
Implementation Order (from big-pickle, adapted)
- Scaffold: docker-compose.yml, app/Dockerfile, vcp/Dockerfile, package.json, tsconfig.json
- Config layer: config.ts, JSON read/write, config schema
- Tesla auth: auth.ts, keys.ts, OAuth PKCE flow, setup wizard UI
- Tesla client: client.ts, VCP proxy wrapper, start/stop/wake/SOC
- Price fetcher: energinet.ts, tariffs.ts, price_cache.json
- Optimizer: optimizer.ts — cheapest contiguous window
- Scheduler: scheduler.ts — node-cron jobs at 14:00, 18:00, 20:00 + window boundaries
- Executor: executor.ts — command loop with retry
- API usage tracker: api-usage.ts — log each call, expose via API
- UI pages: layout, dashboard, prices, settings, setup
- Manual overrides: charge now, stop, skip tonight endpoints + UI buttons
- Notifications: ntfy.ts
- Cloudflare Tunnel docs for HTTPS OAuth callback
Budget (from big-pickle, verified against Tesla pricing)
| Item | Monthly | Notes |
|---|---|---|
| Tesla Fleet API | ~$0.72-0.78 | Well within $10 credit |
| VPS/home server | $0 | Docker on existing hardware |
| Energinet API | $0 | Free, open data |
| ntfy.sh | $0 | Free, open source |
| Total out-of-pocket | $0 |
Fleet Telemetry Upgrade Path (new — from Tesla docs)
Once basic polling works, optionally deploy a Fleet Telemetry server (public HTTPS endpoint) to completely eliminate Data endpoint costs. SOC streams automatically when the car is awake at ~$0.006/hr — cheaper than polling. Requires: public server, Cloudflare Tunnel, virtual key pairing. Configurable via use_fleet_telemetry: true toggle.
Sources
| Feature | Origin |
|---|---|
| Full architecture, cost analysis, error handling, project structure, UI design, tariff model, Dockerfile | big-pickle |
| Conservative polling (18:00/20:00), API usage tracker, manual overrides, Cloudflare Tunnel | Kimi K2.7 Code |
| Cached-state persistence concept | MAI |
| Fleet Telemetry upgrade path | Tesla Fleet API docs |
Share this post
Related Posts

Plan MAI----Own plan
To understand this blog post you need to read the post "Keeeping token cost down and evaluation test" and the other posts
July 4, 2026

Plan Big Pickle----Own plan
To understand this blog post you need to read the post "Keeeping token cost down and evaluation test" and the other posts
July 4, 2026

Plan Kimi K2.7-coder----Own plan
To understand this blog post you need to read the post "Keeeping token cost down and evaluation test" and the other posts
July 4, 2026
Comments
Be the first to leave a comment.