If you’re here, you probably know what Home Assistant is. If not, you can take a look at my previous article about Home Assistant.
Probably the easiest way to start with Home Assistant is with a Raspberry Pi, but instead of using one of these I chose to install it on a different board, an Orange Pi Zero.
Well, compared to a Raspberry Pi 3, an Orange Pi Zero is a pretty capable board, powerful enough for running Home Assistant in a smaller footprint at a very reasonable price (links below).
The lack of an HDMI port in the Orange Pi Zero is absolutely no problem in this type of application. And the power consumption is slightly lower than on a Raspberry Pi 3.
In this post I will show you how to install Home Assistant in a Python virtual environment on an Orange Pi Zero running Armbian, however, these steps are likely to work on most boards running debian-based systems.
Using a virtual environment will prevent your Python installation and Home Assistant installation from impacting each other.
First you have to have Armbian installed on your Orange Pi Zero, if you don’t know how to install it you can follow the steps I show in this other post.
Update the system
Then run these commands to be sure the system is up to date.
sudo apt-get update sudo apt-get upgrade
Install Python 3 dependencies
Install the required Python 3 dependencies with these commands.
sudo apt-get install python3 python3-dev sudo apt-get install python3-venv python3-pip
You can check the installed version ofPython 3 with this command.
python3 -V Python 3.5.3
Install Cryptography dependencies
Install the libffi package required by the cryptography package during the Home Assistant installation.
sudo apt-get install libffi-dev
Directory for Home Assistant
If you didn’t create a user account for Home Assistant when installing Armbian we will now do it with the command useradd.
sudo useradd -rm hass -G dialout
Since this account is only for running Home Assistant the extra arguments of -rm is added to create a system account and create a home directory. The argument -G dialout adds the user to the dialout group. This group is required for using Z-Wave and Zigbee controllers.
Create now a group for Home Assistant.
sudo addgroup homeassistant
Then we create a directory for the installation of Home Assistant and change the owner to the hass account.
sudo mkdir /srv/homeassistant sudo chown hass:homeassistant /srv/homeassistant
Virtual environment for Home Assistant
Next we create a python virtual environment for Home Assistant with the hass account.
sudo -u hass -H -s
python3 -m venv /srv/homeassistant
Now we activate the virtual environment.
Notice how the prompt changes once you have activated the virtual environment.
Run the following command to install the required wheel python package.
python3 -m pip install wheel ... Successfully installed wheel-0.31.1
Install Home Assistant
Finally, the time to install Home Assistant has come!
python3 -m pip install homeassistant ... Successfully installed MarkupSafe-1.0 PyJWT-1.6.4 aiohttp-3.4.0 asn1crypto-0.24.0 astral-1.6.1 async-timeout-3.0.0 attrs-18.1.0 bcrypt-3.1.4 certifi-2018.8.24 cffi-1.11.5 chardet-3.0.4 cryptography-2.3.1 homeassistant-0.77.0 idna-2.7 idna-ssl-1.1.0 jinja2-2.10 multidict-4.3.1 pycparser-2.18 pytz-2018.5 pyyaml-3.13 requests-2.19.1 six-1.11.0 urllib3-1.23 voluptuous-0.11.5 yarl-1.2.6
Start Home Assistant
Now that we have successfully installed Home Assistant it is time to run the hass command to start Home Assistant for the first time.
This will complete the installation, create the .homeassistant configuration directory in the /home/homeassistant directory and install any basic dependencies.
Be aware that when you run the hass command for the first time, it will download, install and cache the necessary libraries/dependencies. This procedure may take around 10 to 15 minutes. This will only happen for the first time, and subsequent restarts will be much faster.
Unable to find configuration. Creating default one in /home/hass/.homeassistant Config directory: /home/hass/.homeassistant ... ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Hello, and welcome to Home Assistant! We'll hope that we can make all your dreams come true. Here are some resources to get started: - Configuring Home Assistant: https://home-assistant.io/getting-started/configuration/ - Available components: https://home-assistant.io/components/ - Troubleshooting your configuration: https://home-assistant.io/getting-started/troubleshooting-configuration/ - Getting help: https://home-assistant.io/help/ This message is generated by the introduction component. You can disable it in configuration.yaml. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ... INFO (MainThread) [homeassistant.setup] Setup of domain sensor took 75.7 seconds ... INFO (MainThread) [homeassistant.bootstrap] Home Assistant initialized in 774.21s INFO (MainThread) [homeassistant.core] Starting Home Assistant core loop INFO (MainThread) [homeassistant.core] Starting Home Assistant ...
During this time, a “site cannot be reached” error may occur if you attempt to access the web interface.
After that time, you will be able to access your Home Assistant installation on your Orange Pi Zero via the web interface at http://ip_address:8123 (eg. http://192.168.1.144:8123/).
Create owner user account
Starting from version 0.77 the access to Home Assistant is secured by the authentication system and each member of the family will have their own user account to access Home Assistant.
So the first time you access the Home Assistant frontend you will be prompted to create the owner’s user account.
And then you will see the login pop-up where you will need to enter the username and password for the account you have just created.
And finally (drum rolls) the Home Assistant interface!!!
Starting Home Assistant on Boot
You probably don’t like to have to manually start Home Assistant every time you reboot the system, do you? So stop the home assistant process pressing Ctrl+Z and let’s automate the start of Home Assistant on Boot:
Create a service file to control Home Assistant with systemd using this command:
sudo nano -w /firstname.lastname@example.org
And copy this text in it:
[Unit] Description=Home Assistant After=network-online.target [Service] Type=simple User=%i ExecStart=/srv/homeassistant/bin/hass -c "/home/hass/.homeassistant" [Install] WantedBy=multi-user.target
Exit pressing Crtl+X and press Y to save the file.
Now you need to reload systemd to make the daemon aware of the new configuration.
sudo systemctl --system daemon-reload
To have Home Assistant start automatically at boot, enable the service.
sudo systemctl enable home-assistant@hass
If you want to start Home Assistant now, use this command.
systemctl start home-assistant@hass
And that’s it. You should have Home Assistant successfully installed on your Orange Pi Zero and it will start automatically at boot up.
In a next post we’ll continue configuring Home Assistant.
Comparison table between an Orange Pi Zero and a Raspberry Pi 3
|Orange Pi Zero||Raspberry Pi 3|
|SoC||Allwinner H2+||Broadcom BCM2837|
|CPU||Quad Core ARM Cortex-A7 (32 bits) @ 1.2GHz||Quad Core ARM Cortex-A53 (64 bits) @ 1.2GHz|
|GPU||Mali-400 MP2 @ 600 MHz||VideoCore IV @ 400 MHz|
|Memory (SDRAM)||256MB or 512MB DDR3-1866||1GB LPDDR2-900|
|WiFi||802.11 b/g/n||802.11 b/g/n|
(*) This power consumption has been measured using the same microSD card right after installing Home Assistant with no additional configuration using this USB current meter (Raspberry Pi 3 running HassOS 2.2, Orange Pi Zero 512MB running Armbian 5.59 / Debian Stretch 4.14.65 / Home Assistant 0.77.0).
Some handy links
Home Assistant, the missing piece I needed to get into home automation
How to install Armbian Debian on an Orange Pi Zero
Home Assistant : Manual installation on a Raspberry Pi
Home Assistant : Autostart using systemd
Home Assistant : Authentication System
AliExpress : Orange Pi Zero H2+ Quad Core Open-source 512MB Development Board with Wifi Antenna
Amazon : Orange Pi Zero H2+ Quad Core Open-source 512MB Development Board with Wifi Antenna
Amazon : Orange Pi Zero H2+ Quad Core Open-source 256MB Development Board with Wifi Antenna
Amazon : SanDisk Ultra 32GB microSDHC Memory Card with A1 App Performance, Class 10, U1
Amazon : SanDisk Ultra 16GB microSDHC Memory Card with A1 App Performance, Class 10, U1
Amazon : Samsung 32GB 95MB/s Memory Evo Plus Micro SD Card
The truth is that Hass.io is not something that is installed on top of this installation but a different way of installing Home Assistant using a Docker container.
The good news is that it is also possible to install Home Assistant using a Docker container (also known as Hass.io) on an Orange Pi Zero. And I’m writting a post about how to do it :) Stay tuned!
Hi there Alberto!
Very nice blog you have! Congratulations!
I would like to ask you something: do you know how to add the Hass.io add on tab on this home assistant installation?
Thank you and regards!
Thank you for the info Alberto!
Actually i installed the Home Assistant but the lack of out of the box features and some dificulty in make automations made me leave it…maybe the Hass.io is more easy beacuse of the add ons… one thing that i found amazing in home assistant was the ability to detect my xiaomi gateway and all the sensor without any configuration!!! what a powerfull software!!!
i’m looking forward to read your post about Hass.io! please post it ASAP!!! :)
Any news on that tutorial about HASS.IO on Orange pi zero?
I’m sorry, I’ve been quite busy lately. I’ll post more articles on the blog this week, but I can’t promise it will be that one.