HOME AUTOMATION SYSTEM FOR RENTAL PROPERTIES

Kotiautomaatiojärjestelmä Vuokra-asunnoille

Bachelor’s thesis

Valkeakoski – Electrical and Automation Engineering

Spring Semester 2021 Mauricio Alvarez Rojano Electrical and Automation Engineering Abstract

Author Mauricio Alvarez Rojano Year 2021 Subject System for Rental Properties Supervisors Timo Väisänen

This thesis describes the development and implementation of a home automation system for rental properties. It can connect to a variety of sensors, lights and other devices from different vendors with a accessible from a computer or a smart phone. An additional goal of this project was to make the system locally or remotely controlled. The automation system should be flexible enough to be implemented in any type of rental property.

This project targeted a typical student rental apartment in the City of Tampere and the focus of the system concentrated on control, leak detection, temperature monitoring and security. An open-source home automation platform was selected based on the hardware required to run the system, the number of supported devices and the size of an active community behind the platform. The hardware to run the home automation system was selected based on its expandability options. The controllable devices and sensors suitable for this project were selected based on their cost and characteristics. The ZigBee protocol was chosen for this project.

The result of this project is a fully functional home automation system that can be implemented into any rental property, which allows you to control, schedule and/or automate any ZigBee light or a controllable outlet. It also offers the possibility to monitor ZigBee sensors that provide various pieces of information such as whether a door is open or closed, the temperature, light levels and leak detection. The system can be monitored and/or controlled locally and remotely.

Keywords Home automation, Home Assistant, Lighting control, ZigBee Pages 36 pages Contents

1 Introduction...... 1 2 Theoretical foundations...... 1 3 Aim of thesis...... 3 4 Research process...... 3 4.1 HUB hardware...... 4 4.1.1 ...... 4 4.1.2 Network-attached storage (NAS)...... 5 4.1.3 Desktop computer...... 5 4.2 Communication protocols...... 6 4.2.1 Z-...... 6 4.2.2 RF 433.92 MHz...... 7 4.2.3 Wi-Fi...... 7 4.2.4 ZigBee...... 8 4.3 Antennas...... 8 4.4 ...... 9 4.4.1 Home Assistant...... 10 4.4.2 server...... 10 4.4.3 Virtual machine or Docker...... 11 4.4.4 Portainer...... 12 4.4.5 SSH...... 12 4.4.6 Node-RED...... 13 5 Development and implementation of system...... 13 5.1 Property...... 14 5.1.1 Controlled devices...... 15 5.2 Cost calculation...... 17 5.3 Server set-up...... 18 5.3.1 Linux server installation...... 18 5.3.2 Docker and Portainer installation...... 19 5.4 Installation and set-up of Home Assistant...... 19 5.4.1 Set-up...... 20 5.4.2 SSH connection...... 21 5.4.3 Back-up system...... 22 5.4.4 Dresden Elektronik ConBee II set-up...... 22 5.5 Configuration of devices and system...... 22 5.5.1 Pairing devices...... 22 5.5.2 User interface...... 24 5.5.3 Automations...... 27 5.5.4 Remote access...... 33 5.5.5 Mobile application...... 34 6 Project results...... 35 7 Conclusions...... 36 References...... 37 1

1 Introduction

Home automation holds significant potential in the overall smart home industry in developed countries. The market is gaining growth due to the rising adoption of the mostly in developed countries. Users prefer advanced standards of living where they have access to technologically connected devices, which include televisions, refrigerators, smartphones, and many other electronic devices. Some studies estimated the home automation market to be worth 45.8 Billion US dollars and project a growth on this market to reach 124.18 Billion US dollars by 2025. (Home Automation Market, 2019)

The more robust systems like KNX and others, provided by companies with a lot of experience in building automations often require a change in the wiring of the property, to be able to implement home automation systems (KNX Basic, n.d.). This situation poses a challenge for rental houses or apartments where such changes cannot be done. This often leaves no options for tenants who would want to implement automations in their homes.

2 Theoretical foundations

In this last decade, the smart home industry has come a long way and currently offers a wide variety of devices using various technologies. Often to control a particular device the user is required to install an application, an “app”. The issue starts when each device requires the installation of its own application to perform one task. To control the thermostat the user has one app, to control the lights the user has another app, to control outlets, another app.

The homeowner’s smartphone can be filled with multiple apps, all to control different devices and all dedicated to controlling the home under normal living conditions. A better way would be to install a dedicated, centralized solution. (5 Common Home Automation Problems And How We

Solve Them, n.d.)

“When you add devices to your smart home, you usually have to download and use additional apps, which is frustrating and confusing. You can avoid all that—and you do not need a hub to do it. You just need one app.” (Hendrickson, 2019) 2

Often these apps are designed to transfer data to the cloud, which does all the heavy lifting. This eliminates the need of manufacturers to create and program a device powerful enough to analyze complex data. (Whalen, 2019)

Cloud-based processing comes with some compromises, the biggest of which is the possibility of a privacy breach. Data travels from the devices to the cloud—data that users might not want to be revealed to the public. While manufacturers, companies and services pledge the customers that their data is encrypted and secure, there is no assurance that a device is hack proof. (Whalen,

2019)

On the other hand, local control of the devices is a superior solution from the perspective of speed and privacy. A locally controlled hub that can integrate products from different vendors and different technologies would be a much better approach. Again, this would provide control, flexibility and more privacy to the end user. (Colegrove, 2020)

As of now, there are existing products than can achieve a similar functionality. In the smart home industry, the type of devices that allow you to connect different devices from different vendors and/or different technologies are often called hubs or smart hubs.

Some of these smart hubs require an internet connection to connect to the server to control the devices. Other smart hubs offer local control and do not require connection to a server and relay only on the existing Wi-Fi local network, or different protocols such as Zigbee or Z-Wave to perform the delivery of messages. (Colegrove, 2020)

As previously stated, the cloud depended smart hubs pose privacy challenges and slow control. On the other side ready-made smart hubs that offer local control rise the concern of longevity as it is not clear how long these devices will be supported. In both hub cases, companies may start charging subscription fees to use their software or services as some have done in the past.

“Smart home provider Wink has some bad news for existing customers: Unless they opt into a new $4.99 monthly subscription plan by May 13, customers will basically lose internet access to their Wink products.” (Kan, 2020) 3

Hence there is a necessity of independent hardware and software capable of controlling devices from different vendors that do not rely on a cloud connection. It is an acute necessity for those wanting to automate their homes and not depend on companies that might collect data on users or start charging subscription fees after all the hardware has been purchased. (Kan, 2020)

3 Aim of thesis

The aim in this thesis was to create an independent automation system that could connect to a variety of sensors, lights and other devices from different vendors and would function wirelessly, thus not needing new wiring of the premises. At the same time providing enough flexibility to be implemented into any rental property where wiring cannot be changed.

Many devices that work wirelessly are available in the market. These devices use different types of technologies such as Zigbee, Z-Wave, 433.92 MHz and others. A centralized hub that could control locally these devices with one or more of these protocols would be a great solution for people looking into creating an automation system. Additionally, the system would ideally provide the possibility of remote access.

4 Research process

To create an automation system a hub was needed, in other words hardware that could host the automation system and its design. The system needed to be running 24/7, required appropriate software, antennas to connect to the wireless devices and finally the devices eg. lights, plugs, sensors, etc.

The following list provides a broad understanding of the hardware and software needed:  HUB  Automation software  Wireless antennas  Controlled devices 4

The software running the automation system should be independent, giving the security of not having subscription fees added in the future. There were several options of open-source software, two of them being the most prominent in the home automation world: OpenHAB and Home Assistant (Memon, 2020).

4.1 HUB hardware

For the hub hardware there were several aspects that required consideration. The main issues to focus on included;  Reliability as the hardware should run 24/7  Electricity consumption  Flexibility  Compatibility with different software

Three different types of devices were considered: single board computers, network-attached storage (NAS) and desktop computer.

4.1.1 Raspberry Pi

The Raspberry Pi is an inexpensive minicomputer with a size comparable to a credit-card that can be plugged into a computer monitor or TV. It can use a standard keyboard and mouse and it is a capable of running fully operating systems and is often used to learn programming languages such as Scratch and Python. It is capable of doing all that one expects from a desktop computer. (What is a Raspberry Pi?, 2015)

The power supply requirements of a Raspberry Pi differ between models. While all models require a 5.1V supply, the current needed generally increases according to model. All models before the

Raspberry Pi 4 used a microUSB power connector and the Raspberry Pi 4 uses a USB- connector instead. (Power supply, n.d.)

The official Raspberry Pi USB-C power supply is designed to power the latest Raspberry Pi 4 Model B boards. The power supply has a maximum output of 5.1 Volts and 3 Ampere. This makes the maximum power consumption of a Raspberry Pi 4 15.3 Watts, making the Raspberry Pi 4 very 5 appealing for home automation projects due to its low power consumption. (Raspberry Pi 15.3W

USB-C Power Supply, n.d.)

4.1.2 Network-attached storage (NAS)

A NAS device is a storage device connected to a network that allows you to save and restore data from it by authorized users. Some NAS devices offer the possibility of adding more storage and remote access to them. In this sense NAS devices are like having a personal private cloud service. One can benefit of having complete control of one’s data. (What is NAS?, n.d.)

4.1.3 Desktop computer

A compact pc of a small form factor type (SFF) or a dedicated server can be a good option. These types of devices are reliable and designed to run on extended periods of time, their disadvantage is a higher power consumption in comparation to the Raspberry Pi. (What does SFF mean? Small

Form Factor Computers, 2019)

If it is considered that the automation software will take care of security aspects, then a more reliable solution should be a priority. All of the options listed above, will need the proper antennas to connect with the devices wirelessly as electrical rewiring is not an option in rental properties.

With all of the above taken into consideration an SFF computer can constitute a better option from the point of view of flexibility if the system is required to grow over time. As it might be necessary to add more lights, sensors or simply using the server running the automation system to be a to host picture, music and video libraries for example. An SFF Computer was chosen for this project because of all the advantages such a device offered in comparation to a

Raspberry Pi or a NAS.

The SFF computer chosen for this particular system was an old SFF office computer purchased from a local store shown in Figure 1. From the environmental point of view this approach is a great way to recycle old computers. This type of equipment offers good performance for the task as well as a good number of ports to connect different peripherals. 6

Figure 1 - SFF Computer HP Compaq

4.2 Communication protocols

To communicate with the devices, lights, plugs, sensors, etc. a type of was needed and there are existing several options for this. Each of the wireless communication protocol have some caveats. To keep the costs low it would be best to choose one wireless protocol as the need for purchasing several antennas will be minimized. Among the most popular wireless communication protocols for smart home devices are Wi-Fi, Zigbee, Z-Wave, and 433.92

MHz.

4.2.1 Z-Wave

Z-Wave is a wireless protocol used mainly in the home automation industry, it allows devices to connect and exchange data with each other (Definition Z-Wave, 2018). It offers two-way communication through and message acknowledgment, this low power consumption protocol brings an alternative to Wi-Fi and a longer-range alternative to

(What is Z-Wave?, 2020).

In Europe devices using Z-Wave wireless protocol are not many as this protocol is mainly used in the United States and the devices using Z-Wave are usually more expensive than their contra parts. 7

4.2.2 RF 433.92 MHz

433.92 MHz is a wireless radio band typically used by small devices used in house for home automation. This technology is a mature technology and has been in use for a long time. Devices using this technology are relatively inexpensive and the protocol has longest range of all the other protocols commonly used in home automation. (433 MHz technology in smart home and domotics, 2020)

The main drawback of this protocol for the home automation scenario is fact that it uses only one- way communication. The devices can only send or receive signals and there is no confirmation if the message has been received. (RF Communication, 2020). This makes the protocol not a good option for sensors and other devices.

4.2.3 Wi-Fi

Wi-Fi is a wireless networking protocol that enables devices such as computers, mobile devices and other equipment (eg. wearables), network attached storage to connect with the Internet. It allows these devices to interchange data with one another, creating a network. (What is Wi-Fi,

2019)

This protocol offers a wide variety of controllable devices in the market, enabling the person creating their smart home solution with a good number of choices. Typically, Wi-Fi devices are more affordable than ZigBee or Z-Wave. One of the drawbacks of Wi-Fi enabled devices is that they are more power hungry than similar ZigBee or Z-Wave, in some cases consuming 10 times more energy. (What are the advantages and disadvantages of Wi-Fi for home automation, 2020)

4.2.4 ZigBee

ZigBee is a wireless communication protocol developed as an open global standard to address the unique needs of low-cost, low-power wireless IoT networks. It operates on the IEEE 802.15.4 physical radio specification and operates in unlicensed bands including 2.4 GHz, 900 MHz and 868 MHz. (Zigbee Wireless Mesh Networking, n.d.) 8

Some of the advantages of the ZigBee protocol are its low power consumption, allowing the devices to use small batteries, and the ability to create a mesh network extending the range of the

ZigBee network. As a disadvantage ZigBee devices have a short range of operability. (Ashrit, 2018)

For this project, the chosen communication protocol was Zigbee. The property was a rental apartment with a few thick walls which allowed the relatively easy establishment of the mesh network. In addition, Zigbee devices are in abundance in Finland and are constantly going down in price (ZigBee devices - Overview, 2017).

4.3 Antennas

The two types of Zigbee antennas that would work with open-source automation system are illustrated in Figure 2 and Figure 3.

Figure 2 - Nortek HUSBZB-1 GoControl (HUSBZB-1: GoControl QuickStick Combo, 2017)

Figure 3 - Dresden Elektronik ConBee II (ConBee II overview, n.d.) 9

Disregarding price, both options seemed to be a good choice as they offer flexibility in the number of devices the antennas could work with. Both could be connected to a Raspberry Pi, a desktop computer or a NAS as an USB port was present in all these devices.

The Nortek HUSBZB-1 GoControl USB stick offered both antenna modules for Z-Wave and Zigbee radio while ConBee II offered only the Zigbee antenna module. As the Nortek HUSBZB-1 GoControl price was slightly higher perhaps due to the two antenna modules, it made more financial sense to consider the Dresden Elektronik ConBee II as the Z-Wave antenna module was not necessary in this project.

4.4 Software

Among open-source platforms several options exist; Home Assistant, OpenHAB, Domoticz, Homebridge.io and others. As mentioned previously the most popular in the open-source world being Home Assistant and OpenHAB.

The preliminary requirements for the software:  Open source  Can run on multiple type of hardware  Active community  Support for vast range of products and vendors

OpenHAB, Home Assistant, Homebridge.io and Domoticz are all open-source platforms, can run in a variety of hardware as they are not resource demanding platforms. At the moment Home Assistant and OpenHAB have the most active communities, with Home Assistant having a seemly bigger community than OpenHAB (Arrows, 2020). OpenHAB has a more rigorous review process making integration and support of new devices come slower than in Home Assistant which has slightly more device integrations, making it a good choice for this project.

4.4.1 Home Assistant 10

Home Assistant is a free, open-source home automation software designed to be a home automation system for controlling smart home devices and integrating devices from many different vendors. Home Assistant focuses on local control and privacy. (Home Assistant, n.d.)

There were different installation methods of Home Assistant depending on the hardware the system would be running on. There is special installation for Raspberry Pi, virtual machine and a Docker container. (Install Home Assistant, n.d.)

The official minimum requirements listed for the hardware are:

 Storage: 32 GB  Memory (RAM): 1 GB  Network connection speed: 100 Mb/s

As this project didn’t use a Raspberry Pi, there were two options of installation left, the Virtual machine and Docker container.

4.4.2 Linux server

To utilize a virtual machine or a Docker container a host is required (Avi, 2019). For this project the use of a virtual machine would mean excessive use of computing resources and the cost of a Windows license needs to be considered.

A Linux server is a free, open-source variant of the Linux operating system (OS). It is built to address the requirements of business applications like system and network administration, Web services and database management. Linux servers are frequently chosen over other server operating systems because of their security, consistency and flexibility. (Linux Server, 2013)

The Linux server allows you to use docker to install home assistant via docker container. The operating system is also designed to run permanently and with low resources.

4.4.3 Virtual machine or Docker 11

A virtual machine is a file, often called an image, that mimics the behavior of an actual computer. It is like a computer within a computer. The image runs in a window, like any other program or application and it gives the end user the same experience on a virtual machine as they would have on the host operating system itself all while being sandboxed from the rest of the system. (What is a virtual machine?, n.d.)

Docker is a tool designed to make it more comfortable to create, deploy, and run applications. The applications are contained within virtual boxes called containers which allow a developer to package up an application with all of the parts necessary. (What is Docker?, n.d.)

Figure 4 - Virtual machine vs Docker containers (Arora, 2019)

As illustrated in Figure 4 it is visible that virtual machines have a host operating system (OS) and the guest operating system inside each virtual machine. The guest operating system can be any operating system. On the other hand, Docker containers host on a single physical server or computer with a host OS, the guest OS shares resources with the host OS and the other containers. (Arora, 2019)

4.4.4 Portainer

Portainer is a manager of Docker containers, it offers a to manage with ease a library of containers without the need to write code (Portainer, n.d.). Home Assistant will be running on a docker container but as well many vital Home Assistant integrations like: Node- 12

RED, SSH and the software controlling the ConBee II.

Figure 5 - Portainer user interface

Portainer makes easy to start, stop, rebuild, remove and update containers using its graphical user interface as it is illustrated in Figure 5.

4.4.5 SSH

The SSH protocol (also referred to as Secure Shell) is a way for secure remote connect from one computer to another. It offers several options for strong and secure authentication and integrity with strong encryption. (Ylönen, n.d.)

This communication protocol enables connection to 2 separate parts of the system. Connection with the Linux server operating system and connection with the Home Assistant file structure. Allowing you to monitor and manage both instances if needed.

4.4.6 Node-RED

Node-RED is a flow-based programming tool as it is illustrated in Figure 6, it represents graphically all the elements present in a program and works by passing messages between nodes (Node-RED - About, n.d.). 13

Figure 6 - Node-RED

Automations for this project will be made with Node-RED as it will allow to export the automations to another automation system easier if needed. Although Node-RED is installed as a Home Assistant integration, it will be running as a separate docker container independent from Home Assistant. Thus, in case of restarting the Home Assistant, some of the automations can still run while the system is restarting.

5 Development and implementation of system

The development and implementation of the system constitutes of three main steps.  Analysis of the property  Cost estimate  Development, set-up and configuration of the system

5.1 Property

The target property of this project was a student apartment located in Tampere; the apartment was administrated by the Tampere Student Housing Foundation (TOAS). 14

Figure 7 - 3D model of rental apartment

Figure 7 presents a 3D model of the study case of this project. An apartment with four bedrooms, one Toilet/Shower, one Kitchen and a Corridor.

Figure 8 - Room distribution

The apartment was inhabited by a family of four people. Two adults and two children. And the rooms have been distributed as can be seen in Figure 8. 15

An aspect to be taken into consideration was that one of the rooms was visually divided into two separate zones without any physical division. This was the case of the living room and dining room that coexisted in the same space but had to be addressed as two separate zones from the perspective of lighting.

On the 3D model, all the ceiling fixtures present in the apartment were visible. All lights could be controlled from the traditional wall switches independently, with the exception of the two corridor lights that were turned on at the same time.

5.1.1 Controlled devices

The control devices needed in the project were specific to the particular property. After a short conversation with the family, their necessities were identified. This allowed to create a list of the type and number of controlled devices needed in the property as can be seen in Table 1 and Table 2

Table 1 - Lights

No Room Quantity 1 Office 1 2 Living Room 1 3 Dining Room 1 4 Master Bedroom 1 5 Corridor 2 Total 6

Table 2 - Controlled Outlets

No Room Quantity 1 Living Room 2 2 Kid’s Bedroom 1 3 Master Bedroom 1 4 Office 1 Total 5

The family manifested their concern on knowing when either the main door or balcony door was open or closed or either of those doors was left open. This made clear that two door sensors were needed as this was a high priority and security concern. It was also suggested to the family to add 16 leak sensors, one under the kitchen sink and another under the toilet sink. All the necessary sensors and switches that were necessary for the system are listed below in Table 3 and Table 4

Table 3 - Sensors

No Room Description Quantity 1 Corridor Main Door Open/Close 1 2 Corridor Motion Sensor 1 3 Living Room Balcony Door Open/Close 1 4 Kitchen Leak Sensor 1 5 Toilet Leak Sensor 1 6 Office Motion Sensor 1 Total 6

Table 4 - Switches

No Room Quantity 1 Living Room 1 2 Dining Room Bedroom 1 3 Master Bedroom 1 4 Office 1 5 Corridor 1 Total 5

As for lighting, the family wanted to have control of the lights but not in all the rooms thus some traditional lights remained in the apartment. This was the case of the kitchen light and the kid’s bedroom light.

The family also manifested the wish of being able to control some devices via a controllable outlet, devices like lamps, ventilators and/or holiday lights. In this case the outlets were to be used depending on the season with different appliances and would be easy to move to any room in the house.

5.2 Cost calculation

A cost estimate of the project was calculated taking into account all the devices presented in the above tables Table 1 - Lights, Table 2 - Controlled Outlets, Table 3 - Sensors and Table 4 - Switches. These devices could be purchased from different retail stores in Finland and/or online stores. The cost of the SFF Computer and the Dresden Elektronik ConBee II were also added to the estimate. 17

Table 5 - Cost estimate

Description Quantity Price per Total, unit, EUR EUR SFF Computer desktop 1 100 100 Dresden Elektronik ConBee II 1 40 40 TRÅDFRI Led-lamppu E27 806 lm, 3 8 24 himmennettävä lämmin valkoinen/pallo opaalinvalkoinen

TRÅDFRI Led-lamppu E27 1000 lm, 2 15 30 himmennettävä valkoinen spektri/pallo opaalinvalkoinen

TRÅDFRI Led-lamppu E27 600 lm, 1 20 20 himmennettävä värillinen/valkoinen spektri/pallo opaalinvalkoinen

TRÅDFRI Outlet 3 13 39

TRÅDFRI Remote 3 15 45 TRÅDFRI Remote Dimmer 1 8 8 TRÅDFRI Motion Sensor 1 10 10 Samsung Smartthings Button GP- 2 17 34 U999SJVLEGA Philips Hue Filament LED lamppu 1 29 29 929002241401 Philips Hue Dimmer switch 1 19 19 Samsung Multipropose sensor GP- 2 23 46 U999SJVLAGA Samsung Leak Sensor GP-U999SJVLCGA 2 23 46 Philips HUE indoor motion sensor 1 27 27 Total EUR 498

The value of the whole system was close to 500 euros as can be seen in Table 5

5.3 Server set-up

For the development and implementation of the home automation system, the first step was to prepare the hardware with the host operating system Linux Ubuntu Server, as the installation of Home Assistant chosen for this project was Home Assistant on a Docker containers as explained 18 earlier.

5.3.1 Linux server installation

A Linux Ubuntu Server image was downloaded from the official website and software called Etcher was used to create a bootable installation USB drive. During the installation process it was important to set up a SSH connection, as this server was to be used without a monitor, which would allow one to control the server without being physically connected to it. To do this, in the installation process needed to be selected the option of OpenSSH server as it is illustrated bellow in Figure 9 - SSH Protocol

Figure 9 - SSH Protocol (Linux: How to Install Ubuntu Linux Server 16.04 LTS, n.d.)

After the installation was finished, a regular automatic restart was set up to be done once a month on a non-sensitive time of the day to clean up any trash or malfunctioning process(es) present in the active memory (Simic, 2018).

The server was configured to automatically restart after a power outage to prevent the server from remaining off after the power has come back. Using the router administration panel, a static IP address was assigned to the server, thus in case of lost connection or power outage the server would be assigned the same IP address every time. (When should I use a static or dynamic IP 19 address?, n.d.)

5.3.2 Docker and Portainer installation

Docker and Portainer were installed to the Linux server via the command line. Portainer was installed with the intention to manage with ease all the containers that were going to be installed. Typically, Portainer would be available via the port 9000.

After this Portainer could be accessed with a browser by typing the IP address of the server followed by the port number as can be seen in an example at the following address: http://192.168.1.2:9000

5.4 Installation and set-up of Home Assistant

Before installing Home assistant Docker container some packages were required to be installed. The packages were installed via the Linux command line with the following command: apt-get install apparmor-utils avahi-daemon dbus iq network -manager socat

To install the Home Assistant Docker container the following command was used: curl -sL "https://raw.githubusercontent.com/home- assistant/supervised-installer/master/installer.sh" | bash -s

From this point on, it was possible to access the Home Assistance installation from another computer in the same local network as the Home Assistant server. It required the use of a browser to visit the IP address of the sever running Home Assistant followed by the port 8123. This meant that was possible to use the Home Assistant server without having any peripherals connected to it.

A headless server is a computer without a monitor, keyboard, mouse, or other peripherals connected to it. Headless computers are generally controlled over the network. (Hoffman, 2020)

5.4.1 Set-up 20

When the IP address of the Home Assistant server was entered into the browser, Home Assistant presented the initial screen as it is shown in Figure 10

Figure 10 - First installation screen (Install Home Assistant, n.d.)

After the installation was done, the following step was to create an administrator account. For this the system presents the following screen as it is shown in Figure 11

Figure 11 – Creation of an administrator account (Onboarding Home Assistant, n.d.)

The system guides the user with a graphical user interface throughout all the steps to set up the system with all the needed information such as: selection of location, unit system and possible set up of detected devices in the local network. 21

Figure 12 - Creation of users and areas

Once the set-up process was done, the system displayed the main dashboard named “Lovelace” in Home Assistant (Lovelace, n.d.). As the system was going to be handled by different users, it was necessary to create other user accounts and it was decided which account(s) were granted administrator status. This was done in the “Configuration” section followed by the section “Users” as it is shown in Figure 12.

Also areas were created to keep the system organized. Areas in Home Assistant are a virtual representation of the different rooms or areas in the physical world (Configuration, n.d.). As it was illustrated above in Figure 8 - Room distribution, the apartment consisted of a master bedroom, dining room, living room, hallway, kid’s bedroom, kitchen and an office.

5.4.2 SSH connection

Similar to the Linux server configuration, it was necessary to set-up an SSH connection to the Home Assistant installation to be able to access to the system files if the user interface was not accessible for some reason. This was done by installing an official Home Assistant add-on called

Samba share located in the Home Assistant Add-on Store. (Home Assistant OS Common Tasks, n.d.) 22

5.4.3 Back-up system

Home Assistant provided a manual way to create a back-up which in Home Assistant are called snapshots as they constitute a copy of the system configuration and add-on data. However, this would not offer protection in case of failure of the hardware where Home Assistant has been installed because the snapshots would be stored in the back-up folder of the system. In case of failure of the hard disk or any other storage device, the back-up file could be potentially corrupted or unrecoverable. (Home Assistant OS Common Tasks, n.d.)

For these reasons, an automatic back-up system was set-up, creating a snapshot of the system once a week and additionally uploaded it to a personal Google Drive cloud server. The back-up system was configured to keep in the local back-up folder and in the Google Drive cloud server a maximum of four snapshot files.

5.4.4 Dresden Elektronik ConBee II set-up

The ConBee II stick was connected to one of the USB ports in the Home Assistant server and followed by the installation of the deCONZ add-on found in the Home Assistant Add-on Store as the installation process of the manufacture recommended. (deCONZ, n.d.) The deCONZ add-on allowed Home Assistant to communicate with the Dresden Elektronik ConBee II stick plugged into the server. It also provided a graphical user interface to connect new devices and manage them.

5.5 Configuration of devices and system

To control the devices with Home Assistant, the devices needed to be paired via the deCONZ add- on

5.5.1 Pairing devices

The pairing process of the Zigbee lights, outlets, switches and sensors was done using the manufacture instructions for putting the previously mentioned devices into pairing mode and the Dresden Elektronik ConBee II recommendations for pairing new devices. 23

As an example, pairing an IKEA Trådfri bulb, the bulb must be turned on and put into pairing mode. If the bulb is new it will be already in pairing mode, if the bulb it is not new or already paired with other device, it can be put into pairing mode by switching the light on and off rapidly 6 times. (Getting started with smart lighting, n.d.)

Figure 13 - deCONZ light pairing example

To pair any device, it was needed to be in close range for the ConBee II stick to be detected (Phoscon Documentation, n.d.). Then it was necessary to navigate to the deCONZ section in Home Assistant and then in that section find the “Add new lights” button as seen in Figure 13.

ConBee II searched for 3 minutes for a new device and once the device was detected, it was added to the system. Some devices like outlets are supported in deCONZ software as lights due to their binary nature. To import all the devices into Home Assistant added via the deCONZ add-on, the Home Assistant had to be restarted.

5.5.2 User interface 24

The lovelace dashboard can be created straight in the user interface and the elements can be added with the help of cards. Home Assistant lovelace offers 29 cards like button card, entities card, gauge card, glance, markdown, grid, picture card, weather forecast, etc. (Lovelace, n.d.)

The lovelace can contain different views which act like tabs, located at the top part of the lovelace and can be either named or have an icon assigned. These views can be configured so, that only users with administrator privileges will have access to all views while users without administrator privileges will have access to views that have been authorized to that particular user.

Figure 14 - Lovelace example

For this project five different views were created: home view, statistics view to system, view to automations, battery levels view and floor plan view. The home view was configured to give a quick access to control all lights in the apartment and controlled outlets as well as a quick view on different room temperatures as it is illustrated in Figure 14. 25

Figure 15 - Statistic view to system

The system statistics view as it can be seen in Figure 15 was created to offer a quick glance to different systems information such as: disk usage, processor usage, processor temperature, system update availability among others. In this view was also included information given by leak sensors as it was not crucial to include that in the home view. 26

Figure 16 – View to automations

As illustrated in Figure 16, this view was created with the proposed of having easy access to enable or disable various automations.

The battery level view was made to offer a glance to all battery levels of the different remote controls and sensors.

The floor plan view visible in Figure 17 was created to offer a more interactive way of viewing what lights were on or off in the apartment and the view was configured to provide a simple way to toggle lights on and off with animations transitioning between the two states. In this view the kitchen light and kid’s bedroom light were represented as always on because there are no controllable lights in these two rooms.

Figure 17 - Floor plan view

5.5.3 Automations

As previously mentioned, the automation for this project was done using Node-RED and the wishes of the family living in the premises were considered. 27

Some of the automation functions the family wanted were:  Turning corridor lights on based on motion  Turning all lights off when no one is home  When no one is home the alarm is armed and a notification will be sent if the main door or balcony door are opened  Turning office light on based on motion  Leak detection for the kitchen and toilet sink

The automation was supposed to turn on the two corridor lights whenever motion was detected by the motion sensor placed in the corridor. However, during development and testing of the automation the family had some additional requests.

The family did not want the lights to automatically turn on between 22:30 and 6:30. During weekdays between 6:30 and 8:30 and on weekends between 6:30 and 10:30 they wanted the lights not to be turn on at full brightness and if possible, to have slower transition between the off and on state. Lastly the family wanted the lights not to be turned on if there was enough natural light.

A Philips Hue motion sensor model 464602 was chosen for the corridor, as it integrates motion detection and lux level in one device (Philips Hue Motion Sensor, 2018).

In Node-RED a flow named Lights was created as illustrated in Figure 18. This flow contained all the automation related to lights in this project. All flows were represented as a tab within the Node-RED editor and it is the main way of how to organize nodes (Flows, n.d.). 28

Figure 18 - Light flow

To keep the different nodes organised within the same flow the comment node was used as a label as it is shown in Figure 19.

Figure 19 - Comment node as a label

Before starting with the development of the automation, it was necessary to consider that in some situations, it could be desirable to have the possibility to enable or disable an automation. For this propose a master switch for each automation had to be created.

Home Assistant provided a way to create booleans which are called input booleans in Home Assistant (Input Boolean, 2020). This way the input boolean could serve as a master switch for the respective automation. An automation would be enabled when the state of the corresponding 29 boolean would be set to on or disabled if the state of the corresponding boolean would be set to off.

The star of the corridor light automation was created using the “trigger: state” core node, as it acted similar to the state core node checking for changes of state in an entity but provided some advanced functionality (Zachowj, Trigger: state, 2020). It offered the possibility of adding additional conditions that needed to be met.

This node would send a message with a payload value “on” when the sensor detected motion and the lux level was below the threshold. The minimum lux level in the corridor was determined together with the family using the Philips Hue Motion Sensor. The minimum lux level comfortable for them in the corridor was 6 lux.

The following node used was the “current state” node as seen in Figure 19. It would check the current state of an entity and output a message with a payload containing the state. (zachowj, 2020) The node would check if the state of the corridor light was on or off; if the light was off, it would send the message with a payload value “off” the output one.

Afterwards, the message would be directed to a “time range switch” node. This node would route messages depending on the time range. If message arrived within the range specified in the node configuration, the message is routed to the output one. Otherwise, the message is routed to output two. (Time range switch, n.d.)

As seen in Figure 20 the node needed the latitude and longitude, this is because the node accepts as start time or end time dynamic values such as: sunrise, sunriseEnd, sunset, sunsetStart, dusk among others. 30

Figure 20 - Time range node configuration

The time range switch would check whether the message arrived between 6:30 and 22:30 and if the message arrived within the time range, the node would route the message to the output one (within).

Figure 21 - Weekday node configuration

In a similar manner, the following node used was a “weekday” node. This node filters payload depending on whether the selected days of the week are met. (Weekday node, 2017) As the family had requested to turn on the corridor lights not too bright and have slower transition between the off and on state during the weekdays between 6:30 and 8:30 and on the weekend between 6:30 and 10:30. This node made easy to select weekdays within the node’s options as seen in Figure 21. Which allowed routing the message to the output one if the message arrived in any of the selected days or to the output two of the node if the message arrived on any of the unchecked days. 31

Figure 22 - Corridor light schedule

The weekday node was followed by two “time range switch” nodes. One was connected to the output one of the weekday node and it would check if the message arrived between 6:30 and 8:30, the other was connected to the output two of the weekday node and would check if the message arrived between 6:30 and 10:30 as it is illustrated in Figure 22.

If the message arrived within the defined time range, it would be routed to the output one of the respective time range switch node. The message would be inputted into a current state node that would check if the state of the input boolean for the corridor light automation was on. If this condition was equal to true, it would route the message to the output one of the node with a payload value “on”.

If the state of the input boolean for the corridor light automation would be off, the state node would output a message with a payload value “off” to the output two not connected to any node.

Lastly, a “call service” node was connected to the output one of the current state node previously examined. The call service node functionality is to send a request to Home Assistant for any domain and service available and can be used for numerous actions like turning lights on or off, sending messages or notifications among many others. (Zachowj, Call Service, 2019)

In this particular case the node was configured to use the domain light, the service was assigned to “turn_on” targeting light.corridor_light_1 and light.corridor_light_2 in the entity id field which corresponded to the two light bulbs in the corridor as it is illustrated bellow in Figure 23. 32

Figure 23 - Call service node configuration panel

The data section of the node allowed configuring additional properties of the light domain such as brightness, color temperature and transition. Where the transition value would be the time in seconds it takes to get to the assigned state in the service field. (Zachowj, Homeassistant Domain,

2020)

5.5.4 Remote access

To monitor the Home Assistant installation while the user was not connected to the local network a remote access connection was needed to be configured.

Officially, Home Assistant supports two ways to have a remote connection to the system. For the first option it is necessary to set up port forwarding (for any port) from the router to port 8123 on the computer that is hosting Home Assistant combined with the use of a free Dynamic DNS service like DuckDNS. This approach is a way to set up the connection without any cost to the user.

(Remote access, n.d.) 33

The second option is a paid cloud service called Nabu Casa created by the founder of Home Assistant. It offers the possibility to add the remote connection to a Home Assistant installation fully encrypted. Additionally, the service provides an easy way to integrate voice assistants like

Google Assistant and . (Nabu Casa, n.d.)

For this project it was decided to use the second approach as the monthly cost was relatively low while paying for the service was a way to support Home Assistant open-source project.

5.5.5 Mobile application

As previously mentioned, Home Assistant can be accessed by typing the IP address of the Home Assistant server in a browser, this can be done even on a smart phone. However, Home Assistant offers a mobile companion application that can be downloaded from Apple AppStore and Google Play. The application provides addition information to the system such as: location, motion and other data that can be obtain from the smart phone. (Getting Started, n.d.)

For this project the users installed the application on iPhones. Due to changes in iOS 13 the operating system for Apple iPhones, granting permission was requested before logging into Home Assistant. For Android this permission is requested as part of the onboarding process during the first log in. If this permission is denied, then device_tracker and sensor entities will not be created. (Getting Started, n.d.)

Once the set-up process was finished, a device_tracker entity was automatically created. This entity could be used in automations and conditions within Home Assistant. (Getting Started, n.d.) Now the system would know the location of the smart phone and trigger automations for example when the device was not home or arrived home. 34

6 Project results

The main purpose of this thesis was to study the creation of a home automation system for rental properties. The requirements for an independent automation system that could connect to a variety of wireless sensors, lights and other devices from different vendors, were accomplished. The selected open-source automation system Home Assistant provided an optimum method for uniting the control of all the devices of the project regardless of manufacturer.

As a result, all the ZigBee lights and controllable outlets can be controlled, scheduled and/or automated. Sensors provide data that can be used for automated functions and the system offers the possibility of adding devices beyond lights and sensors. Additionally, the system can be monitored and controlled remotely.

7 Conclusions 35

After the development of the project certain points became clear. Some of these could not be known prior to the implementation of the project. When I was selecting the open-source home automation system, there were two options that were considered: Home Assistant and OpenHAB. Home Assistant was chosen because it had a bigger active international community in comparison with OpenHAB and support to new devices was acquired significantly faster according to several forums and reviews. Lastly, the user interface of Home Assistant looked more intuitive and modern than OpenHAB.

During the development and use of the system, some devices lost connection to the system or became unresponsive. Most of the time this behavior appeared when an update was available. Part of the community of home automation enthusiasts have brought attention to this issue and requested Home Assistant to have a stricter review on new patches and updates to prevent things from breaking when an update is installed. This is part of the reason why new features and support to new devices take longer in OpenHAB because each upgrade of OpenHAB is done after having gone through a rigorous approval process, while Home Assistant seems to be less rigorous in this regard (OpenHAB Vs Home Assistant: Detailed Comparison By An Expert in 2021, n.d.).

However, I suspect that in some cases these errors and unreliable behavior might be due to the type of installation as occasionally errors were fixed with update package(es) of the Linux Ubuntu server, which reminded me that I had to manage separately the updates for the server operating system and for Home Assistant and its add-ons. Along the way I noticed that Home Assistant offered another type of installation named Home Assistant OS, it acts as a standalone operating system with the drawback that any other operating system cannot installed alongside it. In this way one will have to manage only updates to Home Assistant OS and the add-ons and it eliminates the need of updating Linux packages that could be causing problems. Personally, as this project was implemented into my own property, when occasionally some device malfunctioned or had unexpected behavior it did not become a big issue, but I would not recommend implementing the system for remote locations such as summer houses where one cannot easily be physically present. 36

References

433 MHz technology in smart home and domotics . (2020, May 1). Retrieved September 11, 2020, from Homey: https://homey.app/en-ca/wiki/433-mhz/

5 Common Home Automation Problems And How We Solve Them . (n.d.). Retrieved October 15, 2020, from Integrated Technologies Australia: https://integratedtechnologiesaustralia.com.au/resource-centre/5-common-home- automation-problems-and-how-we-solve-them

Arora, S. (2019, October 29). Docker vs. Virtual Machines: Differences You Should Know . Retrieved August 29, 2020, from Cloud Academy: https://cloudacademy.com/blog/docker-vs-virtual- machines-differences-you-should-know/

Arrows, K. (2020, June 6). Home Assistant Vs OpenHAB. Retrieved July 13, 2020, from Appuals: https://appuals.com/home-assistant-vs-openhab/

Ashrit, L. (2018, December 8). What is ZIGBEE Technology in IoT – Architecture, Network

Topologies, Applications. Retrieved September 22, 2020, from Electricalfundablog: https://electricalfundablog.com/zigbee-technology-architecture/ Avi. (2019, September 15). Docker vs Virtual Machine – Understanding the Differences . Retrieved August 24, 2020, from Geekflare: https://geekflare.com/docker-vs-virtual-machine/ Colegrove, M. (2020, September 11). Choosing a Smart Home Hub? | Why Cloud vs Local Matters . Retrieved October 20, 2020, from HomeSeer: https://homeseer.com/cloud-vs-locally- managed-smart-home-hubs/

ConBee II overview. (n.d.). Retrieved July 30, 2020, from ConBee II overview: https://phoscon.de/ Configuration. (n.d.). Retrieved September 28, 2020, from Home Assistant: https://www.home- assistant.io/integrations/config/ deCONZ. (n.d.). Retrieved October 1, 2020, from Home Assistant: https://www.home- assistant.io/integrations/deconz/ Definition Z-Wave. (2018, August 29). Retrieved September 16, 2020, from Internet of things agenda: https://internetofthingsagenda.techtarget.com/definition/Z-Wave

Flows. (n.d.). Retrieved 20 October 2020, from Node-RED: https://nodered.org/docs/user- guide/editor/workspace/flows Getting started with smart lighting. (n.d.). Retrieved September 22, 2020, from IKEA: https://www.ikea.com/us/en/customer-service/product-support/smart-lighting/getting- 37

started-with-smart-lighting-pub2721e8b9 Getting Started. (n.d.). Retrieved December 10, 2020, from Home Assistant Companion Docs: https://companion.home-assistant.io/docs/getting_started/getting-started/

Hendrickson, J. (2019, August 11). How to Control Your Entire Smarthome Through One App . Retrieved October 11, 2020, from How-To Geek: https://www.howtogeek.com/435765/how-to-control-your-entire-smarthome-through- one-app/

Hoffman, C. (2020, April 9). What Is a Headless Server? Retrieved September 25, 2020, from How- To Geek: https://www.howtogeek.com/660841/what-is-a-headless-server/

Home Assistant OS Common Tasks . (n.d.). Retrieved 29 September 2020, from Home Assistant: https://www.home-assistant.io/hassio/haos_common_tasks/

Home Assistant. (n.d.). Retrieved July 23, 2020, from Home Assistant: https://www.home- assistant.io/ Home Automation Market. (2019, April). Retrieved October 10, 2020, from Fortune business insights: https://www.fortunebusinessinsights.com/industry-reports/home-automation- market-100074

HUSBZB-1: GoControl QuickStick Combo. (2017, July 19). Retrieved July 30, 2020, from Nortek Control: https://www.nortekcontrol.com/products/2gig/husbzb-1-gocontrol-quickstick- combo/ Input Boolean. (2020). Retrieved 12 December 2020, from Home Assistant: https://www.home- assistant.io/integrations/input_boolean/ Install Home Assistant. (n.d.). Retrieved July 23, 2020, from Home Assistant: https://www.home- assistant.io/getting-started/ Install Home Assistant. (n.d.). Retrieved September 28, 2020, from Home Assistant: https://www.home-assistant.io/getting-started/

Kan, M. (2020, May 6). Smart Home Vendor Wink Tells Customers: Pay Up Or Lose Access to

Devices. Retrieved October 20, 2020, from PCMag UK: https://uk.pcmag.com/home- security-products/126869/smart-home-vendor-wink-tells-customers-pay-up-or-lose-access -to-devices

KNX Basic. (n.d.). Retrieved October 10, 2020, from KNX: http://knx.fi/doc/esitteet/KNX-

Basics_en.pdf 38

Linux Server. (2013, January 12). Retrieved August 20, 2020, from Techopedia: https://www.techopedia.com/definition/4888/linux-server

Linux: How to Install Ubuntu Linux Server 16.04 LTS . (n.d.). Retrieved September 15, 2020, from Tech on the net: https://www.techonthenet.com/linux/sysadmin/ubuntu/install_16_04.php

Lovelace. (n.d.). Retrieved September 28, 2020, from Home Assistant: https://www.home- assistant.io/lovelace/

Memon, Z. (2020, April). List of Open Source Home Automation Software . Retrieved July 11, 2020, from Linuxhint: https://linuxhint.com/best_home_automation_software/

Nabu Casa. (n.d.). Retrieved November 30, 2020, from Nabu Casa: https://www.nabucasa.com/

Node-RED - About. (n.d.). Retrieved September 10, 2020, from Node-RED: https://nodered.org/about/ Onboarding Home Assistant. (n.d.). Retrieved September 28, 2020, from Home Assistant: https://www.home-assistant.io/getting-started/onboarding/

OpenHAB Vs Home Assistant: Detailed Comparison By An Expert in 2021 . (n.d.). Retrieved January 14, 2021, from Purdy Lounge: https://www.purdylounge.com/openhab-vs-home-assistant/

Philips Hue Motion Sensor. (2018). Retrieved December 2, 2020, from Philips-hue: https://www.philips-hue.com/en-us/p/hue-motion-sensor/046677473389 Phoscon Documentation. (n.d.). Retrieved October 4, 2020, from phoscon.de: https://phoscon.de/en/app/doc#sys-overview-en Portainer. (n.d.). Retrieved September 15, 2020, from Portainer: https://www.portainer.io/

Power supply. (n.d.). Retrieved September 13, 2020, from Raspberry Pi: https://www.raspberrypi.org/documentation/hardware/raspberrypi/power/

Raspberry Pi 15.3W USB-C Power Supply . (n.d.). Retrieved September 13, 2020, from Raspberry Pi: https://www.raspberrypi.org/products/type-c-power-supply/

Remote access. (n.d.). Retrieved November 30, 2020, from Home Assistant: https://www.home- assistant.io/docs/configuration/remote/

RF Communication. (15. May 2020). Haettu 25. August 2020 osoitteesta Elprocus: https://www.elprocus.com/rf-communication-protocol-application/

Simic, S. (2018, October 22). How To Restart Or Reboot Linux Server From The Command Line . Retrieved September 13, 2020, from phoenixNAP: https://phoenixnap.com/kb/restart- linux-using-command-prompt 39

Time range switch. (n.d.). Retrieved October 27, 2020, from Node-RED: https://flows.nodered.org/node/node-red-contrib-time-range-switch

Weekday node. (2017, December). Retrieved November 2, 2020, from Node-RED: https://flows.nodered.org/node/node-red-contrib-weekday

Whalen, H. (2019, September 4). Can Your Smart Home Live Without the Cloud? Retrieved October 11, 2020, from HomeAlarmReport.com: https://homealarmreport.com/smart-home/smart -devices-work-locally/ What are the advantages and disadvantages of Wi-Fi for home automation . (2020, April 9). Retrieved October 30, 2020, from 24/7 Home Security: https://24-7-home- security.com/what-are-the-advantages-and-disadvantages-of-wifi-for-home- automation/#ProsOfWiFi

What does SFF mean? Small Form Factor Computers . (2019, August 14). Retrieved September 20, 2020, from Rack Solutions Blog: https://www.racksolutions.com/news/blog/sff-meaning/

What is a Raspberry Pi? (2015, August 20). Retrieved September 13, 2020, from Raspberry Pi: https://www.raspberrypi.org/help/what-%20is-a-raspberry-pi/ What is a virtual machine? (n.d.). Retrieved August 27, 2020, from Microsoft Azure: https://azure.microsoft.com/en-us/overview/what-is-a-virtual-machine/

What is Docker? (n.d.). Retrieved August 29, 2020, from opensource.com: https://opensource.com/resources/what-docker

What is NAS? (n.d.). Retrieved September 20, 2020, from Seagate UK: https://www.seagate.com/gb/en/tech-insights/what-is-nas-master-ti/ What is Wi-Fi. (2019, August 5). Retrieved November 9, 2020, from Cisco: https://www.cisco.com/c/en/us/products/wireless/what-is-wifi.html

What is Z-Wave? (2020, October 18). Retrieved September 10, 2020, from Safety.com: https://www.safety.com/z-wave/

When should I use a static or dynamic IP address? (n.d.). Retrieved September 19, 2020, from StarTech.com: https://www.startech.com/en-us/faq/networking-general-static-or-dynamic

-ip-address

Ylonen, T. (n.d.). SSH - Secure Login Connections over the Internet . Retrieved September 3, 2020, from ssh.com: https://www.ssh.com/ssh/protocol/

Zachowj, J. (2019, October 15). Call Service. Retrieved November 10, 2020, from HA Nodes: https://zachowj.github.io/node-red-contrib-home-assistant-websocket/node/call- 40

service.html#configuration

Zachowj, J. (2020, January 1). Homeassistant Domain. Retrieved November 25, 2020, from HA Nodes: https://zachowj.github.io/node-red-contrib-home-assistant-websocket/guide/call- service.html#homeassistant-domain

Zachowj, J. (2020, September 23). Current State. Retrieved 26 October 2020, from node-red- contrib-home-assistant-websocket: https://zachowj.github.io/node-red-contrib-home- assistant-websocket/node/current-state.html zachowj, J. (2020, September 23). Current State. Retrieved October 26, 2020, from HA Nodes: https://zachowj.github.io/node-red-contrib-home-assistant-websocket/node/current- state.html

Zachowj, J. (2020, September 26). Trigger: state. Retrieved 15 October 2020, from HA Nodes: https://zachowj.github.io/node-red-contrib-home-assistant-websocket/node/trigger- state.html#configuration

ZigBee devices - Overview. (2017, March 7). Retrieved July 27, 2020, from Cozify: http://blog.cozify.fi/2017/03/zigbee-devices-overview.html Zigbee Wireless Mesh Networking. (n.d.). Retrieved September 27, 2020, from Digi: https://www.digi.com/solutions/by-technology/zigbee-wireless-standard