For some time now, I’ve been automating my wet goods (dishwasher and washing machine) using smart plugs to enable them to be started (or perhaps more accurately restarted) by the HEMS at the best times. However declining performance of the dishwasher prompted its replacement which now allows for improved capability.
The new dishwasher is actually quite similar to the the old one as I suspect Bosch and Siemens brands are different sides to the same coin but has a few differences:
It has a cutlery drawer rather than a removable canteen for cutlery which I quite like but does mean less height in the now middle drawer. That means in turn that taller glasses now need to be washed in the bottom drawer previously the preserve of larger plates and pans.
It is more energy-efficient using water-activated zeolite technology for drying.
It’s a connected device using Home Connect. Home Connect provides an app to configure and receive notifications from devices, but also an API. Over the next few weeks I plan to use this API to my HEMS.
It should be relatively straightforward to replace the existing script file for the smart plug with one to activate the dishwasher directly via Home Connect.
We will shortly have been in this house for six years. During that time I have created three smart control systems that improve my energy costs or efficiency:
heating controls to minimise gas purchase
self-consumption controls of the electricity generated by my solar panels to maximise value of self-consumption
smart tariff controls to buy grid electricity at the lowest price
Most homes have a single heating zone with one timer and potentially one thermostat controlling the whole house with perhaps some thermostatic radiator valves (TRVs) capping the temperature in specific rooms.
By contrast we have seven heating zones created by electronic temperature control valves (eTRVs). Each zone has its own timer. There is no central timer or thermostat. Each eTRV can summon the boiler on when cold rather than simply cap the maximum temperature like a TRV.
Some rooms also have links to other smart devices such as disabling room heating when the window is open or turning off heating early when there’s no movement in the room.
The intent is to save energy by only heating rooms that are in use.
These controls manage the diversion of any excess output from my solar panels rather than give that energy to the grid. The loads are prioritised as follows:
Powervault storage battery (fully proportional)
Car charger (stepped proportional driven by ImmerSUN relay output)
Hot water (driven by ImmerSUN fully proportional output)
Last year these controls helped me to use over 90% of the output of my solar panels avoiding buying £100s of electricity and gas. The priorities are set to maximise value – #1 avoid daytime electricity use at 16 p/kWh, #2 avoid car charging at 5-16 p/kWh, and #3 avoid gas consumption at 2.96 p/kWh.
Smart Tariff Controls
These controls manage my electric devices for lowest grid energy cost. The controlled devices are:
Battery storage (Powervault)
Electric car charger
Hot water heating (ImmerSUN)
The hardware that has this control is known as a Home Energy Management System (HEMS). My HEMS is based on a simple computer known as a Raspberry Pi. The HEMS uses foreknowledge of the electricity price and predicted solar panel output to determine when best to run the above devices. It was designed around a tariff called Octopus Agile which has 48 half-hourly prices that change daily, but is currently working with a simpler two-rate smart tariff.
Central Heating Boiler
Electric car charger
Hot water heating
Devices controlled by smart systems
Most of these solutions are made up of commercially-available items that I have perhaps combined in a way not anticipated by their manufacturers. In particular:
I created a relay module to enable the gas boiler to be turned on remotely and programmed a series of logical rules for the Apple TV’s that act as the controllers.
I identified a way to prioritise different self-consumption devices by configuring their current clamps.
I built my smart car charger integrating various items of hardware and writing the ladder logic program that runs it.
I built the HEMS from commercially-available parts and wrote the software that runs on it to control my devices.
Increasingly I’m starting to use Siri when loading the dishwasher, as in (i) load dishwasher, (ii) start dishwasher, (iii) “Hey Siri, turn the dishwasher off”, and (iv) allow the HEMS to resume the cycle when then cycle cost is most attractive. The dishwasher (and washing machine) are operated by WIFIPLUG smart plugs to achieve this.
However on occasions I used WIFIPLUG’s own app to control the plugs rather than Apple’s Home app, the Eve app, or Siri.
However I have a frustration with the WIFIPLUG app that it often takes three presses to turn the dishwasher off after starting the cycle:
Initially the app shows that the plug is off, although the plug is physically on – the first press reports a communications issue.
The second press reports that it’s turned the plug on, although the plug was physically already on.
Only the third press turns the plug off as was the original intent.
However today I discovered that the WIFIPLUG app is not supposed to reflect the live status of the plugs, instead one swipes to refresh and then presses to toggle status – so two actions in my case rather than three listed above.
I find the need to swipe to refresh completely non-intuitive as both Apple’s Home app and the Eve app show the live status of devices and there is no refresh concept, but I suppose it’s reassuring to know that the app is designed to work this way rather than being broken.
In the meantime, to the best of my knowledge, WIFIPLUG is the only smart plug not only supporting Apple’s HomeKit ecosystem, but also having an exposed API for smart home integration, making it uniquely suited to my application.
I previously described how I had integrated the washing machine into the smart home ecosystem using a smart plug so that it is (re-)started by the HEMS when the cost to complete a washing cycle will be lowest, bearing in mind that my electricity supply is a combination of paid-for electricity where the price varies each half hour and ‘free’ solar. As the means to get the best from the combination of washing machine and smart plug has been the source of some confusion within the household then I thought I would lay out how to get the best from that combination.
Starting the cycle:
Normally as found the smart plug should be on having been left on following the end of the prior load, but if not then turn the plug on using either (i) the button on the plug itself, (ii) the WIFIPLUG app or (iii) the Apple Home app.
Load the drum in the normal manner which is optional washing liquid tab first with colour-catcher if required and clothes on top.
Select and start the required cycle.
Almost immediately stop the cycle on the smart plug using the same options as in #1.
Put washing powder, fabric softener and water-treatment tablet (e.g. Calgon) in the drawer as required.
At the optimum time the HEMS will restart the cycle. Do NOT move the cycle selector dial on the washing machine while waiting for the cycle to restart or the washing machine may become confused.
Adding more clothes while waiting for step #6 above:
Pull the drawer forward so that any water admitted to the washing machine will not take the contents of the drawer with it.
Turn on the smart plug as per step #1 in the ‘Starting the cycle’ list – our washing machine starts to fill with water at this point.
On our washing machine clothes may be added during the early stages of load by pushing the start button. Washing machine briefly displays “No” and then (i) stops the water flow, (ii) unlocks the door and (iii) displays “Yes”.
Extra clothes may then be added.
Once the extra clothes have been added, the door can be closed, the start button is pressed and then the washing cycle will resume.
Stop the cycle almost immediately with the WIFIPLUG using any of the usual options.
Close the drawer.
At the optimum time the HEMS will restart the cycle.
Ending the cycle is absolutely unchanged versus the washing machine without smart controls. The washing cycle finishes. The WIFIPLUG is left on by the HEMS. The door can be opened and the clean clothes dispositioned appropriately in the normal manner.
The dishwasher works similarly but more simply. The door can be opened at any time while awaiting the restart instruction from the HEMS and items removed or added as required.
Discussion elsewhere prompted me to look into what I spent on what you might term my energy smart systems relating to electricity consumption, so I thought I’d document it here.
Solar photovoltaic system (4kW)
Bundled with ImmerSUN.
Powervault battery storage (4kWh)
Free installation as part of UKPN trial.
ImmerSUN management system with monitoring.
Estimate based on today’s pricing.
Remote-controlled car charger.
Modified used charger from eBay. My own software.
Raspberry Pi items to make HEMS
My own software.
Wet goods automation (WIFIPLUG x 2)
Prior analysis of items #1-#4 in pre-Agile days has suggested a total of 9 years to achieve payback on this investment through use of around 85% of the generated energy. Solar panels are potentially good for over 20 years operation, although I doubt the lead-acid batteries will still be operating for anything like that long.
The combination of item #5 with my Octopus Agile dynamic smart electricity tariff has resulted in my average bought electricity price being 7.75 p/kWh in 2019, about half the UK average. I suppose that I could make the same judgements and program items manually each day, but the HEMS significantly reduces my time commitment to achieve that.
Item #6 is my most recent addition. The sophistication of the algorithm combining the Agile tariff with a simple model of the cycle of each device is such that I would never achieve such a high quality result manually. However the saving is perhaps only a three pence each day so maybe £10 per year on my Agile tariff and thus 7 years to pay for the two smart plugs.
Much of this content is thus around 7 years to payback. The HEMS is potentially much quicker, but relies on having smart systems to control such as battery storage and car charger.
One of the consequences of integrating a smart home is the large number of different apps, web portals and potentially sources of APIs involved. The ones I use include:
Reads and stores consumption from smart meter.
No price data for my tariff due to smart meter limitations.
Eve’s alternative to Home for all HomeKit accessories with additional functionality for Eve’s own devices.
I prefer this to Home for editing rules. I use Eve products mostly for central heating control.
Apple’s own app for the HomeKit smart home ecosystem.
Need to refer to device manufacturers own apps (such as Eve or WIFIPLUG) for some configuration and data.
My own web portal to view HEMS schedule and status via Apache web-server on Raspberry Pi.
Control of ImmerSUN power diverter.
Available API provides some measurement and status data as per main screen of the app.
Control of Powervault storage system.
Available APIs provide some user scheduling and status capability.
Future cost, and historic costs and consumption (30 prior days) from Octopus (electricity supplier).
APIs provided by Octopus. App developed by an enthusiast using Octopus APIs. Octopus’s own web portal provides historic consumption but does not pair this with cost. Monthly statements show graph of consumption and cost for each day.
Control and measurements from own brand smart plugs.
Plugs also appear in Home and Eve apps. I use for dishwasher and washing machine.
Notes to table:
APIs not officially released. Reverse-engineered by an enthusiast and available on line.
APIs not officially released. Used as part of a sponsored trial when I first got the battery and re-used by myself with some manufacturer support.
iOS only. Not available for Android.
Some of these apps have similarities:
Both Bright and OctoWatchdog show whole of house energy consumption (and potentially cost) derived from the smart meter. However they have differences too. A smart meter sits on two networks: (i) the Wide Area Network (WAN) via which the meter communicates with the energy supplier and (ii) the Home Area Network (HAN) which links the devices in the home (electricity meter, gas meter, CADs/IHD and gateway). Bright connects to the HAN via small piece of hardware called a Glow Stick Wi-Fi CAD and collects its own data in real time and stores its own records of energy consumption in the cloud; while OctoWatchdog involves no extra in-home hardware, and takes data a day in arrears from Octopus not storing anything in the cloud itself. Bright’s USP is the real time consumption and current day’s data (neither of which OctoWatchdog supports), while OctoWatchdog’s USP is the availability of electricity price which isn’t available from the meter.
Both Eve and Home interact with all devices in the whole HomeKit ecosystem. Eve is best for creating rules and has more ability to configure Eve’s own devices, while Home is best for sharing access with family members. WIFIPLUG’s app is more limited only interacting with their own devices, and thus cannot see Eve or other HomeKit devices.
Both MyImmersun and WIFIPLUG apps, and the Powervault portal, allow configuration of their own manufacturer devices. They all have, for example, timer capability and data logging. MyImmersun is better for giving a whole-of-home view showing solar panel output and net input to house (so provides a more comprehensive energy monitor), Powervault shows no solar panel output but does give a view of whole-of-home, while WIFIPLUG provides only a view of the energy consumption of devices plugged in to the WIFIPLUGs.
So, over the last few days I’ve been adding control of my wet goods (dishwasher and washing machine) to my HEMS so that it can start washing loads at the optimum time – that is the times with the lowest projected electricity cost for a typical wash cycle.
The above image shows the prices for December 18th and 19th as downloaded by the HEMS at 16:45 on the 18th after publication of prices for the 19th. The HEMS then reviews this pricing against the need for electricity to determine when to use electricity and, in the case of the battery when to discharge the battery. I currently have the HEMS configured to provide:
3 hours of car charging
Not more than 2 hours of water heating (but only when electricity is cheaper than gas which can also heat water)
6 hours of fixed battery charging.
Best start time for dishwasher and washing machine.
I’ve described the operation of car charger, water heating, and battery previously; the new content here is the two final columns on each side for dishwasher and washing machine. The numbers in the columns are the estimated cost of a washing cycle if started at the beginning of the corresponding half-hour. The yellow colouring reflects the selected half-hour to start the appliance i.e. the one with the lowest estimated cycle cost. There’s also the option to set a threshold above which one is not prepared to pay to wash today which has resulted in the red box. If the whole day was red then the washing cycle would be deferred for consideration the next day.
The extract from the WIFIPLUG history for the dishwasher shows the typical operating sequence:
@22:19 I turn the WIFIPLUG on to enable the dishwasher to be programmed and the cycle started. The plug for the dishwasher is inconveniently at the back of a low kitchen cupboard so this was achieved via the WIFIPLUG app.
@20:20 I turn the WIFIPLUG off via the app suspending the cycle in its first moments.
@02:00 the HEMS turns the plug on remotely allowing the dishwasher cycle to continue.
The equivalents for the first two actions for the washing machine can more conveniently be achieved via the push button on the WIFIPLUG itself as the plug for the washing machine is above the counter.
The above image shows the measured power consumption from my smart meter. Almost 9 kW is being drawn at times under the action of the HEMS when the electricity price is cheapest, but also zero at times when the price is highest. The washing machine contributes to the peak spike around 02:00 when both it and the car charger are enabled. The later spiking during the peak period is the electric oven cycling on and off under control of its thermostat as the battery isn’t powerful enough to run the oven, so the excess power is drawn from the mains.
The screenshot above shows the half-hourly electricity consumption and costs from Octopus. It should be noted that this is half-hourly consumption in kWh whereas the prior chart was power so, for example, an average 6.6 kW of power consumption results in 3.3 kWh of energy consumption in a half-hour. That the blue line of price is almost the inverse of the red cost columns indicates the HEMS is doing its job to shift most energy use to when the energy price is lowest, and use the battery to offset demand when the price is highest.
Overall on the 19th I paid £1.07 for 21.776 kWh of electricity including standing charge which is independent of use. That’s 86 p for 21.776 kWh without the standing charge, or a weighted average of 3.95 p/kWh. That weighted average of 3.95 p/kWh compares to a range of 1.10 to 26.24 p/kWh during the day. According to UK power the average cost of electricity in the UK is 14.37 p/kWh so I paid 27.5% of the average UK price on December 19th.
This post describes the evolution of my HEMS code to control my dumb wet goods (dishwasher and washing machine) using smart plugs.
The program for my HEMS works as described below. For clarity I’ve emboldened the new steps associated with the control of the wet goods:
Download the cost data for Agile from Octopus. The API provides 48 hours of data, but I use only 24 hours at a time. I download at 16:45 to create a schedule from 17:00 today to 17:00 tomorrow. I use two fields only: the date-time stamp and the energy price inc-VAT.
Calculate cycle cost. Reverse sort the unit cost data in descending time, and combine the energy price with the load profile for each non-interruptible device (dishwasher and washing machine) to estimate the cost of running a washing cycle starting on each half hour. Add as third and fourth fields to the data file.
Establish start time for each non-interruptible load. For each appliance in turn, sort the cost data in ascending cycle cost. Enable the appliance for interval with the lowest cycle cost within an acceptable time window (typically the first row), and overwrite remaining instructions from the prior day. Repeat for other appliances.
Establish on times for each interruptible load. For all interruptible loads (battery, car charger and immersion heater) sort the data in ascending unit cost. Replicate the unit cost column for each interruptible load. For each load enable for the required number of half-hourly intervals within the time window set by the user, and disable for higher cost half-hourly intervals.
Prepare user screens. Sort data file by ascending time, split into first and second 12-hour periods, and present as two HTML files.
The top level scheduling script which runs automatically at 16:45 each day is a shell script which calls a series of awk scripts to: (i) calculate cycle costs for wet goods, (ii) determine start time(s) for each wet-goods appliance, (iii) determine on/off times for interruptible loads.
Awk is a pattern-matching program for processing text files. Such text files may be thought of a series of records and fields in a textual database. Awk may seem an odd choice of scripting languages, but essentially the processing of a text file of 96 time and unit pairs to create HTML files of 48 times and cost combinations is a text file processing task. Along the way as each on or off decision is made a system call to the OS is made by awk to copy an on or off script to a time-stamped script (e.g. either washingmachineon.sh or washingmachineoff.sh is copied to washingmachine_0930.sh). An internal timer called cron runs each half-hour so, for example, at 09:30 it runs all the scripts with 0930 in their names which updates the status of each controlled device.
At the time of writing we have 5 HEMS-controlled devices:
Battery storage – interruptible – the only device with 3 states (normal, charge-only, force charge).
The loads that I already control via the HEMS (that is loads which can be interrupted like battery charging, car charging and water heating) are essentially constant, that is that they draw the same power regardless of progress. The battery charging does start to tail off at particularly high states of charge, but that effect is neglected here. However the non-interruptible loads like the dishwasher and washing machine are expected to have very variable loads as the cycle continues – largely because periods of water heating demand much more power than spraying water around, spinning the drum, or pumping water out.
I thus decided that I would measure the pattern of these variable loads and use that information as part of the decision when to run the load for lowest cost. Rather than tabulate the half-hourly energy price as I do for interruptible loads, I would instead estimate the energy price to complete a load for each half hour in which I might start the cycle. This process of measuring the load pattern during a cycle I have referred to as characterisation.
I characterised the loads using a plug-in energy meter reporting kWh which I read manually every half hour during a typical wash cycle to determine the blue lines above. I then calculated the energy usage in each half hour period as per the orange line. I did all of this half-hourly as that’s the interval after which the energy price changes and correspondingly the interval at which the HEMS updates its output controls.
The measured loads confirmed my suspicions regarding variation with heat inputs providing the largest loads – twice for the dishwasher as it both heats the water at the start and heats to dry the dishes at the end, while the washing machine also heats the water at the start but spins to dry the clothes at the end (which is more energy efficient). The effect of this is that the washing machine would generally be expected to start in the cheapest half hour as that’s when it uses most energy, while the optimum time for the dishwasher is more complex to determine.
Of course the actual loads for the wash cycle will vary from the prediction for various reasons including not only the ability to select different wash cycles and options but also the smartness of the device in assessing how full it is or how dirty the utensils are.
I also decided that I would not explicitly turn these loads off from the HEMS – only turn them on. Not turning the loads off allows for some uncertainty as to the length of a cycle depending on the actual cycle selected, options selected, loading of machine etc. Not turning the outlet off also provides for the user being able to do additional loads under manual control if at home later in the day.
Internally my HEMS creates a schedule of 48 half-hourly actions each day for each load. Typically each action is either ‘on’ or ‘off’ (the fixed battery is more complex). The actions for these devices will follow a similar pattern of 48 half-hourly actions, but typically only one of those is ‘on’ and the 47 actions that would normally be ‘off’ do nothing. There existence is largely for equivalence and re-use of code, but they also ensure that the previous day’s ‘on’ command is over-written as required if the start time for the new day is different to that for the prior day.
One of the enhancements to my HEMS that I’ve had in mind for some time is to control wet goods – that is dishwasher and washing machine. I had previously thought that this might have to wait until I replaced my current machines with smart equivalents, but recently discovered that both existing machines recover after a power outage and continue their cycles. This creates the opportunity to put the machines on smart plugs, to manually start washing cycles, but then immediately turn the smart plugs off, and then use the smart plug to resume the cycle at the optimum time as instructed by the HEMS.
I already have two Eve Energy smart plugs as part of my smart heating system using Apple HomeKit, but these aren’t ideal for this application as I really need an exposed API to allow the HEMS to have control. However I then came across WIFIPLUG which, not only has an exposed API, but also Apple HomeKit compatibility (and indeed compatibility with other smart home ecosystems).
The WIFIPLUG (unlike the Eve Energy) also features an integrated on/off button allowing the washing cycle to be paused using this button, or via the HomeKit app, before later resuming under HEMS control when the energy cost is lowest.
The WIFIPLUG also has its own app which allows timers to be set and energy consumption viewed (although not in great detail) giving the ability to control via Apple’s own Home app or via the WIFIPLUG app. The one thing that I hadn’t spotted first time around is that it’s preferred to add the unit to the WIFIPLUG app (which then automatically adds to Home) whereas if you add to Home directly then you lose the ability to connect to the WIFIPLUG app later.
I was sufficiently impressed to buy a second unit even before I’d integrated the first, and indeed I now have another two on order.