Skip to content

Instantly share code, notes, and snippets.

@cerealkill
Last active May 1, 2019 20:24
Show Gist options
  • Save cerealkill/c7ac72a8e685ca1b8d50cc014c19d258 to your computer and use it in GitHub Desktop.
Save cerealkill/c7ac72a8e685ca1b8d50cc014c19d258 to your computer and use it in GitHub Desktop.

Home-Assistant Hassbian Configuration

Table of Contents

  1. Introduction
  2. SDCard
  3. Network Configuration
  4. System Configuration
  5. Home-Assistant

1. Introduction

The Home-Assistant project offers it's own linux distribution to host the home automation system in a Raspberry Pi portable computer. This tutorial aims to help anyone whom might join the adventure of using and configuring this system. Another good source is this video.

Requirements

  1. Raspberry Pi
  2. Computer
  3. Internet access

No extra keyboard or monitor is needed to use or configure the Hassbian. Setting up Hassbian requires internet connection.

2. SDCard

First step is writing the SDCard with Hassbian image, next is choosing cable over wi-fi connection. Instructions in the official website cover only cable and this tutorial tries to cover both, pick a flavor: user friendly or command line.

Official Instructions

  1. Download the Hassbian image (364 MB)
  2. Use Etcher to flash the image to your SD card
  3. Ensure your Raspberry Pi has wired access to the internet.
  4. Insert SD card to Raspberry Pi and turn it on. Initial installation of Home Assistant will take about 5-10 minutes.
  5. Proceed to Network Configuration.

MacOS Terminal

In this tutorial I will dd, a command-line tool that requires some knowledge for it can seriously damage the computer's operating system.

Proceed only when safe, if not proceed via the official website instructions. Commands may vary from system to system.

  1. Download Hassbian image
  2. Go to downloads folder and unzip it. Note it may be a newer version number.
$ cd ~/Downloads
$ unzip Hassbian_1.23.zip
  1. Insert the SSDCard if it's not in it's socket.
  2. List mounted devices and unmount the SDDCard. In my case the SDDCard is disk2 and partitions are disk2s1 and disk2s2.
$ diskutil list
$ diskutil umount /dev/disk2s1
  1. Write the disk using dd. After dd starts nothing is written to tell the user it's going on, but it is, just wait a few minutes until it's finished. :)
$ sudo dd bs=1m if=2017-05-09-Hassbian.img of=/dev/disk2
1324+1 records in
1324+1 records out
1389256704 bytes transferred in 311.064509 secs (4466137 bytes/sec)
  1. To connect the raspberry using the ethernet cable just run diskutil umount /dev/disk2s1 to unmount the device and safely unplug from the computer then insert in the Raspberry Pi and proceed to cable topic. Otherwise just follow steps in the Wi-Fi session before unmounting.

3. Network Configuration

There is two ways to get hassbian up and running with Home-Assistant installed and available. By plugging it to an ethernet cable or by configuring the wi-fi connection before installing. This wi-fi setup should work for both Raspberry v3, with wi-fi builtin, and older versions with a wi-fi dongle connected to it.

Ethernet Cable

The vanilla way described in Home-Assistant website is to connect it directly in a router port with an ethernet cable, power it up and proceed to the system configuration session.

Wi-Fi

To enable wi-fi to work in the same way that plugging the ethernet cable does a file must be created in the SDCard boot partition. Since Win, Linux and Mac all them mount this partition automatically, the task is easy as create the file and write the right contents in it.

This tutorial uses nano to edit the file, but any text editor can be used. In MacOS the command open will open a dialog for the user to choose a program to open the file.

Writing the configuration file in MacOS command-line

  1. Go to the boot mounted partition, or drive letter in Win, and create the wpa_supplicant.conf file.
$ touch wpa_supplicant.conf
  1. Open the configuration file with the text editor of choice.
$ nano wpa_supplicant.conf
  1. Write it with wi-fi ssid and password between the double-quotes ".

SSID is the name of the network. ie.: "Home Wi-Fi"

PSK or password key is the network's password. ie.: "shhh it's a secret!"

network={
  ssid="Wi-Fi network name example"
  psk="password string example"
}

In case the wi-fi network has no password just use this configuration instead.

network={
    ssid="Open network example"
    key_mgmt=NONE
}
  1. Save the file. If using nano press ctrl+o, enter to confirm, then ctrl+x to exit the editor.

In mac keyboards press command+o and command+x instead.

  1. Eject or unmount before unplugging the SSDCard from the computer and insert it in the Raspberry Pi slot.
  2. Proceed to System Configuration.

4. System Configuration

By now the Rasberry Pi shall be powered and accessing the internet. After it is powered just wait a few minutes before checking out if hassbian home is already up. Hassbian uses this minutes to configure the device, download the latest version of Home-Assistant and install it. Access it be sure

Login

Access and login are required to change the Home-Assistant configurations files. The default credentials for the hassbian are pi and password raspberry. After running ssh pi@hassbian type yes to add hassbian as a trusted device and then insert the password.

This tutorial uses ssh. Windows users might use PuTTY or MinGW.

 $ ssh pi@hassbian
The authenticity of host 'hassbian (192.168.1.120)' can't be established.
ECDSA key fingerprint is SHA256:8L+WLEcJdiG2cD/C81doennZ+4Ggf/XZNP7aQjT96YE.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'hassbian' (ECDSA) to the list of known hosts.
pi@hassbian's password:

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Jul 10 07:55:54 2017 from c3po

SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.

pi@hassbian:~ $

If hassbian hostname is not available try enabling network discovery in the os or running a scanner like nmap.

$ nmap -p 8123 192.168.1.2-255
Nmap scan report for hassbian (192.168.1.120)
Host is up (0.021s latency).

PORT     STATE    SERVICE
8123/tcp filtered polipo

Password

By default the pi user is not enabled to execute sudo or super user commands before updating password. To update run sudo passwd pi and type in the new password twice.

pi@hassbian:~ $ sudo passwd pi
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Raspi-Config

The raspi-config tool is a very easy to use gui to enable all kinds of linux system configurations. The most important steps are configuring the timezone and wi-fi channels regulations in the Localization Options menu. Countries have different regulations that might apply heavy fees for noncompliance.

pi@hassbian:~ $ sudo raspi-config

5. Home-Assistant

Configuring home-assistant to know your available extensions and devices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment