mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-19 07:17:14 +00:00
Added a more basic example as the template ones are tough to use as s… (#14223)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
parent
497cde4c08
commit
64e800447d
@ -71,8 +71,30 @@ service_name:
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic example which uses PUT method and payload encoded as form data
|
||||
|
||||
This example implements 2 REST commands to add service calls for the missing shuffle functionality of the iTunes integration.
|
||||
|
||||
```yaml
|
||||
rest_command:
|
||||
shuffle_on:
|
||||
url: "http://YOUR_ITUNES-API_SERVER_IP:8181/shuffle"
|
||||
method: put
|
||||
content_type: "application/x-www-form-urlencoded"
|
||||
payload: "mode=songs"
|
||||
shuffle_off:
|
||||
url: "http://YOUR_ITUNES-API_SERVER_IP:8181/shuffle"
|
||||
method: put
|
||||
content_type: "application/x-www-form-urlencoded"
|
||||
payload: "mode=off"
|
||||
```
|
||||
|
||||
### Using templates to change the payload based on entities
|
||||
|
||||
The commands can be dynamic, using templates to insert values of other entities. Service call support variables for doing things with templates.
|
||||
|
||||
In this example, uses [templates](/docs/configuration/templating/) for dynamic parameters.
|
||||
|
||||
{% raw %}
|
||||
```yaml
|
||||
# Example configuration.yaml entry
|
||||
@ -90,7 +112,7 @@ rest_command:
|
||||
```
|
||||
{% endraw %}
|
||||
|
||||
In this example entry, you can see some simple [templates](/docs/configuration/templating/) in use for dynamic parameters.
|
||||
### How to test your new REST command
|
||||
|
||||
Call the new service from [developer tools](/docs/tools/dev-tools/) in the sidebar with some `data` like:
|
||||
|
||||
@ -100,7 +122,7 @@ Call the new service from [developer tools](/docs/tools/dev-tools/) in the sideb
|
||||
"emoji":":plex:"
|
||||
}
|
||||
```
|
||||
Or in an example `automation`
|
||||
### Using a REST command as an action in an automation
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
|
Loading…
x
Reference in New Issue
Block a user