mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-19 07:17:14 +00:00
MQTT switch config to integration key (#22837)
This commit is contained in:
parent
fee352d834
commit
5a600d7ec0
@ -22,11 +22,30 @@ To enable this switch in your installation, add the following to your `configura
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Example configuration.yaml entry
|
# Example configuration.yaml entry
|
||||||
|
mqtt:
|
||||||
|
switch:
|
||||||
|
- command_topic: "home/bedroom/switch1/set"
|
||||||
|
```
|
||||||
|
|
||||||
|
<a id='new_format'></a>
|
||||||
|
|
||||||
|
{% details "Previous configuration format" %}
|
||||||
|
|
||||||
|
The configuration format of manual configured MQTT items has changed.
|
||||||
|
The old format that places configurations under the `switch` platform key
|
||||||
|
should no longer be used and is deprecated.
|
||||||
|
|
||||||
|
The above example shows the new and modern way,
|
||||||
|
this is the previous/old example:
|
||||||
|
|
||||||
|
```yaml
|
||||||
switch:
|
switch:
|
||||||
- platform: mqtt
|
- platform: mqtt
|
||||||
command_topic: "home/bedroom/switch1/set"
|
command_topic: "home/bedroom/switch1/set"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
{% enddetails %}
|
||||||
|
|
||||||
{% configuration %}
|
{% configuration %}
|
||||||
availability:
|
availability:
|
||||||
description: A list of MQTT topics subscribed to receive availability (online/offline) updates. Must not be used together with `availability_topic`.
|
description: A list of MQTT topics subscribed to receive availability (online/offline) updates. Must not be used together with `availability_topic`.
|
||||||
@ -225,21 +244,21 @@ The example below shows a full configuration for a switch.
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Example configuration.yaml entry
|
# Example configuration.yaml entry
|
||||||
switch:
|
mqtt:
|
||||||
- platform: mqtt
|
switch:
|
||||||
unique_id: bedroom_switch
|
- unique_id: bedroom_switch
|
||||||
name: "Bedroom Switch"
|
name: "Bedroom Switch"
|
||||||
state_topic: "home/bedroom/switch1"
|
state_topic: "home/bedroom/switch1"
|
||||||
command_topic: "home/bedroom/switch1/set"
|
command_topic: "home/bedroom/switch1/set"
|
||||||
availability:
|
availability:
|
||||||
- topic: "home/bedroom/switch1/available"
|
- topic: "home/bedroom/switch1/available"
|
||||||
payload_on: "ON"
|
payload_on: "ON"
|
||||||
payload_off: "OFF"
|
payload_off: "OFF"
|
||||||
state_on: "ON"
|
state_on: "ON"
|
||||||
state_off: "OFF"
|
state_off: "OFF"
|
||||||
optimistic: false
|
optimistic: false
|
||||||
qos: 0
|
qos: 0
|
||||||
retain: true
|
retain: true
|
||||||
```
|
```
|
||||||
|
|
||||||
For a check, you can use the command line tools `mosquitto_pub` shipped with `mosquitto` to send MQTT messages. This allows you to operate your switch manually:
|
For a check, you can use the command line tools `mosquitto_pub` shipped with `mosquitto` to send MQTT messages. This allows you to operate your switch manually:
|
||||||
@ -262,11 +281,11 @@ The configuration will look like the example below:
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Example configuration.yaml entry
|
# Example configuration.yaml entry
|
||||||
switch:
|
mqtt:
|
||||||
- platform: mqtt
|
switch:
|
||||||
name: bathroom
|
- name: bathroom
|
||||||
state_topic: "home/bathroom/gpio/13"
|
state_topic: "home/bathroom/gpio/13"
|
||||||
command_topic: "home/bathroom/gpio/13"
|
command_topic: "home/bathroom/gpio/13"
|
||||||
payload_on: "1"
|
payload_on: "1"
|
||||||
payload_off: "0"
|
payload_off: "0"
|
||||||
```
|
```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user