diff --git a/atom.xml b/atom.xml index f20e7494b1..40f559cc6b 100644 --- a/atom.xml +++ b/atom.xml @@ -4,7 +4,7 @@
The mqtt
binary sensor platform uses an MQTT message payload to set the binary sensor to one of two states: on
or off
.
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
.
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.
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.
To use an MQTT binary sensor in your installation, add the following to your configuration.yaml
file:
# Example configuration.yaml entry
binary_sensor:
@@ -135,6 +135,9 @@
In this section, you will find some real-life examples of how to use this sensor.
+To test, you can use the command line tool mosquitto_pub
shipped with mosquitto
or the mosquitto-clients
package to send MQTT messages. To set the state of the binary sensor manually:
$ mosquitto_pub -h 127.0.0.1 -t home-assistant/window/contact -m "OFF"
@@ -155,6 +158,24 @@
value_template: '{{ value.x }}'
Assuming that you have flashed your ESP8266 unit with ESPEasy. Under “Config” is a name (“Unit Name:”) set for your device (here it’s “bathroom”). A configuration for a “Controller” for MQTT with the protocol “OpenHAB MQTT” is present and the entries (“Controller Subscribe:” and “Controller Publish:”) are adjusted to match your needs. In this example, the topics are prefixed with “home”. Also, add a “Switch Input” in the “Devices” tap with the name “switch” and “button” as value.
+As soon as the unit is online, you will get the state of the attached button.
+home/bathroom/status Connected
+...
+home/bathroom/switch/button 1
+
+The configuration will look like the example below:
+# Example configuration.yml entry
+binary_sensor:
+ - platform: mqtt
+ name: Bathroom
+ state_topic: "home/bathroom/switch/button"
+ payload_on: "1"
+ payload_off: "0"
+
+