MQTT binary_sensor config to integration key (#22817)

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

View File

@ -25,11 +25,30 @@ add the following to your `configuration.yaml` file:
```yaml ```yaml
# Example configuration.yaml entry # Example configuration.yaml entry
mqtt:
binary_sensor:
- state_topic: "home-assistant/window/contact"
```
<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 `binary_sensor` 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
binary_sensor: binary_sensor:
- platform: mqtt - platform: mqtt
state_topic: "home-assistant/window/contact" state_topic: "home-assistant/window/contact"
``` ```
{% 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`.
@ -223,9 +242,9 @@ The example below shows a full configuration for a binary sensor:
```yaml ```yaml
# Example configuration.yaml entry # Example configuration.yaml entry
binary_sensor: mqtt:
- platform: mqtt binary_sensor:
name: "Window Contact Sensor" - name: "Window Contact Sensor"
state_topic: "home-assistant/window/contact" state_topic: "home-assistant/window/contact"
payload_on: "ON" payload_on: "ON"
availability: availability:
@ -245,9 +264,9 @@ binary_sensor:
```yaml ```yaml
# Example configuration.yaml entry # Example configuration.yaml entry
binary_sensor: mqtt:
- platform: mqtt binary_sensor:
state_topic: "lab_button/cmnd/POWER" - state_topic: "lab_button/cmnd/POWER"
value_template: "{%if is_state(entity_id,\"on\")-%}OFF{%-else-%}ON{%-endif%}" value_template: "{%if is_state(entity_id,\"on\")-%}OFF{%-else-%}ON{%-endif%}"
``` ```
@ -269,9 +288,9 @@ The configuration will look like the example below:
```yaml ```yaml
# Example configuration.yaml entry # Example configuration.yaml entry
binary_sensor: mqtt:
- platform: mqtt binary_sensor:
name: Bathroom - name: Bathroom
state_topic: "home/bathroom/switch/button" state_topic: "home/bathroom/switch/button"
payload_on: "1" payload_on: "1"
payload_off: "0" payload_off: "0"