mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-22 16:56:50 +00:00
Update light.mqtt.markdown (#20392)
This commit is contained in:
parent
dd7f40769e
commit
a2f5cb57a0
@ -825,15 +825,15 @@ availability_topic:
|
|||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
blue_template:
|
blue_template:
|
||||||
description: "[Template](/docs/configuration/templating/#processing-incoming-data) to extract blue color from the state payload value."
|
description: "[Template](/docs/configuration/templating/#processing-incoming-data) to extract blue color from the state payload value. Expected result of the template is an integer from 0-255 range."
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
brightness_template:
|
brightness_template:
|
||||||
description: "[Template](/docs/configuration/templating/#processing-incoming-data) to extract brightness from the state payload value."
|
description: "[Template](/docs/configuration/templating/#processing-incoming-data) to extract brightness from the state payload value. Expected result of the template is an integer from 0-255 range."
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
color_temp_template:
|
color_temp_template:
|
||||||
description: "[Template](/docs/configuration/templating/#processing-incoming-data) to extract color temperature from the state payload value."
|
description: "[Template](/docs/configuration/templating/#processing-incoming-data) to extract color temperature from the state payload value. Expected result of the template is an integer representing mired units."
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
command_off_template:
|
command_off_template:
|
||||||
@ -841,7 +841,7 @@ command_off_template:
|
|||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
command_on_template:
|
command_on_template:
|
||||||
description: "The [template](/docs/configuration/templating/#processing-incoming-data) for *on* state changes. Available variables: `state`, `brightness`, `red`, `green`, `blue`, `flash`, `transition` and `effect`."
|
description: "The [template](/docs/configuration/templating/#processing-incoming-data) for *on* state changes. Available variables: `state`, `brightness`, `color_temp`, `red`, `green`, `blue`, `flash`, `transition` and `effect`. Values `red`, `green`, `blue`, `brightness` are provided as integers from range 0-255. Value of `color_temp` is provided as integer representing mired units."
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
command_topic:
|
command_topic:
|
||||||
@ -949,7 +949,7 @@ qos:
|
|||||||
type: integer
|
type: integer
|
||||||
default: 0
|
default: 0
|
||||||
red_template:
|
red_template:
|
||||||
description: "[Template](/docs/configuration/templating/#processing-incoming-data) to extract red color from the state payload value."
|
description: "[Template](/docs/configuration/templating/#processing-incoming-data) to extract red color from the state payload value. Expected result of the template is an integer from 0-255 range."
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
schema:
|
schema:
|
||||||
@ -1044,6 +1044,48 @@ light:
|
|||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
|
||||||
|
### CCT light (brightnes and temperature)
|
||||||
|
|
||||||
|
This example comes from a configuration of Shelly RGBW Bulb working in White mode.
|
||||||
|
`max_mireds` and `min_mireds` set color temperature boundaries to 3000K - 6500K. Notice the same limits are applied in `command_on_template`, but in kelvin units this time. It's due to conversion from mired to kelvin which causes exceeding boundary values accepted by the device.
|
||||||
|
The code also ensures bi-directional conversion of brightness scale between 0-100 (required by the device) and 0-255 (required by Home Assistant).
|
||||||
|
Add the following to your `configuration.yaml` file:
|
||||||
|
|
||||||
|
{% raw %}
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# Example configuration.yaml entry
|
||||||
|
light:
|
||||||
|
- platform: mqtt
|
||||||
|
schema: template
|
||||||
|
name: "Bulb-white"
|
||||||
|
command_topic: "shellies/bulb/color/0/set"
|
||||||
|
state_topic: "shellies/bulb/color/0/status"
|
||||||
|
availability_topic: "shellies/bulb/online"
|
||||||
|
command_on_template: >
|
||||||
|
{"turn": "on", "mode": "white"
|
||||||
|
{%- if brightness is defined -%}
|
||||||
|
, "brightness": {{brightness | float | multiply(0.39215686) | round(0)}}
|
||||||
|
{%- endif -%}
|
||||||
|
{%- if color_temp is defined -%}
|
||||||
|
, "temp": {{ [[(1000000 / color_temp | float) | round(0), 3000] | max, 6500] | min }}
|
||||||
|
{%- endif -%}
|
||||||
|
}
|
||||||
|
command_off_template: '{"turn":"off", "mode": "white"}'
|
||||||
|
state_template: "{% if value_json.ison and value_json.mode == 'white' %}on{% else %}off{% endif %}"
|
||||||
|
brightness_template: "{{ value_json.brightness | float | multiply(2.55) | round(0) }}"
|
||||||
|
color_temp_template: "{{ (1000000 / value_json.temp | float) | round(0) }}"
|
||||||
|
payload_available: "true"
|
||||||
|
payload_not_available: "false"
|
||||||
|
max_mireds: 334
|
||||||
|
min_mireds: 153
|
||||||
|
qos: 1
|
||||||
|
retain: false
|
||||||
|
optimistic: false
|
||||||
|
```
|
||||||
|
|
||||||
|
{% endraw %}
|
||||||
|
|
||||||
### Template schema - No brightness or color support
|
### Template schema - No brightness or color support
|
||||||
|
|
||||||
If you don't want brightness, color or effect support, just omit the corresponding configuration sections.
|
If you don't want brightness, color or effect support, just omit the corresponding configuration sections.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user