I’m pretty new to docker, and hass so PLEASE make suggestions (pull requests would be amazing!) Hopefully everyone can learn something!
TLDR
I can now modify my files on any machine with git, commit the changes and if travis passes the build my HASS instance will update it’s config and restart to re-load the config.
The setup
I like to run everything in docker - so HASS is in docker running on Ubuntu.
Implementation
Firstly get your config into git, and configure travis to automatically test your builds - the guide is really good, and I have nothing to add to it!
After your config is backed up, and travis is configured it’s time to use webhooks to get your HASS to update git, and reboot the docker image automatically (if the tests pass)
I’ve created a simple docker image that can validate a travis webhook and call a script - you can find the image on dockerhub. This image is responsible for calling the script that will update your local config when the build tests all pass.
Note the script runs in the docker container… so this is where I think improvements can probably be made.
My script creates a text file called “update-hass.txt” in the scripts volume the docker container uses.
I then have the following script that checks to see if the file exists. If it does I do a pull from git, then I reset my HASS docker container
This script simply runs as a cron job every minute.
Finally you need to update .travis.yml to call the notification handler:
Potential improvements
I’m sure you can watch for files being creating in linux, but I’m not too worried about that - also my shares are mounted from a network share and I’ve had lots of issues with file watches working with this setup.
Currently if I modify a config file, then commit it to git it causes travis to build, then the webhook call makes my HASS reboot. This is totally pointless as nothing has changed. I’m sure there will be a way to modify the autoupdate.sh script to only restart docker if something changes.