mirror of
https://github.com/home-assistant/developers.home-assistant.git
synced 2025-07-10 02:46:29 +00:00
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
This commit is contained in:
parent
606b157561
commit
ee8ecdcb57
@ -36,6 +36,17 @@ headers = {
|
|||||||
response = get(url, headers=headers)
|
response = get(url, headers=headers)
|
||||||
print(response.text)
|
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:
|
Successful calls will return status code 200 or 201. Other status codes that can return are:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user