My home automation system
My first post in the smart home series describes how I installed a solar and battery energy storage system in my home, and my second post talks about how you could find yourself inadvertently paying for some of the energy that it generates.
In this post, I’m going to introduce the underlying system that ties each component of my home automation system together.
This is a multi-part series. Be sure to follow the “smart home” tag for more posts on this topic.
I node no better
We do this not because it is easy, but because we thought it would be easy.
At the heart of my home automation system lies a Raspberry PI3B+ running Node-RED. Node-RED is a web-based low-code programming tool that allows sequences (flows) to be strung together using a drag-and-drop style interface.
There are a plethora of guides that describe how to install Node-RED onto a Raspberry PI – a quick Google search will find most of these. Equally, Node-RED has built up a nice little community of tinkerers who have guides on how to use the software, and how to build (some quite complex) flows.
In terms of complexity, the use of Node-RED means my home automation system requires a more hands-on approach when compared to a system like Home Assistant. However, that complexity allows for a high level of configurability, which I think was necessary given the tasks I wanted my system to do. For those who don’t want the hassle of coding their system, but like home automation, I would recommend going down the Home Assistant route.
The wiring
In my first post, I described a set of design principles that I try to adhere to when building my home automation system, one of which is ensuring the system is reliable and operates not only for me but for any future homeowner. Because I cannot bank on the fact that any future homeowner will have a local Wi-Fi network, or even know how to interact with this system, I decided to go down the route of hardwiring the important bits.
In this respect, my Raspberry PI makes use of:
- A Raspberry PI 3B Relay HAT that allows me to interact with my solar inverter via its DRED interface. The DRED interface is a set of hardwired connections that allow Node-RED to tell the inverter to undertake a predefined function, like stopping the use of the battery or reducing its generation output.
- A USB to Serial (RS-485) converter, allowing the Raspberry PI to interact with my Eastron power meter and the hot water temperature controller via Modbus RTU.
Each of these integrations exposes the key data points that I can then programmatically monitor and/or control within Node-RED.
The programming
Being a graphical programming tool, any discussion about the flows I have programmed within Node-RED are best described using pictures (of which there will be a few scattered throughout this page).
I have programmed a handful of flows within Node-RED, each of which appear as a tab within the Node-RED graphical interface. Whilst some of these flows handle auxiliary functions like trending power values and sending alert emails when things go wrong, most flows support the following logic:
- Establishing a Modbus RTU connection to both the Eastron power meter and hot water digital temperature controller. With a connection established to each of these devices, Node-RED can read data from them and send commands back to them when appropriate to do so.
- Using the data it reads from the Eastron power meter, Node-RED can monitor the flow of electricity throughout various parts of my home. When this logic detects that the sun is shining and the battery system is fully charged (at which point power would start exporting to the Grid), it starts ramping up the temperature setpoint on my hot water cylinder. This, in turn, allows me to “bank” excess solar generation as hot(ter) water.
- The logic is a bit smarter than that – only slightly – and is built upon a series of IF/ELSE statements that dynamically modulate the temperature setpoint based on several conditions… If the local time is between:
- 00:00 and 09:00, then the temperature setpoint is decreased to its minimum (20C). During these two times, I am reliant on the latent heat previously stored within the hot water cylinder.
- 09:00 and 16:00, then the system is free to modulate the temperature setpoint up and down based on the amount of excess solar generation. If there’s plenty of excess generation, then the setpoint rises up to a maximum of 75C. If there is not, then the setpoint lowers to a minimum of 45C.
- 16:00 and 21:00, then the setpoint is decreased to its minimum (20C) as there is no sense in generating hot water right now as it will soon be free to do so. During these two times, I am reliant on the latent heat previously stored within the hot water cylinder.
- 21:00 and 24:00 (the period when my electricity retailer gives me free power), then the setpoint is ramped up to its maximum value (75C). In addition, I tell my solar inverter and battery system to DISABLE. This prevents the hot water system from using any energy stored within the battery (as I want to fully use the Grid supply right now).
Pictorial representation of the Node-RED temperature control algorithm
Other interesting things
Detecting a blown hot water element?
There have been times in the past when the heating element in my hot water cylinder has failed, and the only way this has been discovered is when someone (usually me) happens to find themselves in the middle of a cold shower. To help my family and I avoid unexpectedly experiencing a cold shower, I have built alert logic that:
- Specifically looks at those times when the temperature setpoint has just been increased to its maximum value.
- 99% of the time, suddenly increasing the temperature setpoint will cause the digital temperature controller to turn on the hot water heating element. When on, the hot water heating element should draw 3kW of power.
- Using the data provided by the Eastron power meter, logic within Node-RED looks for a corresponding 3kW jump in power consumption. If it sees this sudden jump, then it can concluded that the heating element is working fine. If not, then an email is sent advising me that there may be an issue.
Cloud dashboards
Whilst Node-RED itself allows me to log and visualise different parameters (such as power consumption, hot water temperature, etc), I thought it would be handy to stream this off to a cloud-based dashboard for further analysis. In this respect, a Node-RED flow is programmed to stream information to the AdaFruit.io platform, and within AdaFruit I can do any number of things from plotting power consumption over time, to sending signals back to Node-RED to do something like manually alter setpoints on my hot water system.
Again, I prioritise local resiliency, so if the connection to AdaFruit goes down (because my home Internet connection is offline), then everything continues to work locally.
A local Node-RED dashboard showing power flows on my system - More advanced dashboards are built in AdaFruit.io
Summary
Node-RED is a powerful programming tool for those who don’t want to dabble in the depths of a more compressive programming language like C# or Java, but are comfortable dipping there tools into something that is a little more involved than Home Assistant.
Over time my home automation system is likely to change, and I think Node-RED is the perfect platform to grow with me. I already have plans to start automating my home heating and cooling system as soon as I can reverse engineer the infra-red codes sent by its remote control…