MQTT switch config to integration key (#22837)

This commit is contained in:
Jan Bouwhuis 2022-05-23 14:31:58 +02:00 committed by GitHub
parent fee352d834
commit 5a600d7ec0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,11 +22,30 @@ To enable this switch in your installation, add the following to your `configura
```yaml
# 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:
- platform: mqtt
command_topic: "home/bedroom/switch1/set"
```
{% enddetails %}
{% configuration %}
availability:
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
# Example configuration.yaml entry
switch:
- platform: mqtt
unique_id: bedroom_switch
name: "Bedroom Switch"
state_topic: "home/bedroom/switch1"
command_topic: "home/bedroom/switch1/set"
availability:
- topic: "home/bedroom/switch1/available"
payload_on: "ON"
payload_off: "OFF"
state_on: "ON"
state_off: "OFF"
optimistic: false
qos: 0
retain: true
mqtt:
switch:
- unique_id: bedroom_switch
name: "Bedroom Switch"
state_topic: "home/bedroom/switch1"
command_topic: "home/bedroom/switch1/set"
availability:
- topic: "home/bedroom/switch1/available"
payload_on: "ON"
payload_off: "OFF"
state_on: "ON"
state_off: "OFF"
optimistic: false
qos: 0
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:
@ -262,11 +281,11 @@ The configuration will look like the example below:
```yaml
# Example configuration.yaml entry
switch:
- platform: mqtt
name: bathroom
state_topic: "home/bathroom/gpio/13"
command_topic: "home/bathroom/gpio/13"
payload_on: "1"
payload_off: "0"
mqtt:
switch:
- name: bathroom
state_topic: "home/bathroom/gpio/13"
command_topic: "home/bathroom/gpio/13"
payload_on: "1"
payload_off: "0"
```