Setup Home Assistant on Linux Ubuntu 16.04





 

Home Assistant

Setup Home Assistant on Ubuntu 16.04

please note this setup only works up to HASS V 0.64 since Python V 3.5.3 is required and Ubuntu 16.04 can’t easily support it, therefore, for the latest versions of Home Assistant (HASS) V 0.65 and above I’d highly suggest to setup Hass.io it works lika a charm out of the box. Instructions here HASS.IO

Here are the steps I use to install Home Assistant on Linux Ubuntu 16.04 in a virtualenv scenario.


In this example I used 192.168.1.206 as my Ubuntu server IP address and 192.168.1.1 as my router (gateway) IP address, 8.8.8.8 as google DNS IP address.

Once the server is installed.

Use the following command to check the current IP address and other network settings.

ifconfig -a

Set the IP address as static.

sudo nano /etc/network/interfaces

Add the following settings:


auto eth0
iface eth0 inet static
address 192.168.1.206
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1 8.8.8.8

To save use the following keys,


CTRL + X
Y
Enter

Now let’s proceed with the actual setup.(the user I used in this example is “hass”)


sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python-pip python3-dev
sudo pip install --upgrade virtualenv
pip install --upgrade pip
sudo mkdir /srv/homeassistant
sudo chown hass /srv/homeassistant
virtualenv -p python3 /srv/homeassistant
source /srv/homeassistant/bin/activate
pip3 install --upgrade homeassistant

To run Home Assistant

sudo -u hass -H /srv/homeassistant/bin/hass

To easily make changes to your configuration setup Samba so you can easily view and browse the Home Assistant folder from a Windows PC

I recommend using Putty to connect to the Home Assistant server so you can easily paste code.
Install Samba.


sudo apt-get install samba
sudo nano /etc/samba/smb.conf

Delete everything inside.

Hold down CTRL + K

Paste the following configuration using right click if you use Putty.


[global]
netbios name = Hass
workgroup = WORKGROUP
hosts allow
remote announce =
remote browse sync =


[HOME ASSISTANT]
path = /home/hass/.homeassistant
comment = No comment
browsable = yes
read only = no
valid users =
writable = yes
guest ok = yes
public = yes
create mask = 0777
directory mask = 0777
force user = root
force create mode = 0777
force directory mode = 0777
hosts allow =


[SAMBA CONFIG]
path = /etc/samba/
comment = No comment
browsable = yes
read only = no
valid users =
writable = yes
guest ok = yes
public = yes
create mask = 0777
directory mask = 0777
force user = root
force create mode = 0777
force directory mode = 0777
hosts allow =


sudo smbpasswd -a hass

Choose a password to use it in Windows to get into Home Assistant configuration.
Restart SAMBA.

sudo service smbd restart
sudo reboot

Install Mosquitto.


sudo apt-get install mosquitto
sudo apt-get install mosquitto-clients
sudo nano /etc/mosquitto/mosquitto.conf

Type in file the following configuration.


allow_anonimous false
password_file /etc/mosquitto/pwfile
listner 1883

Then save.

CTRL + X
Y
Enter

Set a username and a password for Mosquitto.


sudo mosquitto_passwd -c /etc/mosquitto/pwfile mqttuser


sudo reboot

To upgrade Home Assistant:


sudo su -s /bin/bash hass
source /srv/homeassistant/bin/activate
pip3 install --upgrade homeassistant
sudo su -s /bin/bash hass
sudo -u hass -H /srv/homeassistant/bin/hass

Start Home Assistant as a service on startup.


sudo systemctl --system daemon-reload
sudo nano -w /etc/systemd/system/home-assistant@hass.service
sudo systemctl daemon-reload
sudo systemctl enable home-assistant@hass
sudo systemctl start home-assistant@hass
sudo reboot

References:
https://home-assistant.io/docs/autostart/systemd/ ** to make Hass autostart **
https://www.youtube.com/watch?v=AsDHEDbyLfg ** mqtt setup **

Leave a Reply

Your email address will not be published. Required fields are marked *