Figure 25 – Setting Up a Controller
I use an open-source smart home software, which means I can modify it with code and scripts written by others to enable extended functionality. I don’t have to program my smart thermostat for every hour of the day, every day of the year in order to program it for my peak rate structure. Instead I run an automation that detects when it is a weekend or holiday, and then enables a lower energy mode of operation. That is not something that even the most expensive smart thermostats can do out of the box, so that added-value is the promise of smart technology. Work in the industry long enough and you start to get frustrated with high-end electronics of any sort that are proprietary and don’t provide access to source code.
As far as the material needed, a computer is needed as well as a z-wave antenna. Somewhere near the beginning of hardware programming, the computer needs to be told where on its computer chip the Z-wave antenna is plugged into. So I recommend sticking to hardware solutions that everyone else is using, which makes troubleshooting much easier.
One computer popular amongst home automation users is a $40 computer called a Raspberry Pi. The Rasperry Pi is just hardware that software is installed onto, but because it opens its technical specifications, and the software installed on it is similarly open, it attracts significant attention from hobbyists who collectively contribute knowledge and code, often free of charge, to make the platform better for everyone. That doesn’t mean your Raspberry Pi isn’t password protected, but using open-source hardware and software is one solution to avoid reliance upon manufacturer support.
Even if building a more powerful dedicated computer to host the software, which would improve start-up speeds and add-on capability, sticking to similar computers as what everybody else is doing helps with answers that you might have to otherwise be very knowledgeable in computers to find.
Figure 26 – Open Source Automation Software
The software I use for my hub is open-source as well as free to download and use. Home Assistant is one of the top 10 open source projects on Github (the website for managing open-source projects). So it is a very popular platform and to get it set up, you literally take the home assistant software and install it onto the Raspberry Pi, starting out with a micro SD card as the boot disk.
After inserting the boot disk, the Raspberry Pi starts up. Plug in the Zwave USB anttenae – the RaspberryPi already has an hdmi port for a screen, as well as a wifi signal and ethernet port. Perhaps on a commercial system, a mini pc which lacks a wifi antennae is a more secure option, only using the ethernet port for communication. In fact much of this external stuff, whether it be a zwave antennae or boot disk or whatever gets integrated into the actual computer chip board when you go with higher end consumer smart hubs. And ultimately having the antennae of your smart home network on a USB drive becomes the failure point. The literal connection between the USB stick and the computer could become damaged or loose, causing performance issues.
But that comes later. Let’s now go through the process of building a local energy controller.
Figure 27 – Use The Official Documentation
We’re using the popular home assistant open source platform, which does not require internet access to run. Connect the Pi to the local wifi hub will allow for remote web browser viewing on any connected device function, and connection to the world wide web would allow for remote viewing remote as well as integration with voice services, but it doesn’t have to be integrated
it can run on its own without connection to the outside world.
All this stuff changes fast so don’t use online guides produced by other people, even when they are very good guides, because the software changes can make the guide obsolete so always start with the official documentation.
Figure 28 – Use Discord for Technical Support
One web resource that is a big help is the Home Assistant Discord channel. I moderate a solar Discord community, and I’ve found other Discord groups very helpful for technical support of different kinds of technology. If you like using Facebook for technical discussion groups, you will love Discord and there is more information in the references slide at the end of this class. So between the official documentation and the Discord group, you should be able to get this project out of the ground.
Figure 29 – Downloading Controller Operating System
One of the first steps is to download the home assistant software. There’s different options for various popular hardware, whether it’s the raspberry pi or slightly upgraded mini pcs. The software is downloaded onto a boot disk, something that computer professionals are familiar with. In your computer, there is dedicated disk drive space that is unlike other parts of your hard drive. It contains the primal code that tells a computer how to turn on as energy starts flowing through its circuits, in a process not dissimilar to a needle extracting sound from a record player, except with ones and zeros instead of bumps.
The boot disk for the Raspberry Pi is commonly stored on a data card that then gets plugged directly into the Raspberry Pi. Finding a microSD card as well as a computer that can read it is perhaps the hardest part of the whole process.
The software contained is Home Assistant software written for Raspberry Pi hardware. It might differ slightly for other computers. When it comes time to graduate from the Raspberry Pi to host Home Assistant on a computer, the installation can be slightly different.
Figure 30 – Making a Boot Disk
Anyway, computers are capable of making boot disks because it is a necessary feature for restarting the hardware when your operating system crashes. That same boot disk software can be used to “etch” the boot image of home automation software written for a particular hardware configuration onto any SD card, instead of using the computer to create a boot disk for its own operating system. So your computer may already have this etcher software or boot disk creation software already installed which you could use to create a boot disk for the Raspberry Pi. Or you can download the BalenaEtcher software to put the Home Assistant boot image on the SD data card.
There is an extra step, which is more difficult, to pre-load the wifi network information onto the Raspberry Pi. But it is easier to simply locate the Raspberry Pi wherever your internet router is located, and plug in with an ethernet cable.
Figure 31. – Startup Success
Upon start-up, the energy controller now asks to go through the user creation process. It’s connected to the internet and pulling in information from the outside world. One fascinating input is weather, as the weather forecast information becomes a digital automation input. It is possible to trigger energy automations based on the next day’s weather forecast, such that you could charge the batteries ahead of a storm, or otherwise aggressively discharge the batteries for normal electric bill optimization. All these really powerful concepts become relatively simple once you get the hang of the software interface.
Figure 32 – Adding Zwave
As a next step, I suggest registering the Zwave USB stick, which allows you to register Zwave devices into the Home Assistant hub. I do not know the USB path of the zwave stick, which refers to how the computer motherboard talks to the virtual registry of devices plugged into the controller’s USB ports. Because I have used commonly used hardware and software with a common configuration, I can cheat and find this information online without using any advanced computer science knowledge.
Figure 33 – Out-of-the-box Functionality
As an optional step, as I say optional because this is a complicated next step which is not necessary for energy automations, but to record this data onto the Raspberry Pi we need to add a data logger.
Right after an inclusion pairing process is successful, Home Assistant will take the data from a zwave energy meter and display it in a 24 hour view. But if you want the data to go back a few days, it is necessary to set up a data logger. Yes energy analytics are really good but it is important to note they are not necessary for energy automation. It is best to have server data stored on a cloud service, such that the device does not fail if the data storage accidently fills up the entire hard drive and degrades system performance. It is possible in fact to restrict the data storage on the local to device to just what is needed rather than to record everything.
In the solar industry, installers get very frustrated with the lack of system data locally available from their solar monitoring systems, but managing this data for every 5-10 second period for years, if not decades, ends up being a lot of data! Whereas a monitoring system without data logging could be a few lines of script.
A Raspberry pi makes a great home automation management system, but if you want to do robust data logging then taking extra steps to start with a mini pc may be in your best interest.
Figure 34 – Adding a database
Fortunately, the Home Assistant software allows this addition to be made within its software. Otherwise, Home Assistant would have to be installed on a computer, running in a container inside a larger computer. Regardless, to store the data the computer needs a database and a popular and therefore well supported one is influxdb. In the past, you would need to know how to run command lines to add the database onto the controller, but Home Assistant can now be easily modified within its own software, like a traditional operating system.
Anyway, storing lots of constantly updating information is not a good practice for an SD memory card, but if you proceed with these steps and do it for anyone on a Raspberry Pi energy controller, it might fill up the card and crash the system. Because there are so many inputs into a smart hub, recording everything possible is not the best approach. Instead, think about what you want to record and log only that. But basically setting up the database is a bunch of username and password creation.
Figure 35 – Visualizing the Database
This is a visual display software that is useful for displaying the database information. Both Influxdumb and Grafana are open source and can be installed directly within the smart hub. Both add-ons are installed and then programmed to talk to each other.
Figure 36 – Setting Up Communication
Here we’re setting up our database with a username and password. If it looks daunting remember this is a common step taken by many, and so the process is well supported if you were to ask for help within Home Assistant’s free to join Discord group.
Figure 37 – Beyond-the-Box Functionality
If you know what you are doing, the entire set up process can be done in under an hour, so makes a good side project. Even if you don’t know much about computers, this process is something you can do, although it may be a bit longer.