From 0afeb3907c28730c7d1e54b0f8c4cae4c8028398 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sun, 22 Nov 2015 08:33:17 +0100 Subject: [PATCH] Initial MQTT binary sensor page --- .../_components/binary_sensor.mqtt.markdown | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 source/_components/binary_sensor.mqtt.markdown diff --git a/source/_components/binary_sensor.mqtt.markdown b/source/_components/binary_sensor.mqtt.markdown new file mode 100644 index 00000000000..50a97096714 --- /dev/null +++ b/source/_components/binary_sensor.mqtt.markdown @@ -0,0 +1,44 @@ +--- +layout: component +title: "MQTT binary sensor" +description: "Instructions how to integrate MQTT binary sensors within Home Assistant." +date: 2015-05-30 23:21 +sidebar: true +comments: false +sharing: true +footer: true +logo: mqtt.png +ha_category: Binary Sensor +--- + + +This MQTT binary sensor implementation uses the MQTT message payload as the sensor value. If messages in this state_topic are published with *RETAIN* flag, the sensor will receive an instant update with the last known value. Otherwise, the initial state will be off. + +To use your MQTT binary sensor in your installation, add the following to your `configuration.yaml` file: + +```yaml +# Example configuration.yml entry +binary_sensor: + platform: mqtt + state_topic: "home-assistant/window/contact" + name: "MQTT Sensor" + qos: 0 + payload_on: "ON" + payload_of: "OFF" +``` + +Configuration variables: + +- **state_topic** (*Required*): The MQTT topic subscribed to receive sensor values. +- **name** (*Optional*): The name of the sensor. Default is 'MQTT Sensor'. +- **qos** (*Optional*): The maximum QoS level of the state topic. Default is 0. +- **payload_on** (*Optional*): The payload that represents on state. Default is "ON". +- **payload_off** (*Optional*): The payload that represents state. Default is "OFF". + + +For a quick check you can use the commandline tools shipped with `mosquitto` to send MQTT messages. Set the state of your sensor manually: + +```bash +$ mosquitto_pub -h 127.0.0.1 -t home-assistant/window/contact -m "OFF" +``` +