jcallaghan / home-assistant-config

My Home Assistant configuration & documentation.
https://www.jcallaghan.com/
MIT License
175 stars 8 forks source link

GitHub rest_commands #103

Closed jcallaghan closed 4 years ago

jcallaghan commented 4 years ago

GitHub API

Rest command

Using the rest_command integrated I created the following service.

rest_command:
  new_github_issue_replace_battery:
    url: https://api.github.com/repos/jcallaghan/home-assistant-config/issues
    method: POST
    headers:
      Authorization: !secret github_token
    payload: '{"title":"{{ title }}","body":"{{ message }}","labels":["battery","task: maintenance"]}'

secrets.yaml

Don't forget to add Bearer in front of your access token in your secrets file.

github_token: "Bearer 000000000000000"

Automation/service

Service name: rest_command.new_github_issue_replace_battery Service data:

{ 
  "title": "Service test",
  "message": "Create via service call in Home Assistant"
}

image

Reference

Originally posted by @jcallaghan in https://github.com/jcallaghan/home-assistant-config/issues/60#issuecomment-642597169