Thinking House Lab
EN

Language

  • English
  • Deutsch
  • Français · coming later
  • Español · coming later
  • 中文 · coming later

Power Flow Logic · Episode 1 · Chapter A

When is electricity actually cheap?

My battery was 99 % full, and the system switched off the heat pump anyway. The reason was a single number: the price of electricity. More precisely, the wrong one.

UnderstandComing soonBatteryCostsHeating9 min read

The episode

In production – coming soon

The video is in production. Until it's online, this article tells the whole story.

The video is level 1. This article adds first details from levels 2 and 3. Graphs from the running system that show what happens when, and why, follow at level 2.

In short

  1. Treat the battery like an account: solar goes in at zero, grid electricity at what you actually paid for it.
  2. Taking energy out never changes the price. Only adding energy changes the mix.
  3. For every decision, first ask where the electricity would come from right now. Then use the price of that source.
Chapters in the video
  1. 01A strange decision
  2. 02What does battery electricity cost?
  3. 03The battery is an account
  4. 04Let's do the maths
  5. 05Almost zero, and correct
  6. 06Two wrong fixes
  7. 07Heat pump or gas?
  8. 08The tipping point
  9. 0969 hours → 0 hours
  10. 10The rule
  11. 11Outlook: grid charging
  12. 12Summary

Time stamps appear with the release.

Example pricesAll prices on this site are example prices from one real house, and all energy amounts are example values. Your tariff, your currency and your numbers will be different. The logic works the same in euros, dollars or pounds.

A strange decision

One afternoon in September, at five o'clock, my system did something strange. Right then, a kilowatt hour from the grid cost 98 cents. I'm on a dynamic tariff, and the price can change every 15 minutes. So the system switched off the heat pump and fired up the gas boiler instead.

The house at 5 p.m. – one day in September
  • Grid price98 ct/kWh
  • Battery99 %
  • Heat pumpOFF
  • Gas boilerON

Sounds sensible: electricity expensive, gas cheaper. Except for one detail. The battery was 99 % full. The heat pump could have run entirely on the battery and the sun. I only spotted it by chance: the energy flow on my dashboard showed gas while the sun was shining.

So what went wrong? Was the system looking at the price in the wrong place? Or did it have no current price at all? To answer that, we need a question that sounds simple but isn't: when is electricity actually cheap?

The price that really matters

More precisely: what does one kilowatt hour from my battery cost? Because that's the electricity my house actually uses. If the system gets that number wrong, it makes wrong decisions. In my case: 69 hours of them in a single month.

A quick look at my setup, because it matters here. My house mainly runs on the battery, or straight on solar while the sun shines. The battery is filled by the solar panels, and in winter, when the sun isn't enough, it can be topped up from the grid. So there are exactly two ways for energy to get into the battery, and they cost very different amounts.

The battery is an account

The trick is to treat the battery like a bank account. Every kilowatt hour that goes in brings its price with it. Solar costs nothing, because the panels are already paid for. Grid electricity costs whatever I actually paid for it. That gives the stored energy a value in money, and that value helps decide between heat pump and gas.

The price of one kilowatt hour in the battery is then simply what the contents cost, divided by how much is in there.

Battery price = cost of the contents ÷ energy in the battery

Let's do the maths

Let's do the maths with example numbers. Yours will differ, the logic won't. Say the sun puts 10 kWh into the battery, at zero cost. Then, on a dark day, 5 more kWh come from the grid at 30 cents each. That's €1.50.

Step 1: filling up (example)
EnergyPriceCost
Solar10 kWh0 ct/kWh€0.00
Grid5 kWh30 ct/kWh€1.50
In the battery15 kWh€1.50

€1.50 ÷ 15 kWh = 10 ct per kWh

Battery content: 15 kWhprice 10 ct/kWh
  • Solar 10 kWh · 0 ct
  • Grid 5 kWh · 30 ct

Taking energy out doesn't change the price

Now the house uses 10 kWh. What happens to the price? Nothing. It stays at 10 cents. There are 5 kWh left, worth 50 cents.

Step 2: the house uses 10 kWh (example)
EnergyPriceCost
Before15 kWh10 ct/kWh€1.50
Taken out−10 kWh10 ct/kWh−€1.00
Left in the battery5 kWh€0.50

€0.50 ÷ 5 kWh = still 10 ct per kWh

Battery content: 5 kWhprice 10 ct/kWh
  • Solar 3.3 kWh · 0 ct
  • Grid 1.7 kWh · 30 ct

Think of a jug of lukewarm water. Pouring some out doesn't make the rest warmer or colder. The mix stays the mix.

Only adding changes the mix

Another 5 kWh come from the grid, again at 30 cents. That's €1.50 more.

Step 3: another top-up from the grid (example)
EnergyPriceCost
Already in the battery5 kWh10 ct/kWh€0.50
Grid5 kWh30 ct/kWh€1.50
In the battery10 kWh€2.00

€2.00 ÷ 10 kWh = 20 ct per kWh

Battery content: 10 kWhprice 20 ct/kWh
  • Solar 3.3 kWh · 0 ct
  • Grid 6.7 kWh · 30 ct

Every expensive top-up from the grid pushes the price up. Every sunny day dilutes it again.

Almost zero, and correct

Which leads to a number that looks like a bug. In summer, when the battery is filled almost entirely by the sun, the price drops to something like a hundredth of a cent per kilowatt hour.

0.01 ctper kWh from the battery in summercorrect

It isn't a bug. It's the correct answer: the energy in the battery really did cost almost nothing.

Two wrong fixes

A number that small looks suspicious. I write the code with an AI, and twice the AI tried to “repair” this number. I followed along and judged the results. Both repairs sounded perfectly reasonable.

  • Fix 1: use the grid price instead. But the current grid price is a price I don't pay. At that moment the electricity came from the battery, not the grid.
  • Fix 2: use what the energy could have earned elsewhere. That only makes sense if you could sell it. In this example there's no feed-in payment, so there's no second price to compare with.

Both were wrong. The real cost is what went into the account. Nothing more, nothing less. Battery wear isn't in this price either, on purpose: when I tried adding it once, it pushed my system towards gas instead of almost-free solar.

Heat pump or gas?

Why does this matter so much? Because of decisions like the one at the beginning. With one kilowatt hour of electricity, a heat pump delivers several kilowatt hours of heat, most of it taken from the outside air. That factor is called the COP, the coefficient of performance. With a COP of 3, one kWh of electricity delivers 3 kWh of heat. The COP isn't fixed: on warm days it goes well above 6, and I've measured up to about 7.5. In the cold, at −6 °C, it drops to around 2.5.

Heat price (heat pump) = electricity price ÷ COP

The gas boiler has a kind of COP too: its efficiency, about 0.97. So gas heat has its own price per kilowatt hour of heat:

Heat price (gas) = gas price ÷ efficiency

Whichever is cheaper wins. Let's plug in numbers: winter, COP 3. My real values around freezing are between 3 and 4, but 3 keeps the maths simple. Gas heat costs me around 10 cents, without the standing charge.

Heat from the battery (COP 3) ct per kWh of heat
  • Heat pump · battery at 10 ct3.3 ct
  • Gasabout 10 ct

From the battery, the heat pump wins by a factor of three. Now the same winter, but the battery is empty and has to be refilled from the grid at 42 cents. Then battery electricity costs around 42 cents too. Divided by three, that's 14 cents per kilowatt hour of heat:

Heat from the grid at 42 ct (COP 3) ct per kWh of heat
  • Heat pump · grid at 42 ct14 ct
  • Gasabout 10 ct

Now gas is clearly cheaper. So “heat pump or gas?” has no fixed answer. It depends on where the electricity would come from, and what price it carries.

The tipping point

You can even calculate the electricity price at which the heat pump starts to lose: the price of gas heat times the COP. Below it, the heat pump wins. Above it, gas does.

Tipping point = gas heat price × COP

Tipping point with gas heat at about 10 ct ct per kWh of electricity
  • Winter · COP 3.0about 30 ct
  • Mild weather · COP 5.9about 60 ct

In winter, with a COP of 3, the heat pump only loses once electricity costs more than about 30 cents. In mild weather, with a COP of almost 6, the line is at about 60 cents. A battery at 10 cents doesn't even come close.

Over a whole week in an example home, it plays out like this: on sunny days the battery price stays near zero and the heat pump does all the heating; after grey, cold days and a night-time top-up from the grid, the price climbs, gas wins in the coldest hours with a low COP, and once the sun comes back, the price falls again.

69 hours → 0 hours

Now the mistake from the beginning makes sense. The old rule only ever looked at the grid price. At five that afternoon, it saw 98 cents and blocked the heat pump. Yet the battery was 99 % full, and the heat pump could have run on it for a fraction of a cent per kilowatt hour. So the system did have a current price. It just looked at the wrong one: the grid's instead of the battery's.

69 h → 0 hheat pump wrongly blocked in 30 days: old rule vs. battery-price rule (recalculated)

Over 30 days, that rule blocked the heat pump for 69 hours. In every single one of those hours, the battery was more than 60 % full. More than 60 % full, and still blocked. With the right price, it would have been zero hours.

Same 30 days (19 August to 18 September, 728 hours of data): the lowest charge level in those 69 hours was 64 %. The 0 hours are recalculated from the same data, not measured. And if the battery had been empty, the new rule would have blocked those hours too, because then the grid price really would have been the price of the source.

The rule

Where would the electricity come from right now? Then use the price of that source.

This applies to any price decision in a house. Not the price on the news. Not the price that feels right. The price of the source.

And in your house?

The account works for any battery. Two details depend on your setup:

  • If your system feeds electricity into the grid, the feed-in payment you give up by storing is a real price. Then solar isn't free in your account: it costs what you could have sold it for. Without a feed-in payment, as in this example, it really is zero.
  • This example leaves out losses and wear on purpose. Charging and discharging cost a noticeable share of the energy, often 5 to 15 percent, and every cycle ages the battery a little. Both are real, but they're a topic of their own, and they don't change the principle.

Outlook: grid charging

Which leads to the obvious next question: when is grid electricity cheap enough to fill the battery? That's trickier than it looks.

  • Since October 2025, the day-ahead market, where electricity for the next day is traded, sets its own price for every quarter hour: 96 a day.
  • Prices for tomorrow only arrive in the early afternoon.
  • So you never see more than about a day and a half ahead.
  • When the price you actually pay is zero or below: an easy yes.
  • Everything else: only if the battery would actually run short.

That's the topic of a later episode: Grid charging in winter: never just fill it up.

Summary

  • The battery is an account: solar goes in for free, grid electricity at what you paid.
  • Taking energy out never changes the price. Only adding does.
  • For every decision, use the price of the source the electricity would actually come from.

Measured values (98 ct, 99 %, 69 h, 64 %, COP, gas heat about 10 ct) come from the running system and are rounded. The kWh amounts and the 30 ct and 42 ct in the worked examples are example numbers.

Try it yourself

Change the numbers and watch the battery price. The calculator runs entirely in your browser; nothing is sent anywhere.

The calculators need JavaScript. The tables above show the same example.

Starts with the example values from the video. Amounts are shown in euros and cents; the maths works the same in any currency.

Rebuild: the account in a few lines

The whole logic fits into a few lines. This is simplified code, not the code of my system, but it calculates exactly what's described above.

The idea in 10 lines of pseudocode
on charge(kwh, price):
    energy += kwh
    cost   += kwh * price        # every kWh brings its price

on discharge(kwh):
    avg     = cost / energy       # price does not change here
    energy -= kwh
    cost   -= kwh * avg

price() = cost / energy if energy > 0 else unknown
Python example
class BatteryAccount:
    def __init__(self):
        self.energy_kwh = 0.0   # what's in the battery
        self.cost_eur = 0.0     # what that content cost

    def charge(self, kwh, price_eur_per_kwh):
        # every kWh brings its price with it
        self.energy_kwh += kwh
        self.cost_eur += kwh * price_eur_per_kwh

    def discharge(self, kwh):
        # energy leaves at the current average price
        kwh = min(kwh, self.energy_kwh)
        if kwh <= 0:
            return
        price = self.cost_eur / self.energy_kwh
        self.energy_kwh -= kwh
        self.cost_eur -= kwh * price

    def price(self):
        if self.energy_kwh <= 0:
            return None         # empty: no price, not zero
        return self.cost_eur / self.energy_kwh
acc = BatteryAccount()
acc.charge(10, 0.00)    # solar
acc.charge(5, 0.30)     # grid
acc.price()             # 0.10 € per kWh
acc.discharge(10)
acc.price()             # still 0.10 € per kWh

Code licence: MIT. No warranty, use at your own risk; see the note in the imprint.

A more complete version for level 3, with losses, feed-in and a price log, is planned.

On the logic map

This episode brings colour to three blocks:

  • Battery price

    Keeps the account: solar at zero, grid at what it cost. Taking energy out doesn't change the price.

  • COP map

    Learns how much heat one kilowatt hour of electricity delivers, depending on outdoor and flow temperature.

  • Heat price decision

    Compares battery price ÷ COP with the price of gas heat. The cheaper source wins.

Chain 4 · Heat pump or gas?

Open the map

Downloads

  • This article as a PDF

    follows with the release

  • Calculator as a spreadsheet

    follows with the release

  • Code: battery account (pseudocode + Python, MIT licence)

    follows with the release

Sources

Terms in this episode

More on grid charging: Grid charging in winter: never just fill it up (planned)

Your turn

How do you price the electricity in your battery? Or do you not bother at all? Both are allowed. Tell me in the comments under the video, doubts included. Good ideas get picked up and built in public.

To the channel