Paul Fawkesley

Automating my dishwasher for fun and profit

In June we switched to a fully variable electricity tariff, Octopus Agile.

Every half-hour we have a different price per kilowatt-hour. This varies wildly throughout the day:

A bar chart showing 24 hours on the x-axis. On the y-axis is price and the bars range from around 35 pence at 17:00 to 3 pence at 13:00

Image from Agile dashboard

We run a dishwasher every day.

I wondered if I could automate it to optimise the cost and carbon emissions.

Controlling the dishwasher

Fortunately we have a “dumb” dishwasher with manual controls and no timers or internet connection.

Even more fortunately, if you switch the power off while it’s running and switch it on again later, it continues where it left off.

This meant it would be possible to hack together a solution using a smart plug.

Using the Shelly Plus Plug UK

A cylindrical smart-plug with a colourful LED ring and female UK socket on the front.

The Shelly Plus Plug UK is a super little smart plug.

It plugs into the socket, then you plug an appliance into it.

It can:

I’ve been using a few Shellys around the house with simple schedules.

I only recently discovered they can run Javascript with full access to everything the plug can do.

Holding off the dishwasher

Surely I could write a script that detects when the dishwasher is turned on and switches it off until the next cheapest period?

That would offer a simple user experience: load the dishwasher and turn it on as normal. Let the plug do the work. No faffing around with timed starts or annoying apps.

Getting Agile prices with the Octopus API

Since the plug can talk to the internet, it just needs to access prices by calling the Octopus API…

Octopus publishes the half-hourly prices at around 4pm each day for the next day.

They provide an API to get the prices. I used an excellent blog post from Guy Lipman to help me navigate the API.

Once I had access to the prices, I needed to work out the best time to run the dishwasher.

Deciding when to run the dishwasher

version 1: fixed time (1am)

For the first iteration, I simply started it at 1am every morning. On average this massively beats starting at 8pm, when we normally load the dishwasher.

Cut me some slack: I was doing this in random hours around childcare!

version 2: dynamic time, assuming 2 hours flat consumption

I know the dishwasher takes about 2 hours to run.

For the second iteration I simply looked for the cheapest consecutive two-hour period of Agile prices.

This worked well. The start time varied between around 1am and 4am.

version 3: dynamic time, actual consumption profile

I knew that the dishwasher doesn’t consume evenly across the four half-hourly periods.

I added the Shelly as a device in Home Assistant and let the logging begin. The next day I saw a power profile like this:

A graph showing power consumption. There are two spikes about an hour apart.

Interestingly, most consumption is in the first and fourth half-hourly period. That’s the heating and the drying cycle, when the powerful 2.2kW immersion heater comes on. The rest of the time is just a little motor using barely any power.

HomeAssistant recorded a data point any time there was a change in power (Watts). I needed to integrate that (area under the line) so I knocked up a quick Go script to convert HA’s history.csv file into a half-hourly energy profile (kilowatt-hours).

The energy profile came out like this: [0.350, 0.074, 0.014, 0.381]

I updated the code to correlate the consumption profile along the next 12 hours of Agile prices, rather than just looking for the cheapest two hours.

This was a fun optimisation over v2 but probably didn’t gain much. (It would be more important for a 7-hour washer dryer cycle with energy-intensive tumble drying towards the end.)

Putting it all together

The daily user experience looks like this:

Keep an eye on the LED colour ring of the Shelly plug in the cupboard:

Behind the scenes, this is what happens:

Quiet evenings are an unexpected benefit

As an unexpected benefit, it’s really nice being able to put the dishwasher on straight after dinner and not have it running noisily in the open plan living room.

It’s also nice to be able to add forgotten cups and plates without it complaining. Since it’s powered off, it couldn’t care less if you open the door.

So far it’s working well. I haven’t yet calculated the saving but it’s already deeply satisfying knowing it’s always running on cheap, low carbon electricity.

Win.


Thoughts? Get in touch