Skip to content

Commit 3f6f8c4

Browse files
DarkFoxfabaff
authored andcommitted
Fix ON/OFF being interpreted in binary_sensor.mqtt (home-assistant#5042)
* Fix ON/OFF being interpreted in binary_sensor.mqtt YAML interprets `ON` and `OFF` to `true` and `false`. This causes the site to show that instead of the actual default payloads. * Add header
1 parent 6b61e22 commit 3f6f8c4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

source/_components/binary_sensor.mqtt.markdown

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ The `mqtt` binary sensor platform uses an MQTT message payload to set the binary
1717

1818
The binary sensor state will be updated only after a new message is published on `state_topic` matching `payload_on` or `payload_off`. If these messages are published with the `retain` flag set, the binary sensor will receive an instant state update after subscription and Home Assistant will display the correct state on startup. Otherwise, the initial state displayed in Home Assistant will be `unknown`.
1919

20+
## {% linkable_title Configuration %}
21+
2022
The `mqtt` binary sensor platform optionally supports an `availability_topic` to receive online and offline messages (birth and LWT messages) from the MQTT device. During normal operation, if the MQTT cover device goes offline (i.e., publishes `payload_not_available` to `availability_topic`), Home Assistant will display the binary sensor as `unavailable`. If these messages are published with the `retain` flag set, the binary sensor will receive an instant update after subscription and Home Assistant will display the correct availability state of the binary sensor when Home Assistant starts up. If the `retain` flag is not set, Home Assistant will display the binary sensor as `unavailable` when Home Assistant starts up. If no `availability_topic` is defined, Home Assistant will consider the MQTT device to be available.
2123

2224
To use an MQTT binary sensor in your installation, add the following to your `configuration.yaml` file:
@@ -42,12 +44,12 @@ payload_on:
4244
description: The payload that represents the on state.
4345
required: false
4446
type: string
45-
default: ON
47+
default: "ON"
4648
payload_off:
4749
description: The payload that represents the off state.
4850
required: false
4951
type: string
50-
default: OFF
52+
default: "OFF"
5153
availability_topic:
5254
description: "The MQTT topic subscribed to receive birth and LWT messages from the MQTT device. If `availability_topic` is not defined, the binary sensor availability state will always be `available`. If `availability_topic` is defined, the binary sensor availability state will be `unavailable` by default."
5355
required: false

0 commit comments

Comments
 (0)