Update rest.md (#1656)

This commit is contained in:
Alex Bergsland 2023-01-30 16:37:48 +01:00 committed by GitHub
parent b6731d9749
commit a1956e5ee1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -568,6 +568,19 @@ curl -X POST -H "Authorization: Bearer ABCDEFGH" \
http://localhost:8123/api/states/sensor.kitchen_temperature
```
Sample `python` command using the [Requests](https://requests.readthedocs.io/en/master/) module:
```shell
from requests import post
url = "http://localhost:8123/api/states/sensor.kitchen_temperature"
headers = {"Authorization": "Bearer ABCDEFGH", "content-type": "application/json"}
data = {"state": "25", "attributes": {"unit_of_measurement": "°C"}}
response = post(url, headers=headers, json=data)
print(response.text)
```
</ApiEndpoint>
<ApiEndpoint path="/api/events/<event_type>" method="post">