Hello all,
after a quick read through the forum, I couldn’t find an example on how to update the config from GitHub (or similar) and restart Hass after. So here goes my fairly simple solution:
I’ve added this part to my config:
shell_command:
get_latest_config: bash /home/hass/.homeassistant/pullconfig.sh
script:
update_config:
sequence:
- service: shell_command.get_latest_config
- service: homeassistant.restart
This adds a button on the UI, which will execute a small bash script that pulls the latest commits from my Github account (after getting a repo set up and in sync) and call the service to restart Hass afterwards.
You can check the script here: https://github.com/Tommatheussen/Home-Assistant-Configuration/blob/master/bin/update_config_from_github.sh
What I still plan on doing:
- Don’t restart when there’s no updates
-> This could be done by either disabling the button (script condition) or possibly stop the execution ifgit pull
returns no changes - Possibly allow the option to disable restart altogether (switch)
The main reason for me doing this, is the fact that I don’t always have physical access to my home server (when I’m at my GF’s house, at work, somewhere else,…), which allows me to quickly edit my config inside my Github repo and restarting the home assistant without having to SSH into my server.
EDIT: Updated my repo a bit, I now got a Travis CI integration set up.
I protected my master branch, only allowing it to be updated from PR’s.
New commits to a PR branch trigger the Travis builds, which will install HA and run the check_config script.
This way I know for sure my config will work and not crash HA on restart.
Any comments, questions, suggestions welcome