mirror of
https://github.com/home-assistant/developers.home-assistant.git
synced 2025-07-15 21:36:31 +00:00
Added Python Example (#1143)
This commit is contained in:
parent
938ee76929
commit
ccf6b4f438
@ -565,6 +565,21 @@ curl -X POST -H "Authorization: Bearer ABCDEFGH" \
|
||||
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:
|
||||
|
||||
```shell
|
||||
|
Loading…
x
Reference in New Issue
Block a user