Home Assistant, Git Plugin and Web Hooks

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:

  1. Add + test new gadgets to home assistant on my laptop
  2. Commit + Push to my repo
  3. Go to Home Assistant
  4. 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:

automation:
  trigger:
    platform: webhook
    webhook_id: some-uuid-here
  action:
    - service: hassio.addon_restart
      data:
        addon: core_git_pull

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!