From a1956e5ee12e317de4049c9d52bc3ef8773a33aa Mon Sep 17 00:00:00 2001 From: Alex Bergsland Date: Mon, 30 Jan 2023 16:37:48 +0100 Subject: [PATCH] Update rest.md (#1656) --- docs/api/rest.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/api/rest.md b/docs/api/rest.md index 85ee77a6..fc9c5b4a 100644 --- a/docs/api/rest.md +++ b/docs/api/rest.md @@ -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) +``` +