Categories
Home Automation

Home Assistant Configurator

This is a continuation of the already written post Home Assistant Snap, and it’s expected that you already have basic knowledge on the Snap Package Manager. Feel free to have a read-through, before continuing with this article.

In this article will we install the formally known hass-configurator, as a companion app to Home Assistant Snap. The configurator is a web-based editor, that will let you edit the configuration files within Home Assistant Snap through the web brower.

If you want a full detail list of the editor, head over to the github-repository of the project.

We will go through a basic configuration and integrate the editor within the UI of Home Assistant Snap.

The configurator must run on the same computer as Home Assistant Snap, as it’s using plugs/slots to read the configuration files, within the confined environment.

Installation

To install home-assistant-configurator execute the command

sudo snap install home-assistant-configurator

When the installation process is finished, you should be able to find the configurator at the address: http://home-assistant-computer-ip:3218/. If you don’t know or remember the IP-address of the computer running Home Assistant Snap, see the installation section of the Home Assistant Snap-article.

Now make sure that the connecting plug/slot between home-assistant-snap and home-assistant-configurator was successfully auto-connected after installation.

snap connections | grep "content\[configurations\]"

And look for an identical line as this

content[configurations] home-assistant-configurator:configurations home-assistant-snap:configurations -

If you don’t see this connection, run the following

sudo snap connect home-assistant-configurator:configurations home-assistant-snap:configurations

If nothing is returned, the connection is successful. And you can verify this by running the above snap connection-command again.

Configuration

With Home Assistant Configurator we’ll introduce you to a different way of configuring a snap. We’re going to use the snap set and get commands, and not edit the settings.conf-file as the official documentation tells us to – as data added directly to the file will only be temporary until next restart.

Familiarize your self with the available settings

sudo snap get home-assistant-configurator -d

and compare the output you get with the following content of the settings.conf-file:

{
    "LISTENIP": "0.0.0.0",
    "PORT": 3218,
    "GIT": false,
    "BASEPATH": null,
    "ENFORCE_BASEPATH": false,
    "SSL_CERTIFICATE": null,
    "SSL_KEY": null,
    "IGNORE_SSL": false,
    "HASS_API": "http://127.0.0.1:8123/api/",
    "HASS_WS_API": null,
    "HASS_API_PASSWORD": null,
    "USERNAME": null,
    "PASSWORD": null,
    "ALLOWED_NETWORKS": [],
    "ALLOWED_DOMAINS": [],
    "BANNED_IPS": [],
    "BANLIMIT": 0,
    "IGNORE_PATTERN": [],
    "DIRSFIRST": false,
    "SESAME": null,
    "SESAME_TOTP_SECRET": null,
    "VERIFY_HOSTNAME": false,
    "ENV_PREFIX": "HC_",
    "NOTIFY_SERVICE": "persistent_notification.create"
}

The first thing we want to do is to set the BASEPATH, if it’s not set already, to /var/snap/home-assistant-configurator/common/configurations. This is where Home Assistant Snap’s configurations now is «plugged» at.

Set the path with:

snap set home-assistant-configurator server.basepath.dir=/var/snap/home-assistant-configurator/common/configurations

Note we’re using the SNAP_COMMON-directory now, and not SNAP_DATA as we did for Home Assistant Snap, and if the common path is different on your system – do as described in that article.

For simplicity, as you don’t need to edit anything outside of this path, set the ENFORCE_BASEPATH to True:

snap set home-assistant-configurator set server.basepath.enforce=True

Securing the installation

Next generate as password to secure (well, secure-ish, until we add an SSL-certificate..) the installation:

echo -n "TestPass" | sha256sum

And set the output as a password for the configurator, along with an username

sudo snap set home-assistant-configurator server.login.password="{sha256}OUTPUT"
sudo snap set home-assistant-configurator server.login.username=test
Refresh the website of Home Assistant Configurator and you will now be prompted to give a username and a password.

Integrate with Home Assistant Snap

Login to Home Assistant web UI and go to your profile, scroll down to «Long-Lived Access Tokens» and press «create token». Give it a descriptive name, such as «Home Assistant Configurator» and press OK.

Copy the given string and make sure you have it until it’s set withing home-assistant-configurator.

And set it it to Home Assistant Configurator:

snap set home-assistant-configurator server.hass.api.password="COPIED STRING"

Further you have to set the server.hass.api.url (make sure that it ends with /api/) and server.hass.api.ws-url, which I’m confident that you’ll understand how to do by now.

Refreshing Home Assistant Configurator should now let you select entities, conditions, services etc from its dropdown lists.

Additional settings you should use

server.ban.limit=5
server.dir.first=True
server.listen.ip=<actual IP>

You can read the description of all the settings at the official github-repository.

Configuring Home Assistant Snap

Yay! We can now do this from the UI of the Configurator. Make sure you have refreshed the page after the last settings was set.

Now browse by pressing the folder icon in the upper left corner, and select the configuration.yaml-file.

Add the following to the file

panel_iframe:
  configurator:
    title: Configurator
    icon: mdi:wrench
    url: http://<actual ip>:3218

Hit the red-glowing floppy disk in the upper right corner, then press the cog icon to the right of it and select «Restart HASS».

Now go into the web UI of Home Assistant Snap and you should see the configurator in the left menu panel.

Conclusion

We have now installed and configured Home Assistant Configurator, and integrated it with Home Assistant Snap.

In upcoming posts we’ll show you how you can – just as easily – update DNS entries on a domain to make Home Assistant 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!