No description
Find a file
2017-01-30 01:38:22 +01:00
dev Create README.md 2017-01-30 01:05:26 +01:00
changelog.txt Added optional authentication and insert-highlighting 2017-01-29 22:11:33 +00:00
configurator.py Set focus to editor after inserting element 2017-01-29 23:48:21 +00:00
hass-poc-configurator.png Add files via upload 2017-01-29 17:11:02 +01:00
hass-poc-configurator.systemd Added systemd template 2017-01-29 20:45:58 +00:00
LICENSE.txt Added license 2017-01-25 23:26:02 +00:00
README.md Mentioned BASEPATH requirement for systemd 2017-01-30 01:38:22 +01:00

hass-poc-configurator

###Proof of concept configuration UI for Home Assistant

Since there currently is no nice way to edit the yaml-files HASS is using through the HASS frontend, I've code-snippet-patchworked this small webapp that lists yaml (and conf) files in the directory it's being executed in in a nice little jsTree. By clicking on an element, the file is loaded into an embedded Ace editor, which has syntax hightlighting for yaml. When done editing the file, click the save-button and you're done. Dialogs are being displayed using the SimpleModal plug-in for jQuery.

###Feature list:

  • Web-Based editor to modify your yaml (and conf) files with syntax highlighting
  • Lists of available triggers, events, entities, conditions and services. Selected element gets inserted into the editor at the last cursor position.
  • Toggle displaying of whitespace
  • Fold / Unfold the content for better overview
  • Highlight selected word to see where else it's being used
  • Restart HASS directly with the click of a button (API-password required)
  • Direct links to HASS documentation
  • SSL support (configuration required)

####Screenshot of the configurator embedded into HASS: Screenshot

This isn't designed to be pretty or complete in any way. It is a workaround for people tired of SSH-ing into their machines. And maybe there's even someone who takes this as a reference and builds something like this directly into HASS, which would be totally awesome! If there's anything you want to have differently, feel free to fork and enhance.

###Installation There are no dependencies on Python modules that are not part of the standard library. And all the fancy JavaScript libraries are loaded from CDN (which means this doesn't work when you're offline).

  • Copy configurator.py to your HASS configuration directory (e.g /home/hass/.homeassistant)
  • Make it executable (sudo chmod 755 configurator.py)
  • Execute it (sudo ./configurator.py)
  • To terminate the process do the usual CTRL+C, maybe once or twice

###Configuration Near the top of the py-file you'll find some global variables you can change to customize the configurator a little bit. If you're unfamiliar with Python: when setting variables of the type string, you have to write that within quotation marks.

####LISTENIP (string) The IP the service is listening on. By default it's binding to 0.0.0.0, which is every interface on the system. ####LISTENPORT (integer) The port the service is listening on. By default it's using 3218, but you can change this if you need to. ####BASEPATH (string) On Linux systems it is possible to place configurator.py somewhere else. Set the BASEPATH to something like "/home/hass/.homeassistant", and no matter where you're running the configurator from, it will chroot into that directory and start serving files from there. ####SSL_CERTIFICATE / SSL_KEY (string) If you're using SSL, set the paths to your SSL files here. This is similar to the SSL setup you can do in HASS. ####HASS_API (string) The configurator fetches some data from your running HASS instance. If the API isn't available through the default URL, modify this variable to fix this. ####HASS_API_PASSWORD (string) If you plan on using the restart button, you have to set your API password. Calling the restart service of HASS is prohibited without authentication. ####CREDENTIALS (string) Set credentials in the form of "username:password" if authentication should be required for access.

###Embedding into HASS HASS has the panel_iframe component. With this it is possible to embed the configurator directly into HASS, allowing you to modify your configuration through the HASS frontend.
An example configuration would look like this:

panel_iframe:
  configurator:
    title: Configurator
    icon: mdi:wrench
    url: http://123.123.132.132:3218

IMPORTANT: Do NOT setup port forwarding to the configurator. There are no authentication mechanisms, and a port forwarding would expose your configuration to the whole world!

###Keeping the configurator running Since the configurator script on its own is no service, you'll have to take some extra steps to keep it running. Here are three options (for Linux), but there are more, depending on your usecase.

  1. Simple fork into the background with the command nohup sudo ./configurator.py &
  2. If your system is using systemd (that's usually what you'll find on a Raspberry PI), there's a template file you can use and then apply the same process to integrate it as mentioned in the HASS documentation. If you use this method you have to set the BASEPATH variable according to your environment.
  3. A tool called screen. If it's not already installed on your system, you can do sudo apt-get install screen to get it. When it's installed, start a screen session by executing screen. Then navigate to your HASS directory and start the configurator like described above. Put the screen session into the background by pressing CTRL+A and then CTRL+D. To resume the screen session, log in to your machine and execute screen -r.