Home Assistant (HA) is a free open source home automation software. You can integrate it with countless devices and services. We install it together with Node-RED and Mosquitto MQTT broker on Linux Mint. For this tutorial, I used Linux Mint 19.2 “Tina”.
Manual installation versus HASS.IO
You can install Home Assistant on a Raspberry Pi using HASS.IO, a ready-made image. HASS.IO also has an installer for all sorts of Add-ons. However, on Linux Mint you have to install everything manually. Below is a tutorial to help you on your way. After completing these steps you have a basic installation with Home Assistant, Node-RED and Mosquitto MQTT broker.
Install Home Assistant
To install Home Assistant on Linux Mint you can for the most part follow the instructions in “Manual installation on a Raspberry Pi“.
Perform an update of the installed packages: sudo apt-get update sudo apt-get upgrade -y
Install new packages: sudo apt-get install python3 python3-dev python3-venv python3-pip libffi-dev libssl-dev
Add user ‘homeassistant’ to the ‘diaout’ group. We do not include the “i2c” and “gpio” groups. sudo useradd -rm homeassistant -G dialout
Create the installation directory: cd /srv sudo mkdir homeassistant sudo chown homeassistant:homeassistant homeassistant
Create a “virtual environment” for user “homeassistant” sudo -u homeassistant -H -s cd /srv/homeassistant python3 -m venv . source bin/activate
Install Python wheel: python3 -m pip install wheel
Install HA: pip3 install homeassistant
Start HA: hass
Home Assistant autostart
To have HA start automatically, we broadly follow the instructions under “Python virtual environment” in the article “Autostart using systemd” on the HA website.
Use the command below to open the text editor Nano and create the service file for systemd:
When you’re done, press CTRL-X and then Y to save the file and close Nano.
Install Mosquitto MQTT broker
As an MQTT broker we will install Mosquitto, which is easy with the following command:
sudo apt install mosquitto
To test whether Mosquitto works properly, we can follow the instructions in the “MQTT Testing” article. Go to “Developer Tools” in HA and open the “MQTT” tab.
For example, you can enter the following in the “Topic” field:
You can then enter a message for the topic in the “Payload” field, for example:
In the “Listen to a topic” field, type a # to see everything:
Press “Start Listening” and then press “Publish”. The result should be like the following text:
Message 23 received on home-assistant/switch/1/power/stat/POWER at 12:16 PM:
QoS: 0 - Retain: false
Message 22 received on home-assistant/switch/1/power/stat/RESULT at 12:16 PM:
QoS: 0 - Retain: false
First install Node.js and npm, for example according to the instructions on this page: sudo apt-get install curl python-software-properties curl -sL https://deb.nodesource.com/setup_12.x | sudo bash - sudo apt-get install nodejs sudo apt-get install npm
In Node-RED, open the menu (click on the icon with the three horizontal lines), then:
Choose the menu option “Manage palette”
Select the “Install” tab
Search for “node-red-contrib-home-assistant-websocket”
Click on “Install”
When the installation is finished you will see the message “Nodes added to palette”
In the list on the left side of the screen, you will see new nodes below “home assistant”.
Start Node-Red automatically
To make Node-Red start when the computer starts up, you can follow the “Step 3 – Launching Node-RED on Startup” section of the instructions in this article, with a few minor adjustments.
Just like for HA, we create a service file with Nano:
sudo nano /etc/systemd/system/node-red.service
Paste the following code into the file:
ExecStart=/usr/bin/node-red --max-old-space-size=128 -v
# log output to syslog as 'node-red'
# non-root user to run as
Execstart must point to /usr/bin/node-red
WorkingDirectory, User and Group: enter the non-root username of your Linux Mint installation instead of myusername. In other words, the username with which you normally log in to Linux Mint.
Save the file with CTRL + X and then Y.
With the following command, Node-RED will now start automatically: