Big pickle Plan
Artificial Intelligence

Big pickle Plan

To understand this blog post you need to read the post "Keeeping token cost down and evaluation test"

Jan Petersen
July 4, 2026
8 min read
2 views

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)

TimeActionTesla API callsCost
14:00 CETFetch Energinet DK1 prices0$0
18:00Poll 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:00Optional: re-check if SOC changed dramatically1 Data ($0.002)$0.002
Window startwake_up + charge_start1 Wake ($0.02) + 1 Cmd ($0.001)$0.021
Window endcharge_stop1 Cmd ($0.001)$0.001
Total/night$0.024-$0.026
Monthly~$0.72-$0.78

Schedule Algorithm (from big-pickle, improved)

  1. Fetch hourly spot prices from Energi Data Service (DK1/DK2 configurable)
  2. 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)
  3. Read last known SOC from cache (from MAI — use cached state to avoid extra polls)
  4. If no cached SOC or cache >2h old → poll vehicle_data (1 call)
  5. kwh_needed = (target_soc - current_soc) / 100 × battery_kwh
  6. hours_needed = ceil(kwh_needed / charger_kw × 1.15) (15% efficiency buffer)
  7. Filter hours: [now, departure_time] excluding past hours
  8. Find cheapest contiguous window of hours_needed length
  9. 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)

ScenarioBehavior
Car already at/above target SOCSkip night. Log: "Already charged."
Not plugged in at checkAbort night. Log + optional ntfy notification.
Price API (Energinet) downUse last cached prices. If no cache, skip night.
Tesla 429 rate limitExponential backoff: 1min → 5min → 15min → abort night.
charge_start failsRetry once after 30s. If still fails, log + ntfy + abort.
charge_stop failsRetry once after 30s. Log + ntfy. Car stops on its own at target SOC.
Container restart mid-chargeOn boot: check vehicle_data. If charging and past window, stop.
Token refresh failsClear 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)

FieldTypeDefaultSource
target_socnumber80big-pickle
departure_timestring"07:00"big-pickle
monitor_startstring"18:00"big-pickle
charger_kwnumber11big-pickle
battery_kwhnumber75big-pickle
regionstring"DK1"Kimi
active_daysbitmask62 (Mon-Fri)big-pickle
tariff_tiersobjectKonstant modelbig-pickle
ntfy_topicstring""big-pickle
tesla_client_id/secretstringbig-pickle
use_fleet_telemetrybooleanfalsenew — 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)

  1. Scaffold: docker-compose.yml, app/Dockerfile, vcp/Dockerfile, package.json, tsconfig.json
  2. Config layer: config.ts, JSON read/write, config schema
  3. Tesla auth: auth.ts, keys.ts, OAuth PKCE flow, setup wizard UI
  4. Tesla client: client.ts, VCP proxy wrapper, start/stop/wake/SOC
  5. Price fetcher: energinet.ts, tariffs.ts, price_cache.json
  6. Optimizer: optimizer.ts — cheapest contiguous window
  7. Scheduler: scheduler.ts — node-cron jobs at 14:00, 18:00, 20:00 + window boundaries
  8. Executor: executor.ts — command loop with retry
  9. API usage tracker: api-usage.ts — log each call, expose via API
  10. UI pages: layout, dashboard, prices, settings, setup
  11. Manual overrides: charge now, stop, skip tonight endpoints + UI buttons
  12. Notifications: ntfy.ts
  13. Cloudflare Tunnel docs for HTTPS OAuth callback

Budget (from big-pickle, verified against Tesla pricing)

ItemMonthlyNotes
Tesla Fleet API~$0.72-0.78Well within $10 credit
VPS/home server$0Docker on existing hardware
Energinet API$0Free, open data
ntfy.sh$0Free, 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

FeatureOrigin
Full architecture, cost analysis, error handling, project structure, UI design, tariff model, Dockerfilebig-pickle
Conservative polling (18:00/20:00), API usage tracker, manual overrides, Cloudflare TunnelKimi K2.7 Code
Cached-state persistence conceptMAI
Fleet Telemetry upgrade pathTesla Fleet API docs

Share this post

Related Posts

Comments

Be the first to leave a comment.

Leave a comment

Comments are reviewed before they appear.