From 384b8b294eeb7e30866d0e581f245bad286060af Mon Sep 17 00:00:00 2001 From: Fredrik Erlandsson Date: Wed, 23 Oct 2019 20:19:11 +0200 Subject: [PATCH] Added documentation for resource_template for REST sensor (#10918) * Added documentation for resource_template * Fix jinja issues * minor changes * :pencil2: Tweak Co-authored-by: Franck Nijhof --- source/_integrations/rest.markdown | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/source/_integrations/rest.markdown b/source/_integrations/rest.markdown index 54b669718ce..1c91c94b0b3 100644 --- a/source/_integrations/rest.markdown +++ b/source/_integrations/rest.markdown @@ -30,12 +30,28 @@ sensor: payload: '{ "device" : "heater" }' ``` +or a template based request: + +{% raw %} + +```yaml +# Example configuration.yaml entry +sensor: + - platform: rest + resource_template: http://IP_ADDRESS/{{ now().strftime('%Y-%m-%d') }} +``` + +{% endraw %} + {% configuration %} resource: description: The resource or endpoint that contains the value. required: true type: string - default: string +resource_template: + description: The resource or endpoint that contains the value with template support. + required: true + type: template method: description: The method of the request. Either `POST` or `GET`. required: false @@ -103,6 +119,12 @@ force_update: Make sure that the URL exactly matches your endpoint or resource. +
+ +Use either `resource` or `resource_template`. + +
+ `curl` can help you identify the variable you want to display in your Home Assistant frontend. The example below shows the JSON response of a device that is running with [aREST](https://arest.io/). ```bash