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:
Sean Straus 2020-08-13 12:13:06 +02:00 committed by GitHub
parent 497cde4c08
commit 64e800447d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,8 +71,30 @@ service_name:
## Examples ## 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. 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 %} {% raw %}
```yaml ```yaml
# Example configuration.yaml entry # Example configuration.yaml entry
@ -90,7 +112,7 @@ rest_command:
``` ```
{% endraw %} {% 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: 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:" "emoji":":plex:"
} }
``` ```
Or in an example `automation` ### Using a REST command as an action in an automation
```yaml ```yaml
automation: automation: