From 444030d09fa7d505fbc2057868c070e2b5234df5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Fr=C3=BCh?= Date: Wed, 18 Apr 2018 19:35:03 +0200 Subject: [PATCH] Document the `headers` configuration parameter of the RESTful switch (#5196) * Document the `headers` configuration parameter of the RESTful switch * Fix indent --- source/_components/switch.rest.markdown | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/_components/switch.rest.markdown b/source/_components/switch.rest.markdown index db7b6e6e981..79388ff24b7 100644 --- a/source/_components/switch.rest.markdown +++ b/source/_components/switch.rest.markdown @@ -66,6 +66,10 @@ password: description: The password for accessing the REST endpoint. required: false type: string +headers: + description: The headers for the request. + required: false + type: list, string {% endconfiguration %}

@@ -82,13 +86,17 @@ This example shows a switch that uses a [template](/topics/templating/) to allow {"is_active": "true"} ``` +{% raw %} ```yaml switch: - platform: rest resource: http://IP_ADDRESS/led_endpoint body_on: '{"active": "true"}' body_off: '{"active": "false"}' - is_on_template: '{% raw %}{{value_json.is_active}}{% endraw %}' + is_on_template: '{{value_json.is_active}}' + headers: + Content-Type: application/json ``` +{% endraw %} `body_on` and `body_off` can also depend on the state of the system. For example, to enable a remote temperature sensor tracking on a radio thermostat, one has to send the current value of the remote temperature sensor. This can be achieved by using the template `{% raw %}'{"rem_temp":{{states.sensor.bedroom_temp.state}}}'{% endraw %}`.