From ee8ecdcb57b4eacef7eb713f3db5141c74c7896c Mon Sep 17 00:00:00 2001 From: Ron Schaeffer Date: Fri, 8 Mar 2019 13:40:23 +0000 Subject: [PATCH] Add Home Assistant RESTful command example (#194) More appropriate place in the docs for this PR https://github.com/home-assistant/home-assistant.io/pull/8780 --- docs/external_api_rest.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/external_api_rest.md b/docs/external_api_rest.md index 03a3962e..3e2bf12d 100644 --- a/docs/external_api_rest.md +++ b/docs/external_api_rest.md @@ -36,6 +36,17 @@ headers = { response = get(url, headers=headers) print(response.text) ``` +Another option is to use the Restful Command component https://www.home-assistant.io/components/rest_command/ in a Home Assistant automation or script. + +```yaml +turn_light_on: + url: http://localhost:8123/api/states/light.study_light + method: POST + headers: + authorization: 'Bearer ABCDEFGH' + content-type: 'application/json' + payload: '{"state":"on"}' +``` Successful calls will return status code 200 or 201. Other status codes that can return are: