mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-22 16:56:50 +00:00
Fix default values in REST switch (#4922)
* Fix default values in REST switch According to https://github.com/home-assistant/home-assistant/blob/master/homeassistant/components/switch/rest.py * Resource does not have any default value. * Method is set in lowercase "post" * Default name is not "REST Binary Switch" but "REST Switch" * Default body_on is "ON" not true * Default body_off is "OFF" not false * ✏️ Tweaks
This commit is contained in:
parent
9165380172
commit
6e1fe76243
@ -13,7 +13,6 @@ ha_release: 0.7.6
|
|||||||
ha_iot_class: "Local Polling"
|
ha_iot_class: "Local Polling"
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
||||||
The `rest` switch platform allows you to control a given endpoint that supports a [RESTful API](https://en.wikipedia.org/wiki/Representational_state_transfer). The switch can get the state via GET and set the state via POST on a given REST resource.
|
The `rest` switch platform allows you to control a given endpoint that supports a [RESTful API](https://en.wikipedia.org/wiki/Representational_state_transfer). The switch can get the state via GET and set the state via POST on a given REST resource.
|
||||||
|
|
||||||
To enable this switch, add the following lines to your `configuration.yaml` file:
|
To enable this switch, add the following lines to your `configuration.yaml` file:
|
||||||
@ -30,17 +29,16 @@ resource:
|
|||||||
description: The resource or endpoint that contains the value.
|
description: The resource or endpoint that contains the value.
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
default: string
|
|
||||||
method:
|
method:
|
||||||
description: "The method of the request. Supported `post` or `put`."
|
description: "The method of the request. Supported `post` or `put`."
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
default: POST
|
default: post
|
||||||
name:
|
name:
|
||||||
description: Name of the REST Switch.
|
description: Name of the REST Switch.
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
default: REST Binary Switch
|
default: REST Switch
|
||||||
timeout:
|
timeout:
|
||||||
description: Timeout for the request.
|
description: Timeout for the request.
|
||||||
required: false
|
required: false
|
||||||
@ -78,13 +76,12 @@ Make sure that the URL matches exactly your endpoint or resource.
|
|||||||
|
|
||||||
### {% linkable_title Switch with templated value %}
|
### {% linkable_title Switch with templated value %}
|
||||||
|
|
||||||
This example shows a switch that uses a [template](/topics/templating/) to allow Home Assistant to determine its state. In this example the REST endpoint returns this JSON response with true indicating the switch is on.
|
This example shows a switch that uses a [template](/topics/templating/) to allow Home Assistant to determine its state. In this example, the REST endpoint returns this JSON response with true indicating the switch is on.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{"is_active": "true"}
|
{"is_active": "true"}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
switch:
|
switch:
|
||||||
- platform: rest
|
- platform: rest
|
||||||
@ -95,4 +92,3 @@ switch:
|
|||||||
```
|
```
|
||||||
|
|
||||||
`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 %}`.
|
`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 %}`.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user