mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-07 17:36:50 +00:00
Update for templating support
This commit is contained in:
parent
159bc21e6b
commit
a83768bb7a
@ -25,6 +25,7 @@ binary_sensor:
|
||||
qos: 0
|
||||
payload_on: "ON"
|
||||
payload_of: "OFF"
|
||||
value_template: '{% raw %}{{ template }}{% endraw %}'
|
||||
```
|
||||
|
||||
Configuration variables:
|
||||
@ -34,7 +35,7 @@ Configuration variables:
|
||||
- **qos** (*Optional*): The maximum QoS level of the state topic. Default is 0.
|
||||
- **payload_on** (*Optional*): The payload that represents on state. Default is "ON".
|
||||
- **payload_off** (*Optional*): The payload that represents state. Default is "OFF".
|
||||
|
||||
- **value_template** (*Optional*): Defines a [template](/getting-started/templating/) to extract a value from the payload.
|
||||
|
||||
For a quick check you can use the commandline tools shipped with `mosquitto` to send MQTT messages. Set the state of your sensor manually:
|
||||
|
||||
|
@ -22,8 +22,7 @@ sensor:
|
||||
command: SENSOR_COMMAND
|
||||
name: Command sensor
|
||||
unit_of_measurement: "°C"
|
||||
correction_factor: 0.4921
|
||||
decimal_places: 0
|
||||
value_template: '{% raw %}{{ template }}{% endraw %}'
|
||||
```
|
||||
|
||||
Configuration variables:
|
||||
@ -31,8 +30,7 @@ Configuration variables:
|
||||
- **command** (*Required*): The action to take to get the value.
|
||||
- **name** (*Optional*): Name of the command sensor.
|
||||
- **unit_of_measurement** (*Optional*): Defines the unit of measurement of the sensor, if any.
|
||||
- **correction_factor** (*Optional*): A float value to do some basic calculations.
|
||||
- **decimal_places** (*Optional*): Number of decimal places of the value.
|
||||
- **value_template** (*Optional*): Defines a [template](/getting-started/templating/) to extract a value from the payload.
|
||||
|
||||
## {% linkable_title Examples %}
|
||||
|
||||
|
@ -24,7 +24,7 @@ sensor:
|
||||
name: "MQTT Sensor"
|
||||
qos: 0
|
||||
unit_of_measurement: "°C"
|
||||
value_template: '{{ value_json.value }}'
|
||||
value_template: '{% raw %}{{ template }}{% endraw %}'
|
||||
```
|
||||
|
||||
Configuration variables:
|
||||
@ -33,7 +33,7 @@ Configuration variables:
|
||||
- **name** (*Optional*): The name of the sensor. Default is 'MQTT Sensor'.
|
||||
- **qos** (*Optional*): The maximum QoS level of the state topic. Default is 0.
|
||||
- **unit_of_measurement** (*Optional*): Defines the units of measurement of the sensor, if any.
|
||||
- **value_template** (*Optional*): Defines a template to extract a value from the payload.
|
||||
- **value_template** (*Optional*): Defines a [template](/getting-started/templating/) to extract a value from the payload.
|
||||
|
||||
## {% linkable_title Examples %}
|
||||
|
||||
|
@ -36,24 +36,20 @@ sensor:
|
||||
platform: rest
|
||||
resource: http://IP_ADDRESS/ENDPOINT
|
||||
method: POST
|
||||
variable: 'temperature' or ['Temperatures', 0, 'CurrentReading']
|
||||
value_template: '{% raw %}{{ template }}{% endraw %}'
|
||||
payload: '{ "device" : "heater" }'
|
||||
name: REST POST sensor
|
||||
unit_of_measurement: "°C"
|
||||
correction_factor: 0.0001
|
||||
decimal_places: 0
|
||||
```
|
||||
|
||||
Configuration variables:
|
||||
|
||||
- **resource** (*Required*): The resource or endpoint that contains the value.
|
||||
- **method** (*Optional*): The method of the request. Default is GET.
|
||||
- **variable** (*Optional*): Defines the variable or a list of element for complex responses to extract, if any.
|
||||
- **value_template** (*Optional*): Defines a [template](/getting-started/templating/) to extract a value from the payload.
|
||||
- **payload** (*Optional*): The payload to send with a POST request. Usualy formed as a dictionary-
|
||||
- **name** (*Optional*): Name of the REST sensor.
|
||||
- **unit_of_measurement** (*Optional*): Defines the unit of measurement of the sensor, if any.
|
||||
- **correction_factor** (*Optional*): A float value to do some basic calculations.
|
||||
- **decimal_places** (*Optional*): Number of decimal places of the value.
|
||||
|
||||
<p class='note warning'>
|
||||
Make sure that the URL matches exactly your endpoint or resource.
|
||||
|
Loading…
x
Reference in New Issue
Block a user