Home Assistant, Git Plugin and Web Hooks
As of version 0.80 of Home assistant, there is a new web hook trigger for automations. I already setup the Git Pull add-on to automatically pull the latest config from my gitlab. However, when I’m building stuff, my workflow goes like this:
- Add + test new gadgets to home assistant on my laptop
- Commit + Push to my repo
- Go to Home Assistant
- Trigger a restart of the git pull add-on
The git pull add-on already polls the git server every 5 minutes to see if anything new has been pushed, but I’m much too impatient for this. Step 4 above will trigger an immediate check of the git server.
First, the automation. The webhook ID can be any string, any request to https://hass.example.com/api/webhook/thatstring will trigger a refresh, so I chose something hard to guess. Here is the automation:
- service: hassio.addon_restart
The action will restart the “core_git_pull” addon, which triggers a git pull.
The final step is to add the URL with the secret as a webhook integration into gitlab (or github)
Now, any push to master will trigger home assistant to immediately pull!