mirror of
https://github.com/home-assistant/developers.home-assistant.git
synced 2025-07-29 12:16:30 +00:00
Compare commits
8 Commits
2702197f4e
...
5ad4cdde5a
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5ad4cdde5a | ||
![]() |
e360e8ba4a | ||
![]() |
c056fa60de | ||
![]() |
5d9b6a8a76 | ||
![]() |
058c2c7e3a | ||
![]() |
74c03c6382 | ||
![]() |
5e52cc2386 | ||
![]() |
c5f2209e4e |
@ -636,7 +636,7 @@ You can pass an optional JSON object to be used as `service_data`.
|
||||
}
|
||||
```
|
||||
|
||||
Returns a list of states that have changed while the service was being executed.
|
||||
By default, a call will return a list of states that have changed while the service was being executed.
|
||||
|
||||
```json
|
||||
[
|
||||
@ -655,6 +655,57 @@ Returns a list of states that have changed while the service was being executed.
|
||||
]
|
||||
```
|
||||
|
||||
:::tip
|
||||
The result will include any states that changed while the service was being executed, even if their change was the result of something else happening in the system.
|
||||
:::
|
||||
|
||||
If the service you're calling supports returning response data, you can retrieve it by adding `?return_response` to the URL. Your response will then contain both the list of changed entities and the service response data.
|
||||
|
||||
```json
|
||||
{
|
||||
"changed_states": [
|
||||
{
|
||||
"attributes": {},
|
||||
"entity_id": "sun.sun",
|
||||
"last_changed": "2024-04-22T20:45:54.418320-04:00",
|
||||
"state": "below_horizon"
|
||||
},
|
||||
{
|
||||
"attributes": {},
|
||||
"entity_id": "process.Dropbox",
|
||||
"last_changed": "2024-04-22T20:45:54.418320-04:00",
|
||||
"state": "on"
|
||||
}
|
||||
],
|
||||
"service_response": {
|
||||
"weather.new_york_forecast": {
|
||||
"forecast": [
|
||||
{
|
||||
"condition": "clear-night",
|
||||
"datetime": "2024-04-22T20:45:55.173725-04:00",
|
||||
"precipitation_probability": 0,
|
||||
"temperature": null,
|
||||
"templow": 6.0
|
||||
},
|
||||
{
|
||||
"condition": "rainy",
|
||||
"datetime": "2024-04-23T20:45:55.173756-04:00",
|
||||
"precipitation_probability": 60,
|
||||
"temperature": 16.0,
|
||||
"templow": 4.0
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
:::note
|
||||
Some services return no data, others optionally return response data, and some always return response data.
|
||||
|
||||
If you don't use `return_response` when calling a service that must return data, the API will return a 400. Similarly, you will receive a 400 if you use `return_response` when calling a service that doesn't return any data.
|
||||
:::
|
||||
|
||||
Sample `curl` commands:
|
||||
|
||||
Turn the light on:
|
||||
@ -692,9 +743,15 @@ curl \
|
||||
http://localhost:8123/api/services/mqtt/publish
|
||||
```
|
||||
|
||||
:::tip
|
||||
The result will include any states that changed while the service was being executed, even if their change was the result of something else happening in the system.
|
||||
:::
|
||||
Retrieve daily weather forecast information:
|
||||
|
||||
```shell
|
||||
curl \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer TOKEN" \
|
||||
-d '{"entity_id": "weather.forecast_home", "type": "daily"}' \
|
||||
http://localhost:8123/api/services/weather/get_forecasts?return_response
|
||||
```
|
||||
|
||||
</ApiEndpoint>
|
||||
|
||||
|
15
yarn.lock
15
yarn.lock
@ -8758,17 +8758,10 @@ send@0.19.0:
|
||||
range-parser "~1.2.1"
|
||||
statuses "2.0.1"
|
||||
|
||||
serialize-javascript@^6.0.0:
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8"
|
||||
integrity sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==
|
||||
dependencies:
|
||||
randombytes "^2.1.0"
|
||||
|
||||
serialize-javascript@^6.0.1:
|
||||
version "6.0.1"
|
||||
resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.1.tgz#b206efb27c3da0b0ab6b52f48d170b7996458e5c"
|
||||
integrity sha512-owoXEFjWRllis8/M1Q+Cw5k8ZH40e3zhp/ovX+Xr/vi1qj6QesbyXXViFbpNvWvPNAD62SutwEXavefrLJWj7w==
|
||||
serialize-javascript@^6.0.0, serialize-javascript@^6.0.1:
|
||||
version "6.0.2"
|
||||
resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.2.tgz#defa1e055c83bf6d59ea805d8da862254eb6a6c2"
|
||||
integrity sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==
|
||||
dependencies:
|
||||
randombytes "^2.1.0"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user