Updated Feb 10 2020
Changing the Home Assistant Brand
The purpose here is only to explain how this thread fits into the scheme of things
depending on where in time it relates to Changing the Home Assistant Brand
Finding a place in time
A = Home Assistant
B = Hass.io
C = Home Assistant Core
Forever in time
- The following statement is always
TRUE
- This thread is about installation on FreeNAS using a python virtualenv
- This does not use Docker
From the beginning of time until January 29 2020
A = A
B = B
- During this time the following statement was
TRUE
- This will install Home Assistant in a python virtualenv
- This does not use Docker
- This is not Hass.io
From January 30 2020 until the end of time
A = C
B = A
- During this time the following statement is
TRUE
- This will install Home Assistant Core in a python virtualenv
- This does not use Docker
- This is not Home Assistant
my personal thoughts
… don’t really matter.
I agree with what they are after but I think the new naming, as it stands now, has not gone far enough and will only lead to different confusion. I think it is unfortunate the community was not given any further consideration it the final decision because I think there were several other naming conventions suggested by community members that could have done a better job clearing things up without additional confusion. That is just my opinion.
I do not agree 100% with the new naming but I do respect the final decision has been made.
The discussion has already been closed and will not be reopened here.
I was going to remove the outdated 11.2 guide and keep updating this original post for FreeNAS 11.3 – Now after some suggestion from a few friends, I have to agree that is probably better to just move on. Simply put there are around 230 posts with an estimated read over an hour. Coming to thread this on FreeNAS 11.3 will just have too much outdated information to get through before reach anything current to FreeNAS 11.3. The other factor is name change. After second thoughts, I’m thinking it is probably not gonna help the issue if the first 200+ posts are referring to something that was one thing, but now, that one thing has become something else… Anyways onward to the future…
New Branding = Home Assistant Core | FreeNAS 11.3 = New Thread
Old Branding = Home Assistant | FreeNAS 11.2 = This Old Thread
The FreeNAS 11.2 guide now outdated will no longer be updated.
- FreeNAS 11.2 is using the 11.2-RELEASE This release has reach EOL
- If you are on FreeNAS 11.2-U7 or later, you can use the 11.3-RELEASE instead
Getting Started
This “Getting Started” section covers some optional FreeNAS configuration. This is technically not required for Home Assistant, however in my opinion, may provide a better overall experience. For example, having a separate dataset to contain Home Assistant configuration, which can then be shared over a network, allowing to easily edit the files from outside the jail. While these steps can be performed at any time, I find the easiest results can be achieved by starting here before you begin creating your jail. Additional steps will be required if this is done after Home Assistant is installed.
Show Me
Installing FreeNAS is not the scope of this guide however only minimal configuration is assumed.
My FreeNAS setup for this guide
- Storage pool named
tank
- User account named
troy
- Change these to match your setup through out this guide
I have also started these services on FreeNAS
- ssh for remote console connection to FreeNAS
- samba for network access to Home-Assistant configuration
Typically, the jail user is similar to the service application name running inside the jail. Also, the UID/GID are usually the same as the port number used by the service. I will be using a user/group hass
inside the jail, with a UID/GUID of 8123
matching the default Home Assistant port.
Setting up a separate dataset for Home Assistant configuration
- Required for using a network share to access configuration
- Allow FreeNAS user
troy
and jail userhass
READ/WRITE access to files
Create the hass
group on FreeNAS
Create the dataset for hass
Share the dataset via samba (network)
Installing Home Assistant Core on FreeNAS 11.2
There are several options for installing Home Assistant Core on FreeNAS
- This is using the 11.2-RELEASE This release has reach EOL
- If you are on FreeNAS 11.2-U7 or later, you should use the 11.3-RELEASE instead
iocage standard-jail – Scripted Install
- Recommended - Basically this is a scripted version of the manual install
- Includes simple console menu to execute updates
–
Show Me
Download pkg-list and create a jail using it to install requirements
wget -O /tmp/pkglist.json https://raw.githubusercontent.com/tprelog/iocage-homeassistant/11.2-RELEASE/pkg-list.json
sudo iocage create -r 11.2-RELEASE boot=on dhcp=on bpf=yes vnet=on vnet_default_interface=auto -p /tmp/pkglist.json -n homeassistant
Optional: mount a dataset inside the jail
sudo iocage fstab -a homeassistant "/mnt/tank/user/hass /home/hass nullfs rw 0 0"
Git script and begin install
sudo iocage exec homeassistant git clone -b 11.2-RELEASE https://github.com/tprelog/iocage-homeassistant.git /root/.iocage-homeassistant
sudo iocage exec homeassistant bash /root/.iocage-homeassistant/post_install.sh standard
Answer questions will choose what gets installed
Install Home-Assistant? [Y/n]:
Install Hass-Configurator? [Y/n]:
App-Daemon & HA-Dashboard? [Y/n]:
Use the pre-configured examples? [Y/n]:
Profit!
Screenshots
iocage standard-jail – Manual Install
- If you are on FreeNAS 11.2-U7 or later, you should use the 11.3-RELEASE instead
–
Show Me
Creating a jail
Starting with FreeNAS 11.2 new jails can be created and datasets mounted using the GUI. This can be an advantage if you’d like to customize many options.
To quickly create a jail with default settings it is still much quicker to use the FreeNAS console.
I will -n
name this jail homeassistant
and since I assign the ip-address from my router I set the jail to use dhcp
sudo iocage create -r 11.2-RELEASE dhcp=on bpf=yes vnet=on vnet_default_interface=auto boot=on -n homeassistant
Mounting a dataset inside you jail
- This will require a pre-existing dataset.
- This step is optional for Home-Assistant however it is required if you plan access your Home-Assistant configuration directory using any type of network file sharing (ie samba).
- While this can be done later, it is much easier to have this already mounted before installing Home-Assistant
I’m going to mount the /mnt/tank/user/hass
dataset I created earlier. It will be mounted inside the jail at /home/hass
and will contain the Home-Assistant configuration directory.
iocage fstab -a homeassistant "/mnt/tank/user/hass /home/hass nullfs rw 0 0"
Install jail requirements
Log into the homeassistant
JAIL console
sudo iocage console homeassistant
Install requirements for Home-Assistant and Z-Wave
pkg update && pkg upgrade
pkg install python37 py37-sqlite3 bash gmake ca_root_nss
At this point I believe you can finish installing Home-Assistant following any desired pip (python) install method.
Installing Home-Assistant
- It has been pointed out that a virtualenv inside a jail is not needed since the jail itself is already a jail! I still prefer this method.
Best practice suggests to create a user/group hass
then install Home-Assistant inside a python virtualenv.
If not already, log into the homeassistant
JAIL console
sudo iocage console homeassistant
Create a user to run Home-Assistant
- Typically, the user and group names are similar to the application name. Also, the UID and GID are usually the same as the port number used by the service.
- I’m creating a user
hass
with a UID/GUID of8123
matching the default Home-Assistant port.
The next commands, create a home directory if it does not already exist, as well as adding the group and user.
I will add hass
to the dialer
group as required for using the (USB) Aeotec Z-Wave stick.
install -d -g 8123 -o 8123 -m 775 -- /home/hass
pw addgroup -g 8123 -n hass
pw adduser -u 8123 -n hass -d /home/hass -w no -s /usr/local/bin/bash -G dialer -c "Daemon User for Home-Assistant"
Install pip requirements and create directory to install Home Assistant virtualenv
python3.7 -m ensurepip
pip3 install --upgrade pip
pip3 install --upgrade virtualenv
install -d -g hass -o hass -m 775 -- /srv/homeassistant
Switch to user hass
, activate the virtualenv and finally install Home-Assistant!
su - hass
virtualenv -p /usr/local/bin/python3.7 /srv/homeassistant
source /srv/homeassistant/bin/activate
pip3 install --upgrade homeassistant
deactivate && exit
Automatically starting on boot-up
Create directory if it doesn’t exist and add the startup script
mkdir -p /usr/local/etc/rc.d
ee /usr/local/etc/rc.d/homeassistant
Show File: /usr/local/etc/rc.d/homeassistant
#!/bin/sh
# PROVIDE: homeassistant
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# homeassistant_enable: Set to YES to enable the homeassistant service.
# Default: NO
# homeassistant_user: The user account used to run the homeassistant daemon.
# This is optional, however do not specifically set this to an
# empty string as this will cause the daemon to run as root.
# Default: USER_NAME
# homeassistant_group: The group account used to run the homeassistant daemon.
# This is optional, however do not specifically set this to an
# empty string as this will cause the daemon to run with group wheel.
# Default: USER_GROUP
# homeassistant_config_dir: Directory where homeassistant config is located.
# Default: ~/homeassistant
#
# copy file to /usr/local/etc/rc.d/homeassistant
# chmod +x /usr/local/etc/rc.d/homeassistant
#
# sysrc homeassistant_enable=yes # to enable
# sysrc homeassistant_config_dir="~/homeassistant" # to change
# service homeassistant start # to start
. /etc/rc.subr
name=homeassistant
rcvar=${name}_enable
pidfile_child="/var/run/${name}.pid"
pidfile="/var/run/${name}_daemon.pid"
logfile="/var/log/${name}_daemon.log"
load_rc_config ${name}
: ${homeassistant_enable:="NO"}
: ${homeassistant_user:="hass"}
: ${homeassistant_group:="hass"}
: ${homeassistant_config_dir:="/home/hass/homeassistant"}
command="/usr/sbin/daemon"
start_precmd=${name}_precmd
homeassistant_precmd()
{
rc_flags="-f -o ${logfile} -P ${pidfile} -p ${pidfile_child} /srv/homeassistant/bin/hass --config ${homeassistant_config_dir} ${rc_flags}"
if [ ! -e "${pidfile_child}" ]; then
install -g ${homeassistant_group} -o ${homeassistant_user} -- /dev/null "${pidfile_child}";
fi
if [ ! -e "${pidfile}" ]; then
install -g ${homeassistant_group} -o ${homeassistant_user} -- /dev/null "${pidfile}";
fi
if [ ! -e "${logfile}" ]; then
install -g ${homeassistant_group} -o ${homeassistant_user} -- /dev/null "${logfile}";
fi
if [ ! -d "${homeassistant_config_dir}" ]; then
install -d -g ${homeassistant_group} -o ${homeassistant_user} -m 775 -- "${homeassistant_config_dir}"
fi
}
stop_postcmd=${name}_postcmd
homeassistant_postcmd()
{
rm -f -- "${pidfile}"
rm -f -- "${pidfile_child}"
}
run_rc_command "$1"
copy and paste. Press escape then enter twice to save and exit
Make this file executable and enable
chmod +x /usr/local/etc/rc.d/homeassistant
sysrc homeassistant_enable=yes
Finally we can start Home-Assistant
service homeassistant start
From the FreeNAS console You can list jails you have installed and see if they are running. (showing ip addresses requires root
)
sudo iocage list -l
+-----+---------------+------+-------+------+-----------------+---------------------+-----+----------+
| JID | NAME | BOOT | STATE | TYPE | RELEASE | IP4 | IP6 | TEMPLATE |
+=====+===============+======+=======+======+=================+=====================+=====+==========+
| 1 | homeassistant | on | up | jail | 11.2-RELEASE-p3 | epair0b|192.0.1.179 | - | - |
+-----+---------------+------+-------+------+-----------------+---------------------+-----+----------+
Managing your Home-Assistant jail
- How to Update and Start or Stop Home Assistant Core service from the console
–
Show Me
Upgrading Home Assistant Core to use python 3.7
Easily perform updates from a menu
- Included only with the Scripted Install
- Works from FreeNAS console
Show Me
sudo iocage exec homeassistant bash update
Login to JAIL console
sudo iocage console homeassistant
These commands are run from the JAIL console:
- No
sudo
command in the jail since we’re alreadyroot
Control the installed service(s)
Home-Assistant
service homeassistant [start|stop|status|restart]
AppDaemon\HA-Dashboard
service appdaemon [start|stop|status|restart]
Hass-configurator
service configurator [start|stop|status|restart]
Upgrade PiP
To also upgrade pip
just include pip3 install --upgrade pip
Otherwise you can skip this line in the commands below
Upgrade homeassistant
service homeassistant stop
su - hass
source /srv/homeassistant/bin/activate
pip3 install --upgrade pip
pip3 install --upgrade homeassistant
deactivate && exit
service homeassistant start
Upgrade appdaemon:
service appdaemon stop
su - hass
source /srv/appdaemon/bin/activate
pip3 install --upgrade pip
pip3 install --upgrade appdaemon
deactivate && exit
service appdaemon start
Upgrade configurator:
service configurator stop
wget https://raw.githubusercontent.com/danielperna84/hass-configurator/master/configurator.py -O /srv/configurator/configurator.py
chmod +x /srv/configurator/configurator.py
service configurator start
Update FreeBSD packages
standard-jail or plugin-jail
pkg update && pkg upgrade
Backup Home-Assistant config directory using zip
zip
is not installed by default. To use this command you will need to first install zip
pkg update && pkg install zip
create backup as user hass
su - hass
zip -9 -q -r homeassistant-backup /home/hass/homeassistant -x"components/*" -x"deps/*" -x"home-assistant.log"
exit
These commands are run from the FreeNAS Console
Create a snapshot of Home-Assistant jail
The following would on Oct 3 2018
create a snapshot named [email protected]
-n
= “Name_of_Snapshot”
sudo iocage snapshot homeassistant -n $(date +%Y.%m.%d)
List snapshots in homeassistant
sudo iocage snaplist homeassistant
Rollback to previous snapshot
sudo iocage stop homeassistant
sudo iocage rollback homeassistant -n 018.10.03
sudo iocage start homeassistant
Remove snapshot from homeassistant
sudo iocage snapremove homeassistant -n 018.10.03
If you need to restart the jail iocage docs recommend using the -s
switch.
This “soft-restart” will help prevent issues that could arise from a “hard-restart” when vnet=on
sudo iocage restart -s homeassistant
You can also start or stop the jail.
sudo iocage [start|stop] homeassistant
Update / Upgrade Jail RELEASE:
update the Jail for example from 11.1-RELEASE-p10
to 11.1-RELEASE-p14
sudo iocage update homeassistant
upgrade the Jail for example from 11.1-RELEASE-p10
to 11.2-RELEASE-p3
sudo iocage upgrade -r 11.2-RELEASE homeassistant
My other plugins for FreeNAS 11.2
These plugins are using the 11.2-RELEASE
- These are for FreeNAS 11.2 only
- This release has reach EOL
–
Amazon Dash
Create a separate FreeNAS plugin running - Amazon Dash
wget -O /tmp/amazon-dash.json https://raw.githubusercontent.com/tprelog/iocage-amazon-dash/master/amazon-dash.json
sudo iocage fetch -P dhcp=on vnet=on vnet_default_interface=auto bpf=yes boot=on -n /tmp/amazon-dash.json --branch 'master'
Mosquitto MQTT Broker
Create a separate FreeNAS plugin running - Eclipse Mosquitto
wget -O /tmp/mosquitto.json https://raw.githubusercontent.com/tprelog/iocage-mosquitto/11.2-RELEASE/mosquitto.json
sudo iocage fetch -P dhcp=on vnet=on vnet_default_interface=auto bpf=yes boot=on -n /tmp/mosquitto.json --branch '11.2-RELEASE'
Node-RED
Create a separate FreeNAS plugin running - Node-RED
wget -O /tmp/node-red.json https://raw.githubusercontent.com/tprelog/iocage-node-red/11.2-RELEASE/node-red.json
sudo iocage fetch -P dhcp=on vnet=on vnet_default_interface=auto bpf=yes boot=on -n /tmp/node-red.json --branch '11.2-RELEASE'
TasmoAdmin
Create a separate FreeNAS plugin running - TasmoAdmin
wget -O /tmp/tasmoadmin.json https://raw.githubusercontent.com/tprelog/iocage-tasmoadmin/11.2-RELEASE/tasmoadmin.json
sudo iocage fetch -P dhcp=on vnet=on vnet_default_interface=auto bpf=yes boot=on -n /tmp/tasmoadmin.json --branch '11.2-RELEASE'
Screenshots