ιΌ 
2020

Home Assistant on FreeBSD

Not just Linux

Reading up on Home Assistant you might assume it requires only runs with docker, or a raspberry pi or just requires Linux in general. With a venv python install (aka core), hit can run anywhere python works - in theory. If you want a self contained dedicated install a raspberry pi is the best option by far.

Preparations

The FreeBSD install is documented by an article detailing the install on FreeNAS. The first consideration is if installing it in a Jail. Like docker, this offers a few advantages. Security isolation is the obvious benefit but it also means you don't have to worry about Home Assistant taking up network ports on a FreeBSD install that you are using for other things (like mdns). I chose not to do it this way due to added complexity and the fact that I have faith that my local network is somewhat secure and the machine is internally firewalled and encryption is required to connect anyway.

I used an install location of /usr/local/hass. Consider making this a zfs dataset if using zfs. Backup's become trivial and doing a snapshot before an upgrade makes fixing a bad install/upgrade as simple as a rollback. Home Assistant upgrades have generally worked for me but I have done rollbacks as well.

ZFS Block size defaults to 128k. This can lead to read/write amplification. Reading or writing 1k still requires the entire block is used. Reducing the block size can mitigate this but reduces storage efficiency. The recommended record size is 64k for SQLite - the database Home Assistant uses and spends most of its time reading/writing. This may be something to consider if creating a dataset for home assistant.

Requirements

Install

I don't use a jail but most of the directions for FreeNAS are about the same: Installing Home Assistant on FreeNAS. Basically set up venv from the target dataset, using a user specifically for Home Assistant (I have a user called hass).

 cd /usr/local/hass
 su hass -
 python3 -m venv .
 source bin/activate
 pip3 install homeassistant
 

Upgrade

 cd /usr/local/hass
 su hass -
 source bin/activate
 pip3 install --upgrade homeassistant
 

Upgrading Python will break this install and your snapshots won't help if things are completely busted. You can however go back to an old version of python and restore the snapshot later, so what level of adventure you want is up to you. The basic procedure is to save the data for your instance (located in .homeassistant). Wipe everything in the dataset directory. Copy the .homeassistant directory back. Then install again.

Issues

While it worked previously, the home assistant shutdown event doesn't trigger as an automation on system shutdown (platform: homeassistant, event: shutdown). Possibly due to network being down before home assistant can send packets.

NPC Company