mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-23 01:06:52 +00:00
Improve MQTT template docs on handling null values (#38485)
This commit is contained in:
parent
a92290d6c6
commit
4144b06385
@ -1636,11 +1636,13 @@ Example value template:
|
||||
With given payload:
|
||||
|
||||
```json
|
||||
{ "state": "ON", "temperature": 21.902 }
|
||||
{ "state": "ON", "temperature": 21.902, "humidity": null }
|
||||
```
|
||||
|
||||
Template {% raw %}`{{ value_json.temperature | round(1) }}`{% endraw %} renders to `21.9`.
|
||||
|
||||
Template {% raw %}`{{ value_json.humidity }}`{% endraw %} renders to `None`.
|
||||
|
||||
{% endnote %}
|
||||
|
||||
#### Using command templates with MQTT
|
||||
|
@ -201,7 +201,7 @@ state_class:
|
||||
required: false
|
||||
type: string
|
||||
state_topic:
|
||||
description: The MQTT topic subscribed to receive sensor values. If `device_class`, `state_class`, `unit_of_measurement` or `suggested_display_precision` is set, and a numeric value is expected, an empty value `''` will be ignored and will not update the state, a `'null'` value will set the sensor to an `unknown` state. The `device_class` can be `null`.
|
||||
description: The MQTT topic subscribed to receive sensor values. If `device_class`, `state_class`, `unit_of_measurement` or `suggested_display_precision` is set, and a numeric value is expected, an empty value `''` will be ignored and will not update the state, a `'None'` value will set the sensor to an `unknown` state. If a `value_template` is used to parse a JSON payload, a `null` value in the JSON [will be rendered as]((/docs/configuration/templating/#using-value-templates-with-mqtt)) `'None'`. Note that the `device_class` can be `null`.
|
||||
required: true
|
||||
type: string
|
||||
unique_id:
|
||||
|
Loading…
x
Reference in New Issue
Block a user