diff --git a/source/_integrations/rest_command.markdown b/source/_integrations/rest_command.markdown index 29772718572..6105f75bc8d 100644 --- a/source/_integrations/rest_command.markdown +++ b/source/_integrations/rest_command.markdown @@ -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: