You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/_components/light.mqtt_template.markdown
+13-4Lines changed: 13 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ ha_release: 0.33
17
17
The `mqtt_template` light platform lets you control a MQTT-enabled light that receive commands on a command topic and optionally sends status update on a state topic.
18
18
It is format-agnostic so you can use any data format you want (i.e. string, JSON), just configure it with templating.
19
19
20
-
This platform supports on/off, brightness, RGB colors, transitions, and short/long flashing.
20
+
This platform supports on/off, brightness, RGB colors, transitions, short/long flashing and effects.
21
21
22
22
In an ideal scenario, the MQTT device will have a state topic to publish state changes. If these messages are published with the RETAIN flag, the MQTT light will receive an instant state update after subscription and will start with the correct state. Otherwise, the initial state of the light will be off.
23
23
@@ -37,15 +37,17 @@ light:
37
37
Configuration variables:
38
38
39
39
- **name** (*Optional*): The name of the light. Default is "MQTT Template Light."
40
+
- **effect_list** (*Optional*): List of possible effects.
40
41
- **command_topic** (*Required*): The MQTT topic to publish commands to change the light's state.
41
42
- **state_topic** (*Optional*): The MQTT topic subscribed to receive state updates.
42
-
- **command_on_template** (*Required*): The template for *on* state changes. Available variables: `state`, `brightness`, `red`, `green`, `blue`, `flash`and `transition`.
43
+
- **command_on_template** (*Required*): The template for *on* state changes. Available variables: `state`, `brightness`, `red`, `green`, `blue`, `flash`, `transition` and `effect`.
43
44
- **command_off_template** (*Required*): The template for *off* state changes. Available variables: `state` and `transition`.
44
45
- **state_template** (*Optional*): Template to extract state from the state payload value.
45
46
- **brightness_template** (*Optional*): Template to extract brightness from the state payload value.
46
47
- **red_template** (*Optional*): Template to extract red color from the state payload value.
47
48
- **green_template** (*Optional*): Template to extract green color from the state payload value.
48
49
- **blue_template** (*Optional*): Template to extract blue color from the state payload value.
50
+
- **effect_template** (*Optional*): Template to extract effect from the state payload value.
49
51
- **optimistic** (*Optional*): Flag that defines if the light works in optimistic mode. Default is true if no state topic or state template is defined, else false.
50
52
- **qos** (*Optional*): The maximum QoS level of the state topic. Default is 0 and will also be used to publishing messages.
51
53
@@ -78,12 +80,15 @@ light:
78
80
79
81
### {% linkable_title JSON payload %}
80
82
81
-
For a JSON payload with the format `{"state": "on", "brightness": 255, "color": [255, 255, 255]}`, add the following to your `configuration.yaml` file:
83
+
For a JSON payload with the format `{"state": "on", "brightness": 255, "color": [255, 255, 255], "effect": "rainbow"}`, add the following to your `configuration.yaml` file:
82
84
83
85
```yaml
84
86
# Example configuration.yaml entry
85
87
light:
86
88
- platform: mqtt_template
89
+
effect_list:
90
+
- rainbow
91
+
- colorloop
87
92
command_topic: "home/rgb1/set"
88
93
state_topic: "home/rgb1/status"
89
94
command_on_template: >{% raw %}
@@ -94,16 +99,20 @@ light:
94
99
{%- if red is defined and green is defined and blue is defined -%}
95
100
, "color": [{{ red }}, {{ green }}, {{ blue }}]
96
101
{%- endif -%}
102
+
{%- if effect is defined -%}
103
+
, "effect": "{{ effect }}"
104
+
{%- endif -%}
97
105
}{% endraw %}
98
106
command_off_template: '{"state": "off"}'
99
107
state_template: '{% raw %}{{ value_json.state }}{% endraw %}'
100
108
brightness_template: '{% raw %}{{ value_json.brightness }}{% endraw %}'
101
109
red_template: '{% raw %}{{ value_json.color[0] }}{% endraw %}'
102
110
green_template: '{% raw %}{{ value_json.color[1] }}{% endraw %}'
103
111
blue_template: '{% raw %}{{ value_json.color[2] }}{% endraw %}'
112
+
effect_template: '{% raw %}{{ value_json.effect }}{% endraw %}'
104
113
```
105
114
106
115
### {% linkable_title No brightness or color support %}
107
116
108
-
If you don't want brightnessor color support, just omit the corresponding configuration sections.
117
+
If you don't want brightness, color or effect support, just omit the corresponding configuration sections.
0 commit comments