Categories
Home Automation

Home Assistant Snap

In this article will we install Home Assistant using the Snap Package manager on the Ubuntu Core operating system.

Note: The package will remove the hass-ending of the running daemon from home-assistant-snap.hass to only home-assistant-snap

Preface: I have for quite some time (~2 years) thought about packing Home Assistant as a Snap package. My motivation of doing it is that I have been managing up to forty holiday properties during the high season – the past years – and I’ve spent to much time traveling between them, just to make sure windows and doors are closed, temperature is adjusted to a normal level etc. Actually that much that I needed corona to stop the tourism and a summer holiday to rest – to get started with it.

The thought of updating and system maintenance and configuration in every apartment sounds very time consuming and cumbersome, which led me to look at and play around with Ubuntu Core. An strictly confined all-snap operating system, optimized for security and reliability, with transactional updates.

However the Snap Package Manager is shipped with many of the popular Linux Distributions and most likely available for the one you’re using, so if you’re here just to install the Snap package in your system and get familiar with how you configure this version – just follow along.

You can find supported operating systems at the official Snapcraft documentation.

Installation

If you’re unfamiliar with how snap works, you’ll be surprised how quick and easy the installation process is. To install everything needed you’ll have to open up a terminal session, and login over SSH if you’re installing this on a remote/headless computer. In my case am I using a Raspberry Pi 3.

Install home-assistant-snap with the command

sudo snap install home-assistant-snap

After a short while is Home Assistant downloaded, installed and running on your system.

If you installed Home Assistant on your local network, you should be able to reach the setup at http://homeassistant.local:8123/, but in my case I’m using a remote computer on a different network, and therefor will have to use the IP of the computer http://192.168.33.19:8123/.

If you can’t use the homeassistant.local-address and need to figure out the IP of the computer, you can use the command ifconfig on most operating systems, or install toolbox on Ubuntu Core and use the command toolbox.ifconfig.

When you have located Home Assistant in your browser, continue the setup by filling in your details to create a user account and a new zone for your installtion.

Configuration

As the installation process doesn’t give you any clue on how to configure the newly installed app, I will give a brief description here that you need to know to configure Home Assistant for your needs.

Since snap-packages is running in a sandbox-mode and doesn’t have access to the host system, several file systems is mounted on the host system. See the security policy walkthrough at Snapcraft.io if you interested to learn more about it.

We will be using the SNAP_DATA-directory, which in most cases is set to /var/snap/home-assistant-snap/<revision>, but it might be different on a non-Ubuntu system – without being sure.

If you can figure out the directory, login to the Home Assistant daemon with

sudo snap run --shell home-assistant-snap.hass

and execute the command echo $SNAP_DATA, note the output and exit the shell.

Another note is that you should always change the revision number in the path to the word «current», as this is a symlink to the actual revision being used at the system. If you edit files in an unused revision it won’t make any changes to the configuration being used.

When you have determined the path, you can use VIM on Ubuntu Core or your favorite editor on any other distribution. To edit the main configurations file, e.g:

sudo vi /var/snap/home-assistant-snap/current/configuration.yaml

See the official documentation on advanced configuration of Home Assistant for guidance. You can configure the snap-release just as any other release of Home Assistant.

When you’re done editing a configuration file Home Assistant requires a restart to be applied. You restart Home Assistant with

sudo snap restart home-assistant-snap.hass

And it should be up running again shortly after a short while, with the changes applied.

Home Assistant will fail to start if the configuration in invalid, so it’s recommended to watch the log

sudo journalctl -xef --unit=snap.home-assistant-snap.hass

Conclusion

We have now installed Home Assistant through the package manager Snap and shown where to edit the configuration files.

In upcoming posts we’ll show you how you can – just as easily – install an configuration-editor that you can integrate with the web interface of Home Assistant, how to update DNS entries on a domain to make it available through a web address and how to secure your installation with SSL.

For anyone interested in the source code, want’s more detailed information about the release or needs to file a bug report, head over to the official repository.

If you have any questions, do not hesitate to leave a comment.

Until next time!

3 replies on “Home Assistant Snap”

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.