Add REST sensor/binary_sensor/switch templated headers & params (#20058)

This commit is contained in:
Chris Browet
2021-11-02 18:47:40 +01:00
committed by GitHub
parent 87963b7694
commit 813be23edf
4 changed files with 30 additions and 7 deletions

View File

@@ -124,7 +124,11 @@ password:
headers:
description: The headers for the requests.
required: false
type: [list, string]
type: [list, template]
params:
description: The query params for the requests.
required: false
type: [list, template]
{% endconfiguration %}
## Examples
@@ -153,7 +157,9 @@ binary_sensor:
### Accessing an HTTP authentication protected endpoint
The REST sensor supports HTTP authentication and customized headers.
The REST sensor supports HTTP authentication and template-enabled customized headers.
{% raw %}
```yaml
binary_sensor:
@@ -165,8 +171,12 @@ binary_sensor:
headers:
User-Agent: Home Assistant
Content-Type: application/json
X-Custom-Header: '{{ states("input_text.the_custom_header") }}'
```
{% endraw %}
The headers will contain all relevant details. This will also give
you the ability to access endpoints that are protected by tokens.