Added Python Example (#1143)

This commit is contained in:
Ashley Cawley 2022-01-24 12:55:36 +00:00 committed by GitHub
parent 938ee76929
commit ccf6b4f438
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -565,6 +565,21 @@ curl -X POST -H "Authorization: Bearer ABCDEFGH" \
http://localhost:8123/api/services/switch/turn_on http://localhost:8123/api/services/switch/turn_on
``` ```
Sample `python` command using the [Requests](https://requests.readthedocs.io/en/master/) module:
Turn the light on:
```shell
from requests import post
url = "http://localhost:8123/api/services/light/turn_on"
headers = {"Authorization": "Bearer ABCDEFGH"}
data = {"entity_id": "light.study_light"}
response = post(url, headers=headers, json=data)
print(response.text)
```
Send a MQTT message: Send a MQTT message:
```shell ```shell