Home Assistant on Orange Pi Zero

NOTICE:  DUE TO CHRONIC STABILITY PROBLEMS, I DO NOT RECOMMEND USING STANDARD ARMBIAN ON OPZero.  DIET PI RESOLVES STABILITY ISSUES.  NEW BLOG POST WILL BE FORTHCOMING.

 

 

Guide here: https://home-assistant.io/blog/2017/05/13/home-assistant-on-orange-pi-zero/

Phase 1

Important: Have your router set the IP for the Orange Pi before you configure it. Manual configuration has broken the entire thing several times.

  1. Download Armbian for pi zero
  2. Download Etcher
  3. Extract Armbian and use etcher to burn image to microSD card (I used 2GB which may be too small)
  4. Insert mSD and plug into network.
  5. Check router for IP after giving time to boot.

Phase 2

Save a profile to putty:

  • include: keepalive 10 as per this post and enlarge the font if you are old like me and don’t like craning your neck to watch terminal output.

  • Putty to SSH into PiZero with root:1234

Change root password and create a user so you don’t have to use root.

sudo apt-get update

sudo apt-get upgrade

(directory locked and had to reboot first).   This step takes a while to download and install packages.


Phase 3

next install python and its packages:
sudo apt-get install python3-dev python3-pip python3-venv


Now execute the following:
ha@orangepizero:~$ pyvenv-3.5 homeassistant

ha@orangepizero:~$ cd homeassistant && source bin/activate


(homeassistant) ha@orangepizero:~/homeassistant$ pip3 install --upgrade pip


(homeassistant) ha@orangepizero:~/homeassistant$ pip3 install homeassistant


(homeassistant) ha@orangepizero:~/homeassistant$ hass

USE pyenv-3.4 if in dietpi

aiohttp takes quite a while to install so go get coffee or something. First loading hass also takes a while and appears to hang at several points.  That’s okay. Just give it some time.

Make sure to upgrade pip3 from the venv once it’s initiated.  Not doing that will cause a raft of errors.

There can be problems with venv so if needed, just destroy it with

sudo rm -rf homeassistant

Whoop! Dare it is!

Capture

I then restored by configs from the .homeassistant directory.

This threw errors for pylutron-caseta (because it wasn’t installed yet) and mqtt because mosquitto wasn’t installed yet.


Tackling mosquitto as a broker:

sudo apt-get install mosquitto

apt-get install mosquitto-clients

Gotta have both to monitor the messages using:

mosquitto_sub -h 127.0.0.1 -t “home-assistant/”


There is also a known issue with installation of pylutron-caseta (click for forum link).

To solve this one:

sudo apt-get install build-essential libssl-dev libffi-dev python-dev

Until you do that, you won’t get anywhere installing pylutron-caseta.

Also, be aware that pynacl take an extremely long time to install due to it only using one of the 4 cores for compilation.  There is a bug and fix enroute for this at the time of writing.

sudo -H pip3 install pylutron-caseta

This eventually installs in the venv after a reboot.  I also installed paho-mqtt through pip but am unsure if it is needed at all.

There are some super useful aliases which you’ll want to edit the .bashrc to add:


alias config='nano ~/.homeassistant/configuration.yaml'

alias checkconfig='hass --script check_config'


alias venv='cd ~/homeassistant && source bin/activate'


alias hasslog='nano ~/.homeassistant/home-assistant.log'


alias customize='nano ~/.homeassistant/customize.yaml'


alias restart='sudo systemctl restart home-assistant@ha'


alias status='sudo systemctl status home-assistant@ha'


alias stop='sudo systemctl stop home-assistant@ha'


alias start='sudo systemctl start home-assistant@ha'


alias secrets='nano ~/.homeassistant/secrets.yaml'

Don’t forget to enable HASS autostart.

file location:

/etc/systemd/system/home-assistant@ha.service

[Unit]
Description=Home Assistant
After=network.target

[Service]
Type=simple
User=%i

## The line below needs modification based on file location

ExecStart=/srv/homeassistant/bin/hass -c “/home/homeassistant/.homeassistant”

[Install]
WantedBy=multi-user.target


Install Armbian Monitor to use web interface for stats

sudo armbianmonitor r

Port: 8888


Samba

Setup here 


To Do list:

  1. Shell script automate backups of config files to github.  cron job.
  2. Backup to image using easus and win32 Disk Imager
    1. Test restored backups to secondary card
    2. Try restoring to disparate size card
  3.  Automate shell script complete disk image backups.
  4.  change units of some sensors so they don’t all get graphed together
    1. Particularly the DarkSky API sensor.
  5.  Automatically enter the venv from login/boot
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s