A house that gets ahead of peak prices

Our power costs three times as much at breakfast as it does after midnight. Home Assistant now moves the heating, the cooling and the car out of the way.

From October to April our power company charges 26.49 cents for a kilowatt-hour between 6 and 9 on a weekday morning. At 1 in the morning the same kilowatt-hour costs 8.84 cents. In summer the expensive three hours move to the evening, 6 to 9 PM. Not much in a house has to happen in exactly those hours, so on 3 November we asked ours to stay out of them.

5:05 get 2 degrees ahead6:00 coast9:00 go back1 AM369114 PMOn-peak, 26.49 centsDiscount, 8.84 centsEverything else, 13.12 cents
A winter weekday. The thermostats move just before the peak, coast through it and go back after it.
Hours, October to April Cents per kilowatt-hour
On-peak: weekdays, 6 to 9 AM 26.49
Discount: every day, 1 to 3 AM and 11 AM to 4 PM 8.84
Everything else 13.12

Get ahead, then coast

Heating and cooling are the big load that can move. The rule Home Assistant runs on our three thermostats has three steps:

  1. Get ahead. Just under an hour before the peak, each thermostat moves 2 degrees toward comfort: warmer on a cold morning, cooler on a warm evening. The house does that work at the ordinary price.
  2. Coast. Through the three peak hours, each thermostat lets the house drift 2 degrees the other way before it will run. Heating waits until it is 2 degrees colder, cooling until it is 2 degrees warmer.
  3. Go back. When the peak ends, every setting returns to where it was.

All temperatures here are Fahrenheit. Two degrees either way is the whole of it.

The car

The car got its rule the same day. At home it charges only in discount hours, and a “charge now” switch overrides that until the car is unplugged. A week later we rewrote the rule with a switch for each price period, so the ordinary hours can be allowed as well.

The one-second bug

Two mornings in, the air conditioning ran for seven minutes during the peak. The history showed why. The thermostat has a schedule of its own, which changes its settings at set times. That morning one of those changes reached Home Assistant one second after our rule had read the settings. The rule did its sums from the overnight numbers, pulled the cooling limit down to 71, and the air conditioning came on at 6:19.

The fix was to stop racing the thermostat. The rule now starts at five past the hour, after the schedule has had its say, and it reads and restores settings three minutes after each price change for the same reason. A change made before the peak, by a schedule or by a person, becomes the new normal that the rule drifts from and returns to. A change made during the peak is left alone.

Asking the forecast first

The same morning we asked ourselves whether the rule looked at the weather. It did not. Now, before it moves anything, it reads the hourly forecast for the three peak hours:

Forecast for the peak hours What happens first
Any hour below 50 degrees Warm 2 degrees
Any hour at 70 degrees or above Cool 2 degrees
In between Nothing
No forecast Winter counts as cold, summer as warm

Whatever the forecast says, the thermostats still coast through the peak.

The small rules

Most of the work was in the cases around the edges:

  • A thermostat that is off, offline or in Eco mode is skipped.
  • On a holiday there is no peak, so the early move is undone after 70 minutes.
  • Before anything moves, the rule writes down what to put back. After a restart, a second rule reads that note and finishes the job.
  • Each thermostat is set in one call, so its heating and cooling limits never arrive out of order.

What we do not know yet

We cannot tell you what this saves. The meter’s hourly numbers are not in Home Assistant yet, and until they are, any figure would be a guess.

We can tell you the rule that runs now was tested before it touched the house: 69 checks against a throwaway copy of Home Assistant, with fake thermostats and a fake forecast. The first version had 40 checks, and the real thermostats still found the bug above.

The same prices are behind the switch that turns off every GPU.