Dr Neil Paul

Neil's AI Tip #9 — Here's Your Starter Project: Your Own Energy Analyser

· Also posted on LinkedIn — view on LinkedIn

Drafted with Claude, the AI that also did the building — edits and comments welcome.

The tips so far have been about how to work with AI. This one is a complete worked example you can copy tonight in just a browser — nothing to install — with real data, a real payoff, and my mistakes left in, because they turned out to be half the lesson. I should say upfront: I’m not a developer and I’m not an energy expert. I’m learning this in the evenings and sharing it as I go. That’s rather the point.

How this started

We’re thinking about solar and batteries at home. The salesmen have glossy projections; I wanted facts about our house. When does it actually use electricity? Digging around, I found that Octopus Energy — my supplier; others exist and I’m not advocating — publishes an API: a doorway that lets software ask their systems questions directly. Behind it sits my own half-hourly smart meter history, about thirteen months of it, plus live prices for every tariff they sell.

A chat window can’t reach any of that. An AI that writes code can. Discovering the size of that difference has been the theme of my year.

The safety briefing I wish someone had given me

The API comes with a key — a long string from your account page (octopus.energy → Account → Developer settings). It works like a password for your data, and three rules cover it:

Know what it can do. This one is read-only: it can see your usage and account details, but it cannot switch your tariff, spend money, or change anything. That bounds the worst case — and it’s why I’m comfortable using this particular key as a teaching example.

Know how to kill it. One click on the same page regenerates it; the old one dies instantly. Before using any key, find its revoke button. It’s the difference between lending someone a window and lending them a door.

Keep it out of the AI chat. Conversations with an AI are stored on that company’s servers. Your AI writes the machinery — it never needs the actual key. You’ll paste the key into the finished page on your own computer, not into the conversation. The prompt below makes your AI enforce this itself.

Why I didn’t just build you an app

I nearly did — my continuity analyser lives on this blog and people use it. But that tool can make a promise you can verify: it calls no servers at all. This one must call Octopus, so a hosted version’s promise shrinks to “trust me about which calls it makes.” Worse, it would train you to paste API keys into other people’s websites — the exact habit the safety briefing exists to prevent. So you get my prompt instead of my app, and your own AI builds you a private copy.

One more thing I learned writing this: you can check the finished page rather than trusting it. Open your browser’s developer tools (F12), click the Network tab, and use the report — the only server it should ever talk to is api.octopus.energy. If you see anything else, close it and ask your AI why.

Which model? A habit I stole from the models themselves

Every AI tool now has a model picker, and I used to ignore it. What I do now — using Claude’s names, but the tiers exist everywhere — is use the top model (Fable) to design the prompt, a builder model (Opus, or Sonnet for something this size) to write the code, and the top model again to review what got built. Design and scrutiny are where judgement lives; the typing in the middle is honest work a cheaper, faster model does well.

I didn’t invent this. Mid-way through another project, the top model finished designing, announced the build was now straightforward, and effectively handed the job downwards itself. And the review step has earned its keep in this very project — it caught a bug where my energy figures were being quietly double-counted. I’d written the bug; the review found it. If your tool only has one model, keep the habit anyway: specify carefully, build, then review against the spec. It’s the shape that matters.

Step 1 — the usage report

You’ll need your account number and API key, and half-hourly data sharing switched on (a free setting in the Octopus app).

Worth spelling out before you start: there is nothing to install. No Python, no developer tools, no app store. The thing your AI builds is a single file that opens in the web browser you already have — it is a web page, just one that lives on your computer instead of the internet, with your own live dashboard inside it.

Then paste this into your AI — Claude, ChatGPT, Gemini, whichever you use:

Build me a personal electricity usage report as ONE self-contained HTML
file that I save to my computer and open by double-clicking. I'm an
Octopus Energy (UK) customer with a smart meter.

CREDENTIALS - non-negotiable guardrails:
- The page shows two inputs when opened: account number and API key.
  I paste them there, at runtime.
- The key is used only to call the Octopus API directly from my browser.
  Never store it (no localStorage, no cookies), never send it anywhere
  else. Close the page, it's gone.
- Never ask me to paste my key into this chat. If I do it by accident,
  tell me to regenerate it at octopus.energy before continuing.

TECHNICAL FACTS (so it works first time):
- Base URL https://api.octopus.energy/v1 - browser calls are allowed.
- Auth: HTTP Basic, key as username, blank password.
- GET /accounts/{account}/ - find my electricity meter point whose
  agreement has no end date; note MPAN, meter serials, tariff code.
- Consumption: /electricity-meter-points/{mpan}/meters/{serial}/consumption/
  You MUST pass period_from (15 months back) or it silently returns
  only recent days. page_size=25000, follow "next" links.
  Data lags 1-2 days behind - normal, not an error.

SHOW ME (charts drawn inline, no external libraries):
- Total, per-day average, estimated annual kWh.
- Usage by hour of day, by day over time, by month, weekday vs weekend.
- My overnight baseline and what it costs a year.
- Plain-English notes under each chart: what it means and one thing
  I might do about it.
- If a meter returns nothing, say so and point me at the half-hourly
  sharing setting - never invent data.

That prompt looks like it was written by someone who knows what they’re doing. It wasn’t — it accumulated. The line about period_from is there because my first version didn’t pass it, quietly fetched one week instead of thirteen months, and I spent a happy few minutes concluding the data didn’t exist. The “never invent data” line is there because, without it, AIs like to be helpful. Every guardrail is a scar. That’s what iterating with an AI actually looks like, and it’s why I show you the finished prompt rather than pretending I typed it out first go.

What you get back is one file. Double-click, paste in your two strings, and a year of your life in electricity appears. Ours showed an evening spike you could set a clock by, and an always-on baseline quietly costing about £90 a year.

Step 2 — the tariff comparator

Now iterate. Ask your AI:

“Add a tariff comparison: price my last 12 months of real half-hourly usage against my current tariff and every other Octopus tariff available in my region, using live prices from the /products/ endpoints (they’re public — no key needed). Mark which figures are exact and which are estimates, and don’t present any of it as financial advice.”

Then push on the answer — mine took several rounds: “the cheap tariff has a pricey 4–7pm window; how close does my evening sail to it, and what if my routine drifts?” When I ran this for a relative it surfaced a saving well into three figures a year — though I’d say check any such finding against a comparison site before switching, because only Octopus publishes live prices and your AI will be estimating the rest of the market.

Step 3 — the solar and battery calculator

The question I actually started with:

“Using my real half-hourly usage, model what solar panels and a home battery would do: how much of my consumption falls in daylight by season, what a given size of array and battery would offset, and roughly what that’s worth a year. Give me sliders for the sizes. State every assumption on screen — and tell me my roof direction and location matter, then let me set them.”

Be clear what this is: a rough model, not a survey. But it runs on your consumption shape rather than a national average, and that’s exactly what the glossy projections don’t do. Ours produced the single most useful fact of the whole exercise — our usage peaks in summer daytime, which is what solar loves — and turned the salesman’s pitch into a conversation between two models, one of which was mine. Argue with him; don’t replace him.

The point

A chat window answers questions. An AI that writes code, pointed at an API, builds you instruments — and it turns out a gifted amateur with an evening free can now build ones that used to need a developer. Nothing here needed expertise; it needed curiosity, a few rules about keys, and a willingness to be wrong in the middle. If you’re tempted to try the same pattern at work, read the IG tip first (Vibe Coding Is Brilliant. Information Governance Still Matters).

Read it — or better, do it. Then tell me what you built.