Improve explanation of state_value_template and add example (#31928)

* Improve explanation of state_value_template and add example

* Fix syntax problems in documentation

* tweaks, in an attempt to fix the build

* Update source/_integrations/light.mqtt.markdown

* Update source/_integrations/light.mqtt.markdown

---------

Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>
This commit is contained in:
Christian Gahlert 2024-03-19 09:10:10 +01:00 committed by GitHub
parent 8b67075c83
commit 8088152e50
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -363,7 +363,7 @@ state_topic:
required: false
type: string
state_value_template:
description: "Defines a [template](/docs/configuration/templating/#using-templates-with-the-mqtt-integration) to extract the state value. The template should match the payload `on` and `off` values, so if your light uses `power on` to turn on, your `state_value_template` string should return `power on` when the switch is on. For example if the message is just `on`, your `state_value_template` should be `power {{ value }}`."
description: "Defines a [template](/docs/configuration/templating/#using-templates-with-the-mqtt-integration) to extract the state value. The template should return the `payload_on` and `payload_off` values, so if your light uses `power on` to turn on, your `state_value_template` string should return `power on` when the switch is on. For example, if the message is just `on`, your `state_value_template` should be `power {{ value }}`. When your `payload_on = 27`, `payload_off = 'off'`, then this template might be `'off' if value_json.my_custom_brightness_field <= 0 else 27`."
required: false
type: template
unique_id: