Shutting Down Rooms Using Home Assistant

Looking at optimising solar usage in the house is pointless without examining the background power draw of the house. If the background usage is high, we will burn through the energy stored in the house battery and start importing from the grid once the sun goes in.
The stored data/live views of the house can show the overall background power consumption, but not the specific detail. To avoid differences in consumption caused by appliances like TVs and cookers, I looked at the data when everyone was asleep.
The result was a surprisingly high ‘idle’ hourly consumption that I then needed to investigate further. To automate as well as measure the power, I invested in several ‘smart plugs’ from Xavitech *
These wifi connected plugs are part of the Tuya Smart Life platform with a simple application that allows you to control the plug (on/off) along with power usage.
I connected these plugs to devices like TVs, set-top boxes, consoles and audio systems to get an idea of exactly what was using the energy.
With all the data collected I identified 3 main areas in the house that would make a difference :
- My office.
- The living room.
- The Kid’s Room.
So I bought some more of those plugs and used simple schedule automation to ensure that all these devices got switched off by the time the household usually went to bed.
Whilst that had an instant impact on energy usage I realised it had a bunch of drawbacks :
- Having a hard shutdown time isn’t very family-friendly when it turns the tv/audio off in the last 5 minutes of a movie that just happened to overrun the scheduled shutdown time.
- We tend to have gravitated to either the kid’s room or the living room by early evening. This leaves the other room empty and using energy until the scheduled shutdown time.
- Some days I burn the midnight oil in the office, at other times I’ve finished by the early afternoon. The usage doesn’t fit a good scheduled pattern.
Home Assistant is a fantastic home automation platform. It runs on pretty much any hardware and is capable of controlling systems from varied suppliers. As such it is a great place to create automations.
My house already has some Philips Hue lighting in several rooms and an alarm system that is home assistant compatible.
To solve the living room and kid’s room shutdown issue I decided to attempt to determine if people are using a given room. Given that we tend to have picked one room or the other after 8 pm, the system would check every 15 minutes after that to see if any of the lights in that room are switched on. If non are on then turn off the devices in that room.
The above automation is split into three segments. The Triggers contain a cron-like time pattern, in this case, I’ve asked it to fire every 15 minutes.
The Conditions section contains three clauses that are all treated as AND conditions (all have to be true). ‘Willets Play Main 1’ is off, check that the main light in the room is switched off.
The ‘Time condition’ checks that the time is after 8 pm and before 5 am on any day of the week.
The ‘Play 1 socket is on’ condition checks that the main plug in the room is currently on. This saves sending a turn-off command to all the plugs if they are already switched off.
The Actions section contains the operations to perform if all the conditions in the Conditions section are true. In this case, it switches four different sockets off in the room.
Home Assistant is doing some impressive integration here, it is reading data from the Philips Hue system and then sending messages to the Tuya smart life platform. You can’t do this using the two platforms own apps as they have no knowledge of devices from other suppliers.
What if someone wants these devices switched on after they have been turned off? A simple automation triggered by turning the light on that toggles the power switches back on.
The office was more of a challenge. I often like to work without external light, so using the light status isn’t appropriate in this case. Again Home Assistant has a solution. The office has a motion detector and Home Assistant can tell when motion was last detected. So in this case the plugs in the office are turned off if no motion has been detected for more than an hour.
With these automations in place, we have reduced the background house power usage by around 2.5kWh per day.
A few additional tips :
- Don’t power off devices with disk drives this way (including Sky boxes). They really don’t like it.
- Home Assistant can be used to issue ssh commands to computer systems to issue commands like shutdown and wait before powering them down.
- Make it easy to bring things back online and explain the manual way if needed. For example, all the switches linked have a toggle button that you can press if anything fails.
- Hue and my alarm system both work locally. By default, Tuya smart devices need internet access, so in theory, you need to act manually if the internet connection goes down. (It is possible to operate Tuya devices locally, but that’s beyond the scope of this document).